X-Git-Url: https://git.treefish.org/~alex/backmeupscotty.git/blobdiff_plain/c5f074f40b959c83a23cf6bf065e0ce27096032e..037b181608965bcd921c2ae115af03c18ed27b35:/backmeupscotty?ds=inline diff --git a/backmeupscotty b/backmeupscotty index ff0f07f..d6f358f 100644 --- a/backmeupscotty +++ b/backmeupscotty @@ -5,6 +5,7 @@ REMOTE_DIR=/tmp/backmeupscotty/test ARCHIVE_KEEPNBACKUPS=30 ARCHIVE_KEEPNDAYS=30 BACKUP_RUNEVERYNTHDAY=1 +BWLIMIT=500KiB _ERROR_ENCOUNTERED=0 @@ -18,7 +19,7 @@ function scottyline { function scottyinfo { if [ $_ERROR_ENCOUNTERED -eq 0 ]; then - scottyline $@ + scottyline $@ else scottyline $@ >&2 fi @@ -57,20 +58,19 @@ function isIncomplete { } function isNthDay { - if [ $(( ( $(date +%s) / (60*60*24) ) % $BACKUP_RUNEVERYNTHDAY )) -eq 0 ]; + if [ $(( ( $(date +%s) / (60*60*24) ) % $BACKUP_RUNEVERYNTHDAY )) -eq 0 ]; then return 0 else return 1 - fi + fi } function latestTooOld { for oldbackup in $(grepbackups); do tstamp=$(echo $oldbackup | cut -d'-' -f1) - - if [ $(( $(date +%s) - $tstamp )) -lt \ - $(( ($BACKUP_RUNEVERYNTHDAY*24+12)*60*60 )) ] + + if [ $(( $(date +%s) - $tstamp )) -lt $(( ($BACKUP_RUNEVERYNTHDAY*24+12)*60*60 )) ] then return 1 fi @@ -114,16 +114,17 @@ function scottysync { fi scottyinfo "Starting rsync." - rsync -e ssh \ - -v -aHAX --numeric-ids --delete --delete-excluded \ - --link-dest=$dir_current \ - $rsync_exclude \ - $SYNC_SRC/ $REMOTE_HOST:$dir_incomplete/ - + rsync -e ssh --bwlimit=$BWLIMIT \ + -v -aHAX --numeric-ids --delete --delete-excluded \ + --link-dest=$dir_current \ + $rsync_exclude \ + $SYNC_SRC/ $REMOTE_HOST:$dir_incomplete/ + if [ $? -eq 0 ]; then scottyinfo "Timestamping completed backup and linking to current backup." ssh255 $REMOTE_HOST \ - "mv $dir_incomplete $dir_timestamped && rm -f $dir_current && ln -s $(basename $dir_timestamped) $dir_current" + "mv $dir_incomplete $dir_timestamped && rm -f $dir_current && \ + ln -s $(basename $dir_timestamped) $dir_current" else scottyerror "Rsync failed." fi @@ -201,7 +202,7 @@ function backmeupscotty { ;; esac done - + ssh255 $REMOTE_HOST exit if latestTooOld; then