-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
taeguk
committed
Sep 10, 2015
1 parent
ccff1ea
commit 6649c51
Showing
1 changed file
with
30 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
#!/bin/bash | ||
|
||
BACKUP_FILES_DIRECTORY="/root/backup_disk/backups" | ||
BACKUP_RESULT_DIRECTORY="/root/backup_disk" | ||
|
||
args="" | ||
declare -a backups | ||
idx=0 | ||
|
||
if [ -f $BACKUP_FILES_DIRECTORY ]; then | ||
echo "[Error] $BACKUP_FILES_DIRECTORY is a file!" | ||
exit 1 | ||
elif [ ! -e $BACKUP_FILES_DIRECTORY ]; then | ||
echo "[*] Make Directory $BACKUP_FILES_DIRECTORY" | ||
mkdir $BACKUP_FILES_DIRECTORY | ||
fi | ||
|
||
echo "[*] Compress user's home directories in ${BACKUP_FILES_DIRECTORY}/" | ||
for dir in /home/* | ||
do | ||
username=`basename "$dir"` | ||
echo "[*] Backup-ing ${username}'s directories" | ||
tar -cvzPf "${BACKUP_FILES_DIRECTORY}/cnupro-${username}.tar.gz" "$dir" 1>/dev/null | ||
backups[$idx]="${BACKUP_FILES_DIRECTORY}/cnupro-${username}.tar.gz" | ||
args="$args \"\${backups[$idx]}\"" | ||
idx=`expr $idx + 1` | ||
done | ||
|
||
echo "[*] Compress user's backup files to one backup file in /root/" | ||
eval "tar -cvzf ${BACKUP_RESULT_DIRECTORY}/all-cnupro.tar.gz $args 1>/dev/null" | ||
This comment has been minimized.
Sorry, something went wrong.
This comment has been minimized.
Sorry, something went wrong. |
압축 파일을 다시 압축 하는 것은 효율이 좋지 않습니다.
tar.gz가 아니라 tar로만 압축하는 것을 추천합니다!