REMOTE_BASE=/tmp/backmeupscotty
ARCHIVE_KEEPNBACKUPS=30
ARCHIVE_KEEPNDAYS=30
+BACKUP_RUNEVERYNTHDAY=1
function upperme {
echo $(basename $0) | tr '[:lower:]' '[:upper:]'
exit 1
fi
-while getopts ":q" opt; do
+while getopts "qn:" opt; do
case $opt in
q)
exec > /dev/null
;;
+ n)
+ BACKUP_RUNEVERYNTHDAY=$OPTARG
+ ;;
esac
done
ssh $REMOTE_HOST "ls $REMOTE_BASE/$1" | grep -E '[0-9]+-[0-9]+'
}
+function isIncomplete {
+ if ( ssh $REMOTE_HOST '[ -d '$REMOTE_BASE/$1/incomplete' ]' ); then
+ return 0
+ else
+ return 1
+ fi
+}
+
+function isIncompleteOrNthDay {
+ if isIncomplete $1 || \
+ [ $(( ( $(date +%s) / (60*60*24) ) % $BACKUP_RUNEVERYNTHDAY )) -eq 0 ];
+ then
+ return 0
+ else
+ return 1
+ fi
+
+}
+
function scottysync {
timestamp=$(date +%s)
ssh $REMOTE_HOST "mkdir $REMOTE_BASE/$2"
fi
- if (ssh $REMOTE_HOST '[ -d '$REMOTE_BASE/$2/incomplete' ]'); then
+ if isIncomplete $2; then
scottyerror Continuing old incomplete backup
fi
ARCHIVE_KEEPNBACKUPS=30
ARCHIVE_KEEPNDAYS=1
+if ! isIncompleteOrNthDay dest; then
+ scottyinfo "This is not the nth day and no incomplete backup exists."
+ exit 0
+fi
+
scottysync /home/alex/backtest/source dest "/gack,/gugu/*"
scottysync /home/alex/backtest/source2 dest2