File tree 1 file changed +30
-0
lines changed
1 file changed +30
-0
lines changed Original file line number Diff line number Diff line change
1
+ #! /bin/bash
2
+
3
+ BACKUP_FILES_DIRECTORY=" /root/backup_disk/backups"
4
+ BACKUP_RESULT_DIRECTORY=" /root/backup_disk"
5
+
6
+ args=" "
7
+ declare -a backups
8
+ idx=0
9
+
10
+ if [ -f $BACKUP_FILES_DIRECTORY ]; then
11
+ echo " [Error] $BACKUP_FILES_DIRECTORY is a file!"
12
+ exit 1
13
+ elif [ ! -e $BACKUP_FILES_DIRECTORY ]; then
14
+ echo " [*] Make Directory $BACKUP_FILES_DIRECTORY "
15
+ mkdir $BACKUP_FILES_DIRECTORY
16
+ fi
17
+
18
+ echo " [*] Compress user's home directories in ${BACKUP_FILES_DIRECTORY} /"
19
+ for dir in /home/*
20
+ do
21
+ username=` basename " $dir " `
22
+ echo " [*] Backup-ing ${username} 's directories"
23
+ tar -cvzPf " ${BACKUP_FILES_DIRECTORY} /cnupro-${username} .tar.gz" " $dir " 1> /dev/null
24
+ backups[$idx ]=" ${BACKUP_FILES_DIRECTORY} /cnupro-${username} .tar.gz"
25
+ args=" $args \"\$ {backups[$idx ]}\" "
26
+ idx=` expr $idx + 1`
27
+ done
28
+
29
+ echo " [*] Compress user's backup files to one backup file in /root/"
30
+ eval " tar -cvzf ${BACKUP_RESULT_DIRECTORY} /all-cnupro.tar.gz $args 1>/dev/null"
You can’t perform that action at this time.
0 commit comments