Skip to content

Instantly share code, notes, and snippets.

@zhengjia
Created June 3, 2010 03:17
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save zhengjia/423388 to your computer and use it in GitHub Desktop.
Save zhengjia/423388 to your computer and use it in GitHub Desktop.
backup
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