Only forget old backups if the directory already exists

This commit is contained in:
Bob Mottram 2015-11-05 08:16:00 +00:00
parent 96d6fea7ab
commit 2f39f4d6c6
1 changed files with 7 additions and 3 deletions

View File

@ -2469,8 +2469,10 @@ function backup_directory_to_usb {
echo -n "}' | awk -F '/' '{print " >> /usr/bin/$BACKUP_SCRIPT_NAME echo -n "}' | awk -F '/' '{print " >> /usr/bin/$BACKUP_SCRIPT_NAME
echo -n '$2' >> /usr/bin/$BACKUP_SCRIPT_NAME echo -n '$2' >> /usr/bin/$BACKUP_SCRIPT_NAME
echo "}')" >> /usr/bin/$BACKUP_SCRIPT_NAME echo "}')" >> /usr/bin/$BACKUP_SCRIPT_NAME
echo ' if [ -d $USB_MOUNT/backup/${2} ]; then' >> /usr/bin/$BACKUP_SCRIPT_NAME
echo -n " obnam forget --keep=${BACKUP_MAX_DAYS}d " >> /usr/bin/$BACKUP_SCRIPT_NAME echo -n " obnam forget --keep=${BACKUP_MAX_DAYS}d " >> /usr/bin/$BACKUP_SCRIPT_NAME
echo '-r $USB_MOUNT/backup/${2} --encrypt-with $MY_BACKUP_KEY_ID ${1}' >> /usr/bin/$BACKUP_SCRIPT_NAME echo '-r $USB_MOUNT/backup/${2} --encrypt-with $MY_BACKUP_KEY_ID ${1}' >> /usr/bin/$BACKUP_SCRIPT_NAME
echo ' fi' >> /usr/bin/$BACKUP_SCRIPT_NAME
echo ' obnam backup -r $USB_MOUNT/backup/${2} --encrypt-with $MY_BACKUP_KEY_ID ${1}' >> /usr/bin/$BACKUP_SCRIPT_NAME echo ' obnam backup -r $USB_MOUNT/backup/${2} --encrypt-with $MY_BACKUP_KEY_ID ${1}' >> /usr/bin/$BACKUP_SCRIPT_NAME
else else
# For rsyncrypto usage see http://archive09.linux.com/feature/125322 # For rsyncrypto usage see http://archive09.linux.com/feature/125322
@ -3977,8 +3979,10 @@ function backup_directory_to_friend {
echo -n '$2' >> /usr/bin/$BACKUP_TO_FRIENDS_SCRIPT_NAME echo -n '$2' >> /usr/bin/$BACKUP_TO_FRIENDS_SCRIPT_NAME
echo "}')" >> /usr/bin/$BACKUP_TO_FRIENDS_SCRIPT_NAME echo "}')" >> /usr/bin/$BACKUP_TO_FRIENDS_SCRIPT_NAME
echo ' if [ -d $SERVER_DIRECTORY/backup/${2} ]; then' >> /usr/bin/$BACKUP_TO_FRIENDS_SCRIPT_NAME
echo -n " obnam forget --keep=${BACKUP_MAX_DAYS}d " >> /usr/bin/$BACKUP_TO_FRIENDS_SCRIPT_NAME echo -n " obnam forget --keep=${BACKUP_MAX_DAYS}d " >> /usr/bin/$BACKUP_TO_FRIENDS_SCRIPT_NAME
echo '-r $SERVER_DIRECTORY/backup/${2} --encrypt-with $MY_BACKUP_KEY_ID ${1}' >> /usr/bin/$BACKUP_TO_FRIENDS_SCRIPT_NAME echo '-r $SERVER_DIRECTORY/backup/${2} --encrypt-with $MY_BACKUP_KEY_ID ${1}' >> /usr/bin/$BACKUP_TO_FRIENDS_SCRIPT_NAME
echo ' fi' >> /usr/bin/$BACKUP_TO_FRIENDS_SCRIPT_NAME
echo ' obnam backup -r $SERVER_DIRECTORY/backup/${2} --encrypt-with $MY_BACKUP_KEY_ID ${1}' >> /usr/bin/$BACKUP_SCRIPT_NAME echo ' obnam backup -r $SERVER_DIRECTORY/backup/${2} --encrypt-with $MY_BACKUP_KEY_ID ${1}' >> /usr/bin/$BACKUP_SCRIPT_NAME
else else
# For rsyncrypto usage see http://archive09.linux.com/feature/125322 # For rsyncrypto usage see http://archive09.linux.com/feature/125322