ARCHIVE_KEEPNBACKUPS=30
ARCHIVE_KEEPNDAYS=30
+if [ $(pidof -x $(basename $0) | wc -w) -gt 2 ]; then
+ echo BACKMEUPSCOTTY: Another instance of $(basename $0) is already running! >&2
+ exit 1
+fi
+
while getopts ":q" opt; do
case $opt in
q)
echo BACKMEUPSCOTTY: Syncing $1 to $REMOTE_HOST:$REMOTE_BASE/$2 @$timestamp
+ if [ ! -d "$1" ]; then
+ echo BACKMEUPSCOTTY: Source dir $1 does not exist. Not syncing! >&2
+ return 1
+ fi
+
+ if [ $(ls -A "$1" | wc -l) -eq 0 ]; then
+ echo BACKMEUPSCOTTY: Source dir $1 is empty. Not syncing! >&2
+ return 1
+ fi
+
dir_current=$REMOTE_BASE/$2/current
dir_incomplete=$REMOTE_BASE/$2/incomplete
dir_timestamped=$REMOTE_BASE/$2/$timestamp-$(date -d @$timestamp +%Y%m%d%H%M%S)
rsync_exclude=$(eval echo --exclude={$3} | tr -d {})
fi
+ if (ssh $REMOTE_HOST '[ ! -d '$REMOTE_BASE/$2' ]'); then
+ echo BACKMEUPSCOTTY: Creating destination directory $REMOTE_HOST:$REMOTE_BASE/$2
+ ssh $REMOTE_HOST "mkdir $REMOTE_BASE/$2"
+ fi
+
+ if (ssh $REMOTE_HOST '[ -d '$REMOTE_BASE/$2/incomplete' ]'); then
+ echo BACKMEUPSCOTTY: Continuing old incomplete backup >&2
+ fi
+
echo BACKMEUPSCOTTY: Starting rsync
rsync -e ssh \
-v -aHAX --numeric-ids --delete --delete-excluded \