Created
December 21, 2013 13:18
-
-
Save nyxcalamity/8069197 to your computer and use it in GitHub Desktop.
script for complete system and data backup
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
#!/bin/bash | |
#Performs a recursive directory backup by copying it to a specified location in a raw format. | |
#Usefull rsync shortcuts: | |
#-a, --archive archive mode; equals -rlptgoD (no -H,-A,-X) | |
#-n, --dry-run perform a trial run with no changes made | |
#-h, --human-readable output numbers in a human-readable format | |
#-W, --whole-file copy files whole (w/o delta-xfer algorithm) | |
#--del an alias for --delete-during | |
#--delete-during receiver deletes during xfer, not before | |
#--log-file=FILE log what we're doing to the specified FILE | |
#--list-only list the files instead of copying them | |
#--------------------------------------------------------------------------------------------------- | |
# CUSTOMIZATION SECTION START | |
#--------------------------------------------------------------------------------------------------- | |
export TARGET=/media/nyxcalamity/nyx-warehouse | |
export SOURCE_WH=/mnt/wh | |
export TARGET_WH=$TARGET/warehouse | |
export SOURCE_WS=/home/nyxcalamity/ws | |
export TARGET_WS=$TARGET/workspace | |
export TARGET_SYS=$TARGET/sys-backup | |
export LOG_FILE_WH=$TARGET/rsync-backup-wh.log | |
export LOG_FILE_WS=$TARGET/rsync-backup-ws.log | |
#--------------------------------------------------------------------------------------------------- | |
# CUSTOMIZATION SECTION END | |
#--------------------------------------------------------------------------------------------------- | |
export OK="$(tput setaf 2)DONE$(tput sgr0)" | |
echo -n "Backing up warehouse: " | |
rsync -ah --del --log-file=$LOG_FILE_WH $SOURCE_WH/ $TARGET_WH/ | |
find $TARGET_WH -type d -empty -delete | |
echo $OK | |
echo -n "Backing up workspace: " | |
rsync -ah --del --log-file=$LOG_FILE_WS $SOURCE_WS/ $TARGET_WS/ | |
find $TARGET_WS -type d -empty -delete | |
echo $OK | |
echo -n "Backing up system files: " | |
cp -arf ~/.ssh $TARGET_SYS | |
cp -f ~/.profile $TARGET_SYS/.profile | |
echo $OK | |
echo "$(tput setaf 4)Backup completed.$(tput sgr0)" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment