verify backups

This commit is contained in:
Bob Mottram 2015-12-17 16:13:36 +00:00
parent ab54ef2895
commit 7de611fcc8
2 changed files with 28 additions and 8 deletions

View File

@ -171,6 +171,16 @@ function backup_directory_to_usb {
fi fi
obnam force-lock -r $USB_MOUNT/backup/${2} --encrypt-with $MY_BACKUP_KEY_ID ${1} obnam force-lock -r $USB_MOUNT/backup/${2} --encrypt-with $MY_BACKUP_KEY_ID ${1}
obnam backup -r $USB_MOUNT/backup/${2} --encrypt-with $MY_BACKUP_KEY_ID ${1} obnam backup -r $USB_MOUNT/backup/${2} --encrypt-with $MY_BACKUP_KEY_ID ${1}
obnam verify -r $USB_MOUNT/backup/${2} --encrypt-with $MY_BACKUP_KEY_ID ${1}
if [ ! "$?" = "0" ]; then
umount $USB_MOUNT
rm -rf $USB_MOUNT
if [[ ${1} == "/root/temp"* || ${1} == *"tempbackup" ]]; then
shred -zu ${1}/*
rm -rf ${1}
fi
exit 71
fi
obnam forget --keep=30d -r $USB_MOUNT/backup/${2} --encrypt-with $MY_BACKUP_KEY_ID obnam forget --keep=30d -r $USB_MOUNT/backup/${2} --encrypt-with $MY_BACKUP_KEY_ID
if [ ! "$?" = "0" ]; then if [ ! "$?" = "0" ]; then
umount $USB_MOUNT umount $USB_MOUNT

View File

@ -76,16 +76,26 @@ function backup_directory_to_friend {
if [ ! -d $SERVER_DIRECTORY/backup/${2} ]; then if [ ! -d $SERVER_DIRECTORY/backup/${2} ]; then
mkdir -p $SERVER_DIRECTORY/backup/${2} mkdir -p $SERVER_DIRECTORY/backup/${2}
fi fi
obnam force-lock -r $SERVER_DIRECTORY/backup/${2} --encrypt-with $ADMIN_BACKUP_KEY_ID ${1} obnam force-lock -r $SERVER_DIRECTORY/backup/${2} --encrypt-with ${ADMIN_BACKUP_KEY_ID} ${1}
obnam backup -r $SERVER_DIRECTORY/backup/${2} --encrypt-with $ADMIN_BACKUP_KEY_ID ${1} obnam backup -r $SERVER_DIRECTORY/backup/${2} --encrypt-with ${ADMIN_BACKUP_KEY_ID} ${1}
obnam forget --keep=30d -r $SERVER_DIRECTORY/backup/${2} --encrypt-with $ADMIN_BACKUP_KEY_ID obnam verify -r $SERVER_DIRECTORY/backup/${2} --encrypt-with ${ADMIN_BACKUP_KEY_ID} ${1}
if [ ! "$?" = "0" ]; then if [ ! "$?" = "0" ]; then
if [[ ${1} == "/root/temp"* || ${1} == *"tempbackup" ]]; then if [[ ${1} == "/root/temp"* || ${1} == *"tempbackup" ]]; then
shred -zu /root/temp${2}/* shred -zu /root/temp${2}/*
rm -rf /root/temp${2} rm -rf /root/temp${2}
fi fi
# Send a warning email # Send a warning email
echo "Unable to backup ${2}" | mail -s "${PROJECT_NAME} backup to friends" $ADMIN_EMAIL_ADDRESS echo "Unable to verify ${2}" | mail -s "${PROJECT_NAME} backup to friends" ${ADMIN_EMAIL_ADDRESS}
exit 953
fi
obnam forget --keep=30d -r $SERVER_DIRECTORY/backup/${2} --encrypt-with ${ADMIN_BACKUP_KEY_ID}
if [ ! "$?" = "0" ]; then
if [[ ${1} == "/root/temp"* || ${1} == *"tempbackup" ]]; then
shred -zu /root/temp${2}/*
rm -rf /root/temp${2}
fi
# Send a warning email
echo "Unable to backup ${2}" | mail -s "${PROJECT_NAME} backup to friends" ${ADMIN_EMAIL_ADDRESS}
exit 853 exit 853
fi fi
if [[ ${1} == "/root/temp"* || ${1} == *"tempbackup" ]]; then if [[ ${1} == "/root/temp"* || ${1} == *"tempbackup" ]]; then
@ -127,9 +137,9 @@ function backup_configuration {
fi fi
cp -f $CONFIG_FILE /root/tempbackupconfig cp -f $CONFIG_FILE /root/tempbackupconfig
cp -f $COMPLETION_FILE /root/tempbackupconfig cp -f $COMPLETION_FILE /root/tempbackupconfig
if [ -f $BACKUP_EXTRA_DIRECTORIES ]; then if [ -f $BACKUP_EXTRA_DIRECTORIES ]; then
cp -f $BACKUP_EXTRA_DIRECTORIES /root/tempbackupconfig cp -f $BACKUP_EXTRA_DIRECTORIES /root/tempbackupconfig
fi fi
backup_directory_to_friend /root/tempbackupconfig config backup_directory_to_friend /root/tempbackupconfig config
} }
@ -486,7 +496,7 @@ function backup_extra_directories {
if [ -d "$backup_dir" ]; then if [ -d "$backup_dir" ]; then
destination_dir=$(echo "$backup_line" | awk -F ',' '{print $2}' | sed -e 's/^[[:space:]]*//' -e 's/[[:space:]]*$//') destination_dir=$(echo "$backup_line" | awk -F ',' '{print $2}' | sed -e 's/^[[:space:]]*//' -e 's/[[:space:]]*$//')
if [[ $(valid_backup_destination "$destination_dir") == "yes" ]]; then if [[ $(valid_backup_destination "$destination_dir") == "yes" ]]; then
backup_directory_to_friend "$backup_dir" "$destination_dir" backup_directory_to_friend "$backup_dir" "$destination_dir"
else else
echo $"WARNING: The backup directory $destination_dir is already used." echo $"WARNING: The backup directory $destination_dir is already used."
echo $"Choose a different destination name for backing up $backup_dir" echo $"Choose a different destination name for backing up $backup_dir"