Created
June 3, 2010 03:17
-
-
Save zhengjia/423388 to your computer and use it in GitHub Desktop.
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
ROOT_BACKUP_DIR=/media/RD1000/backup | |
# A list of directories to back up. Put each on its own line | |
DIR_TO_BACKUP=`cat <<EOF | |
/home/j/backup-sync | |
/var/www | |
EOF` | |
# The rsync command with options | |
BACKUP_CMD='rsync -Rvurogptl' | |
LOG_FILE=$ROOT_BACKUP_DIR/rsync.`date +%F`.log | |
# Loop through and back up all the directories listed | |
for dir in $DIR_TO_BACKUP; do | |
$BACKUP_CMD $dir $ROOT_BACKUP_DIR 2>&1 >$LOG_FILE | |
done | |
# Clean up all log files older than 30 days | |
find $ROOT_BACKUP_DIR/ -maxdepth 1 -type f -name 'rsync.????-??-??.log' -mtime $ | |
0 1 * * * /root/backup.sh |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment