Skip to content
Snippets Groups Projects
Commit a8e7aeb4 authored by Bob Mottram's avatar Bob Mottram
Browse files

Temp directory for duplicity

parent 53ca0377
No related branches found
No related tags found
No related merge requests found
......@@ -13,7 +13,7 @@
# License
# =======
#
# Copyright (C) 2014-2016 Bob Mottram <bob@freedombone.net>
# Copyright (C) 2014-2017 Bob Mottram <bob@freedombone.net>
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as published by
......@@ -34,6 +34,20 @@ SUSPENDED_SITE=
# Dummy password used for the backup key
BACKUP_DUMMY_PASSWORD='backup'
BACKUP_TEMP_DIRECTORY=/root/.backuptemp
function create_backups_temp_directory {
if [ ! -d $BACKUP_TEMP_DIRECTORY ]; then
mkdir $BACKUP_TEMP_DIRECTORY
fi
}
function remove_backups_temp_directory {
if [ -d $BACKUP_TEMP_DIRECTORY ]; then
rm -rf $BACKUP_TEMP_DIRECTORY
fi
}
function suspend_site {
# suspends a given website
SUSPENDED_SITE="$1"
......@@ -248,9 +262,10 @@ function set_obnam_client_name {
}
function backup_directory_to_usb_duplicity {
echo "$BACKUP_DUMMY_PASSWORD" | duplicity full --encrypt-key $MY_BACKUP_KEY_ID --full-if-older-than 4W --exclude-other-filesystems ${1} file://$USB_MOUNT/backup/${2}
create_backups_temp_directory
echo "$BACKUP_DUMMY_PASSWORD" | duplicity full --tempdir $BACKUP_TEMP_DIRECTORY --encrypt-key $MY_BACKUP_KEY_ID --full-if-older-than 4W --exclude-other-filesystems ${1} file://$USB_MOUNT/backup/${2}
if [[ $ENABLE_BACKUP_VERIFICATION == "yes" ]]; then
echo "$BACKUP_DUMMY_PASSWORD" | duplicity verify --encrypt-key $MY_BACKUP_KEY_ID --full-if-older-than 4W --exclude-other-filesystems ${1} file://$USB_MOUNT/backup/${2}
echo "$BACKUP_DUMMY_PASSWORD" | duplicity verify --tempdir $BACKUP_TEMP_DIRECTORY --encrypt-key $MY_BACKUP_KEY_ID --full-if-older-than 4W --exclude-other-filesystems ${1} file://$USB_MOUNT/backup/${2}
if [ ! "$?" = "0" ]; then
umount $USB_MOUNT
rm -rf $USB_MOUNT
......@@ -260,9 +275,11 @@ function backup_directory_to_usb_duplicity {
fi
function_check restart_site
restart_site
remove_backups_temp_directory
exit 683252
fi
fi
remove_backups_temp_directory
}
function backup_directory_to_usb_obnam {
......@@ -330,7 +347,9 @@ function restore_directory_from_usb_obnam {
}
function restore_directory_from_usb_duplicity {
echo "$BACKUP_DUMMY_PASSWORD" | duplicity restore --force file://$USB_MOUNT/backup/${2} ${1}
create_backups_temp_directory
echo "$BACKUP_DUMMY_PASSWORD" | duplicity restore --tempdir $BACKUP_TEMP_DIRECTORY --force file://$USB_MOUNT/backup/${2} ${1}
remove_backups_temp_directory
}
function restore_directory_from_usb {
......@@ -357,7 +376,9 @@ function restore_directory_from_friend_obnam {
}
function restore_directory_from_friend_duplicity {
echo "$BACKUP_DUMMY_PASSWORD" | duplicity restore --force file://$SERVER_DIRECTORY/backup/${2} ${1}
create_backups_temp_directory
echo "$BACKUP_DUMMY_PASSWORD" | duplicity restore --tempdir $BACKUP_TEMP_DIRECTORY --force file://$SERVER_DIRECTORY/backup/${2} ${1}
remove_backups_temp_directory
}
function restore_directory_from_friend {
......@@ -401,9 +422,10 @@ function set_user_permissions {
}
function backup_directory_to_friend_duplicity {
echo "$BACKUP_DUMMY_PASSWORD" | duplicity full --ssh-askpass --encrypt-key ${ADMIN_BACKUP_KEY_ID} --full-if-older-than 4W --exclude-other-filesystems ${1} $SERVER_DIRECTORY/backup/${2}
create_backups_temp_directory
echo "$BACKUP_DUMMY_PASSWORD" | duplicity full --tempdir $BACKUP_TEMP_DIRECTORY --ssh-askpass --encrypt-key ${ADMIN_BACKUP_KEY_ID} --full-if-older-than 4W --exclude-other-filesystems ${1} $SERVER_DIRECTORY/backup/${2}
if [[ $ENABLE_BACKUP_VERIFICATION == "yes" ]]; then
echo "$BACKUP_DUMMY_PASSWORD" | duplicity verify --ssh-askpass --encrypt-key ${ADMIN_BACKUP_KEY_ID} --full-if-older-than 4W --exclude-other-filesystems ${1} $SERVER_DIRECTORY/backup/${2}
echo "$BACKUP_DUMMY_PASSWORD" | duplicity verify --tempdir $BACKUP_TEMP_DIRECTORY --ssh-askpass --encrypt-key ${ADMIN_BACKUP_KEY_ID} --full-if-older-than 4W --exclude-other-filesystems ${1} $SERVER_DIRECTORY/backup/${2}
if [ ! "$?" = "0" ]; then
if [[ ${1} == "/root/temp"* || ${1} == *"tempbackup" ]]; then
shred -zu ${1}/*
......@@ -411,9 +433,11 @@ function backup_directory_to_friend_duplicity {
fi
function_check restart_site
restart_site
remove_backups_temp_directory
exit 683252
fi
fi
remove_backups_temp_directory
}
function backup_directory_to_friend_obnam {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment