
Originally Posted by
Lallo
LaFong your diff is very interesting.
I've looked at it but not implemented it yet in production (scared

)
Just a couple of questions:
1) The original script with DRCP="yes" has a feature to copy via ssh the backups on anoter server. Your diff does not take care of removing this part right?
Do you mean, removing old backups on the remote server? No, it does not. You could change it to do that. You could change the script like this:
Code:
+ # Remove previous week of backups from 2 weeks ago
+ TWO_WEEKS_AGO=$(expr "$BACKUPWEEK" \- 2)
+ LASTYEAR=$(expr `date +%Y` \- 1)
+ FINALWEEK=`date -d "$LASTYEAR"1228 +%V`
+ if [ "$BACKUPWEEK" -eq "1" ] ; then
+ TWO_WEEKS_AGO=$(expr "$FINALWEEK" \- 1)
+ elif [ "$BACKUPWEEK" -eq "2" ] ; then
+ TWO_WEEKS_AGO="$FINALWEEK"
+ elif [ "$TWO_WEEKS_AGO" -lt "10" ] ; then
+ TWO_WEEKS_AGO=0"$TWO_WEEKS_AGO"
+ fi
+ TWO_WEEK_BACKUP=`ssh -i /root/.ssh/id_rsa $SSHUSER@$REMOTEHOST "ls -A -1 "$REMOTEDIR" | grep "$TWO_WEEKS_AGO" | grep "$BACKUPNAME" | cut -d _ -f1 | head -n1"`
+ if [ -z "$TWO_WEEK_BACKUP" ]
+ then
+ echo
+ echo "No two-week old backups found"
+ echo
+ else
+ echo
+ echo "Two-week old backup found...old week= "$TWO_WEEKS_AGO" current week= $BACKUPWEEK"
+ echo
+ for i in `ssh -i /root/.ssh/id_rsa $SSHUSER@$REMOTEHOST "ls -A -1 "$REMOTEDIR""$TWO_WEEKS_AGO"_"$BACKUPNAME"*"`
+ do
+ ssh -i /root/.ssh/id_rsa $SSHUSER@$REMOTEHOST "rm $i"
+ if [ "$?" -ne "0" ]
+ then
+ echo "Error during delete!"
+ else
+ echo "$i deleted"
+ fi
+ done
+ echo
+ fi
fi
+ If you wanted to test first, change the remove ("rm $i") line to just list the file:
Code:
ssh -i /root/.ssh/id_rsa $SSHUSER@$REMOTEHOST "ls $i"
Or, if you don't need email acknowledgment of deletions, just use the cronjob by pebcomputing on the remote computer, changing the path as needed.
2) Could i still keep my crontab lines unchanged with this? I guess yes, but you know... :-)
Sure.