This commit is contained in:
Bob Mottram 2015-09-22 19:43:02 +01:00
parent 22cd2dda75
commit 5ee5d8445f
1 changed files with 14 additions and 14 deletions

View File

@ -2416,10 +2416,9 @@ function get_mariadb_owncloud_admin_password {
}
function backup_directory_to_usb {
if [ ! -d ${1} ]; then
echo "WARNING: directory does not exist: ${1}"
return
fi
echo "if [ ! -d ${1} ]; then" >> /usr/bin/$BACKUP_SCRIPT_NAME
echo " echo \"WARNING: directory does not exist: ${1}\"" >> /usr/bin/$BACKUP_SCRIPT_NAME
echo 'else' >> /usr/bin/$BACKUP_SCRIPT_NAME
if [[ $BACKUP_TYPE == 'obnam' ]]; then
BACKUP_KEY_EXISTS=$(gpg --list-keys "$MY_NAME (backup key)")
@ -2428,25 +2427,26 @@ function backup_directory_to_usb {
exit 43382
fi
MY_BACKUP_KEY_ID=$(gpg --list-keys "$MY_NAME (backup key)" | grep 'pub ' | awk -F ' ' '{print $2}' | awk -F '/' '{print $2}')
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
# For rsyncrypto usage see http://archive09.linux.com/feature/125322
echo "rsyncrypto -v -r ${1} $USB_MOUNT/backup/${2} $USB_MOUNT/backup/${2}.keys $BACKUP_CERTIFICATE" >> /usr/bin/$BACKUP_SCRIPT_NAME
echo " rsyncrypto -v -r ${1} $USB_MOUNT/backup/${2} $USB_MOUNT/backup/${2}.keys $BACKUP_CERTIFICATE" >> /usr/bin/$BACKUP_SCRIPT_NAME
fi
echo 'if [ ! "$?" = "0" ]; then' >> /usr/bin/$BACKUP_SCRIPT_NAME
echo " umount $USB_MOUNT" >> /usr/bin/$BACKUP_SCRIPT_NAME
echo " rm -rf $USB_MOUNT" >> /usr/bin/$BACKUP_SCRIPT_NAME
echo ' if [ ! "$?" = "0" ]; then' >> /usr/bin/$BACKUP_SCRIPT_NAME
echo " umount $USB_MOUNT" >> /usr/bin/$BACKUP_SCRIPT_NAME
echo " rm -rf $USB_MOUNT" >> /usr/bin/$BACKUP_SCRIPT_NAME
if [[ ${1} == "/root/temp"* || ${1} == *"tempbackup" ]]; then
echo " shred -zu ${1}/*" >> /usr/bin/$BACKUP_SCRIPT_NAME
echo " rm -rf ${1}" >> /usr/bin/$BACKUP_SCRIPT_NAME
fi
echo ' exit 853' >> /usr/bin/$BACKUP_SCRIPT_NAME
echo ' fi' >> /usr/bin/$BACKUP_SCRIPT_NAME
if [[ ${1} == "/root/temp"* || ${1} == *"tempbackup" ]]; then
echo " shred -zu ${1}/*" >> /usr/bin/$BACKUP_SCRIPT_NAME
echo " rm -rf ${1}" >> /usr/bin/$BACKUP_SCRIPT_NAME
fi
echo ' exit 853' >> /usr/bin/$BACKUP_SCRIPT_NAME
echo 'fi' >> /usr/bin/$BACKUP_SCRIPT_NAME
if [[ ${1} == "/root/temp"* || ${1} == *"tempbackup" ]]; then
echo "shred -zu ${1}/*" >> /usr/bin/$BACKUP_SCRIPT_NAME
echo "rm -rf ${1}" >> /usr/bin/$BACKUP_SCRIPT_NAME
fi
}
function backup_database {