From 63b1a9eda639ce81ab541223a497925559d62f9c Mon Sep 17 00:00:00 2001 From: Bob Mottram Date: Sun, 13 Sep 2015 17:45:43 +0100 Subject: [PATCH] Add backup using obnam --- src/freedombone | 28 ++++++++++++++++++---------- 1 file changed, 18 insertions(+), 10 deletions(-) diff --git a/src/freedombone b/src/freedombone index 07ac97cb..b30dfec7 100755 --- a/src/freedombone +++ b/src/freedombone @@ -2416,7 +2416,9 @@ function get_mariadb_owncloud_admin_password { } function backup_directory_to_usb { - if [[ $BACKUP_TYPE == 'rsync' ]]; then + if [[ $BACKUP_TYPE == 'obnam' ]]; then + echo "obnam backup -r $USB_MOUNT/backup/${2} ${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 fi @@ -2440,7 +2442,7 @@ function create_backup_script { if grep -Fxq "create_backup_script" $COMPLETION_FILE; then return fi - apt-get -y install rsyncrypto cryptsetup libgfshare-bin + apt-get -y install rsyncrypto cryptsetup libgfshare-bin obnam get_mariadb_password get_mariadb_gnusocial_admin_password @@ -2909,7 +2911,9 @@ function restore_directory_from_usb { echo " mkdir ${1}" >> /usr/bin/$RESTORE_SCRIPT_NAME echo ' fi' >> /usr/bin/$RESTORE_SCRIPT_NAME - if [[ $BACKUP_TYPE == 'rsync' ]]; then + if [[ $BACKUP_TYPE == 'obnam' ]]; then + echo " obnam restore -r $USB_MOUNT/backup/${2} --to ${1}" >> /usr/bin/$RESTORE_SCRIPT_NAME + else echo " rsyncrypto -v -d -r $USB_MOUNT/backup/${2} ${1} $USB_MOUNT/backup/${2}.keys $BACKUP_CERTIFICATE" >> /usr/bin/$RESTORE_SCRIPT_NAME fi } @@ -2918,7 +2922,7 @@ function create_restore_script { if grep -Fxq "create_restore_script" $COMPLETION_FILE; then return fi - apt-get -y install rsyncrypto cryptsetup + apt-get -y install rsyncrypto cryptsetup obnam get_mariadb_password get_mariadb_gnusocial_admin_password @@ -3671,7 +3675,10 @@ function create_freedns_updater { } function backup_directory_to_friend { - if [[ $BACKUP_TYPE == 'rsync' ]]; then + if [[ $BACKUP_TYPE == 'obnam' ]]; then + echo -n 'obnam backup -r $SERVER_DIRECTORY/backup/' >> /usr/bin/$BACKUP_SCRIPT_NAME + echo "${2} ${1}" >> /usr/bin/$BACKUP_SCRIPT_NAME + else # For rsyncrypto usage see http://archive09.linux.com/feature/125322 echo -n "rsyncrypto -v -r ${1} " >> /usr/bin/$BACKUP_TO_FRIENDS_SCRIPT_NAME echo -n '$SERVER_DIRECTORY/backup/' >> /usr/bin/$BACKUP_TO_FRIENDS_SCRIPT_NAME @@ -3703,7 +3710,7 @@ function backup_to_friends_servers { return fi - apt-get -y install rsyncrypto sshpass + apt-get -y install rsyncrypto sshpass obnam get_mariadb_password get_mariadb_gnusocial_admin_password @@ -4250,7 +4257,10 @@ function restore_directory_from_friend { echo " if [ ! -d ${1} ]; then" >> /usr/bin/$RESTORE_FROM_FRIEND_SCRIPT_NAME echo " mkdir ${1}" >> /usr/bin/$RESTORE_FROM_FRIEND_SCRIPT_NAME echo ' fi' >> /usr/bin/$RESTORE_FROM_FRIEND_SCRIPT_NAME - if [[ $BACKUP_TYPE == 'rsync' ]]; then + if [[ $BACKUP_TYPE == 'obnam' ]]; then + echo -n ' obnam restore -r $SERVER_DIRECTORY/backup/' >> /usr/bin/$RESTORE_FROM_FRIEND_SCRIPT_NAME + echo "${2} --to ${1}" >> /usr/bin/$RESTORE_FROM_FRIEND_SCRIPT_NAME + else echo -n ' rsyncrypto -v -d -r $SERVER_DIRECTORY/backup/' >> /usr/bin/$RESTORE_FROM_FRIEND_SCRIPT_NAME echo -n "${2} ${1} " >> /usr/bin/$RESTORE_FROM_FRIEND_SCRIPT_NAME echo -n '$SERVER_DIRECTORY/backup/' >> /usr/bin/$RESTORE_FROM_FRIEND_SCRIPT_NAME @@ -4263,7 +4273,7 @@ function restore_from_friend { return fi - apt-get -y install rsyncrypto sshpass + apt-get -y install rsyncrypto sshpass obnam get_mariadb_password get_mariadb_gnusocial_admin_password @@ -4633,8 +4643,6 @@ function restore_from_friend { echo ' exit 981' >> /usr/bin/$RESTORE_FROM_FRIEND_SCRIPT_NAME echo ' fi' >> /usr/bin/$RESTORE_FROM_FRIEND_SCRIPT_NAME restore_directory_from_friend /root/tempowncloud2 owncloud2 - echo -n ' rsyncrypto -v -d -r $SERVER_DIRECTORY/backup/owncloud2 /root/tempowncloud2 $SERVER_DIRECTORY/backup/owncloud2.keys ' >> /usr/bin/$RESTORE_FROM_FRIEND_SCRIPT_NAME - echo "$BACKUP_CERTIFICATE" >> /usr/bin/$RESTORE_FROM_FRIEND_SCRIPT_NAME echo " cp -r /root/tempowncloud2/remoterestore/backup/owncloud2/owncloud/* /etc/owncloud/" >> /usr/bin/$RESTORE_FROM_FRIEND_SCRIPT_NAME echo ' if [ ! "$?" = "0" ]; then' >> /usr/bin/$RESTORE_FROM_FRIEND_SCRIPT_NAME echo ' exit 982' >> /usr/bin/$RESTORE_FROM_FRIEND_SCRIPT_NAME