| 23,8 → 23,8 |
| |
| # locking |
| if [ -e $LOCK ]; then |
| echo "Another instance running. Exit" >> $LOG |
| exit 1 |
| echo "Another instance running. Exit" >> $LOG 2>&1 |
| exit 0 |
| fi |
| touch $LOCK |
| |
| 36,22 → 36,16 |
| fi |
| |
| # rotate directories on remote system |
| $LOGIN "test -d ${DEST}/backup.${TODAY}" |
| if [ $? -eq 1 ]; then |
| # get last day |
| LASTDAY=$($LOGIN "ls -t ${DEST} |head -1") |
| #YESTERDAY=$(date -d "1 day ago" +"%Y%m%d") |
| # copy using hard-links to preserve disk space |
| $LOGIN "/bin/cp -al ${DEST}/${LASTDAY} ${DEST}/backup.${TODAY}" |
| echo "if [ ! -d ${DEST}/backup.${TODAY} ]; then |
| /bin/cp -Rpl ${DEST}/\$(ls -1 ${DEST} | tail -1) ${DEST}/backup.${TODAY} |
| fi |
| |
| # remove old directories |
| dirs=$($LOGIN "ls -1 -tr $DEST/ | wc -l") |
| if [ $dirs -gt $KEEP ]; then |
| logger -f $LOG "deleting old directories...." |
| $LOGIN "ls -1 -tr $DEST/ | tail -n 1 | xargs rm -rf" |
| fi |
| if [ \$(ls -1 $DEST/ | wc -l) -gt $KEEP ]; then |
| ls -1 -r --color=never $DEST/ | tail -n 1 | xargs rm -rf |
| fi" > /tmp/cphome.sh |
| |
| cat /tmp/cphome.sh | $LOGIN |
| |
| /usr/bin/rsync -LpDtgHrz -e "ssh -i $KEY -p $PORT" --log-file=$LOG --delete --exclude-from=$EXCLUDES --files-from=$SOURCES / $USER@$HOST:$DEST/backup.$TODAY |
| |
| rm $LOCK |
| rm -f $LOCK |