Created
December 11, 2012 20:23
-
-
Save t-mart/4261818 to your computer and use it in GitHub Desktop.
Local incremental backup of Windows' drives with RSync via Cygwin.
This file contains hidden or 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/sh | |
#Local incremental backup of Windows' drives with RSync via Cygwin. | |
#Run like ./backup.sh cat_pictures_drive d g | |
#where d is the drive containing cat pictures | |
#and g is the destination of the backup. | |
#Backups will be made on g like G:\cat_pictures_drive_backup\backup-YY-MM... | |
#high-level description of the content we're backing up | |
#e.g. music | |
#e.g. photos | |
content=$1 | |
#lower case drive letter of source data to back up | |
#e.g. c | |
srcdrv=$2 | |
#lower case drive letter of destination where backup will be stored | |
#e.g. f | |
destdrv=$3 | |
#exclude the files listed line-by-line in this file | |
excl=/cygdrive/d/Tasks/excludes.txt | |
#source dir to backup | |
#use trailing slash! | |
src=/cygdrive/"$2"/ | |
#destination dir to store backup | |
dest=/cygdrive/"$3"/"$1"_backup | |
#log file | |
log=/cygdrive/"$3"/"$1"_backup.log | |
#a current timestamp, formatted as you'd like | |
#keep the units sorted, i.e. year-month-day-hour... | |
date=`date "+%F-%H-%M-%S.%N"` | |
rsync --archive --human-readable --delete --ignore-errors --itemize-changes --whole-file --exclude-from=$excl --numeric-ids --link-dest=$dest/current $src $dest/backup-$date 2>&1 | tee $log | |
rm -f $dest/current | |
ln -s $dest/backup-$date $dest/current |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment