Add backup using obnam

This commit is contained in:
Bob Mottram 2015-09-13 17:45:43 +01:00
parent eef99b0904
commit 63b1a9eda6
1 changed files with 18 additions and 10 deletions

View File

@ -2416,7 +2416,9 @@ function get_mariadb_owncloud_admin_password {
} }
function backup_directory_to_usb { 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 # 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 fi
@ -2440,7 +2442,7 @@ function create_backup_script {
if grep -Fxq "create_backup_script" $COMPLETION_FILE; then if grep -Fxq "create_backup_script" $COMPLETION_FILE; then
return return
fi fi
apt-get -y install rsyncrypto cryptsetup libgfshare-bin apt-get -y install rsyncrypto cryptsetup libgfshare-bin obnam
get_mariadb_password get_mariadb_password
get_mariadb_gnusocial_admin_password get_mariadb_gnusocial_admin_password
@ -2909,7 +2911,9 @@ function restore_directory_from_usb {
echo " mkdir ${1}" >> /usr/bin/$RESTORE_SCRIPT_NAME echo " mkdir ${1}" >> /usr/bin/$RESTORE_SCRIPT_NAME
echo ' fi' >> /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 echo " rsyncrypto -v -d -r $USB_MOUNT/backup/${2} ${1} $USB_MOUNT/backup/${2}.keys $BACKUP_CERTIFICATE" >> /usr/bin/$RESTORE_SCRIPT_NAME
fi fi
} }
@ -2918,7 +2922,7 @@ function create_restore_script {
if grep -Fxq "create_restore_script" $COMPLETION_FILE; then if grep -Fxq "create_restore_script" $COMPLETION_FILE; then
return return
fi fi
apt-get -y install rsyncrypto cryptsetup apt-get -y install rsyncrypto cryptsetup obnam
get_mariadb_password get_mariadb_password
get_mariadb_gnusocial_admin_password get_mariadb_gnusocial_admin_password
@ -3671,7 +3675,10 @@ function create_freedns_updater {
} }
function backup_directory_to_friend { 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 # 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 "rsyncrypto -v -r ${1} " >> /usr/bin/$BACKUP_TO_FRIENDS_SCRIPT_NAME
echo -n '$SERVER_DIRECTORY/backup/' >> /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 return
fi fi
apt-get -y install rsyncrypto sshpass apt-get -y install rsyncrypto sshpass obnam
get_mariadb_password get_mariadb_password
get_mariadb_gnusocial_admin_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 " if [ ! -d ${1} ]; then" >> /usr/bin/$RESTORE_FROM_FRIEND_SCRIPT_NAME
echo " mkdir ${1}" >> /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 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 ' 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 "${2} ${1} " >> /usr/bin/$RESTORE_FROM_FRIEND_SCRIPT_NAME
echo -n '$SERVER_DIRECTORY/backup/' >> /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 return
fi fi
apt-get -y install rsyncrypto sshpass apt-get -y install rsyncrypto sshpass obnam
get_mariadb_password get_mariadb_password
get_mariadb_gnusocial_admin_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 ' exit 981' >> /usr/bin/$RESTORE_FROM_FRIEND_SCRIPT_NAME
echo ' fi' >> /usr/bin/$RESTORE_FROM_FRIEND_SCRIPT_NAME echo ' fi' >> /usr/bin/$RESTORE_FROM_FRIEND_SCRIPT_NAME
restore_directory_from_friend /root/tempowncloud2 owncloud2 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 " 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 ' if [ ! "$?" = "0" ]; then' >> /usr/bin/$RESTORE_FROM_FRIEND_SCRIPT_NAME
echo ' exit 982' >> /usr/bin/$RESTORE_FROM_FRIEND_SCRIPT_NAME echo ' exit 982' >> /usr/bin/$RESTORE_FROM_FRIEND_SCRIPT_NAME