From 1eae7132c377a3ce1bbaf8b0eae06051a13dc252 Mon Sep 17 00:00:00 2001 From: Bob Mottram Date: Thu, 24 Sep 2015 21:34:48 +0100 Subject: [PATCH] Improving the local restore script --- src/freedombone | 165 ++++++++++++++++++++++++++---------------------- 1 file changed, 90 insertions(+), 75 deletions(-) diff --git a/src/freedombone b/src/freedombone index 78b168f5..1527a973 100755 --- a/src/freedombone +++ b/src/freedombone @@ -2891,68 +2891,78 @@ function create_backup_script { } function restore_directory_from_usb { - echo " if [ ! -d ${1} ]; then" >> /usr/bin/$RESTORE_SCRIPT_NAME - echo " mkdir ${1}" >> /usr/bin/$RESTORE_SCRIPT_NAME + echo 'function restore_directory_from_usb {' >> /usr/bin/$RESTORE_SCRIPT_NAME + echo " USB_MOUNT=$USB_MOUNT" >> /usr/bin/$RESTORE_SCRIPT_NAME + echo " BACKUP_CERTIFICATE=$BACKUP_CERTIFICATE" >> /usr/bin/$RESTORE_SCRIPT_NAME + echo ' if [ ! -d ${1} ]; then' >> /usr/bin/$RESTORE_SCRIPT_NAME + echo ' mkdir ${1}' >> /usr/bin/$RESTORE_SCRIPT_NAME echo ' fi' >> /usr/bin/$RESTORE_SCRIPT_NAME if [[ $BACKUP_TYPE == 'obnam' ]]; then - echo " obnam restore -r $USB_MOUNT/backup/${2} --to ${1}" >> /usr/bin/$RESTORE_SCRIPT_NAME + 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 + echo '}' >> /usr/bin/$RESTORE_SCRIPT_NAME } function restore_database { - RESTORE_SUBDIR='root' - if [[ $BACKUP_TYPE != 'obnam' ]]; then - RESTORE_SUBDIR="usb/backup/${1}data" + echo 'function restore_database {' >> /usr/bin/$RESTORE_SCRIPT_NAME + echo " USB_MOUNT=$USB_MOUNT" >> /usr/bin/$RESTORE_SCRIPT_NAME + echo " DATABASE_PASSWORD=\"$DATABASE_PASSWORD\"" >> /usr/bin/$RESTORE_SCRIPT_NAME + if [[ $BACKUP_TYPE == 'obnam' ]]; then + echo ' RESTORE_SUBDIR="root"' >> /usr/bin/$RESTORE_SCRIPT_NAME + else + echo ' RESTORE_SUBDIR="usb/backup/${1}data"' >> /usr/bin/$RESTORE_SCRIPT_NAME fi echo '' >> /usr/bin/$RESTORE_SCRIPT_NAME - echo "if [ -d $USB_MOUNT/backup/${1} ]; then" >> /usr/bin/$RESTORE_SCRIPT_NAME - echo " echo \"Restoring ${1} database\"" >> /usr/bin/$RESTORE_SCRIPT_NAME - restore_directory_from_usb "/root/temp${1}data" "${1}data" - echo " if [ ! -f /root/temp${1}data/${RESTORE_SUBDIR}/temp${1}data/${1}.sql ]; then" >> /usr/bin/$RESTORE_SCRIPT_NAME - echo " echo \"Unable to restore ${1} database\"" >> /usr/bin/$RESTORE_SCRIPT_NAME + echo ' if [ -d $USB_MOUNT/backup/${1} ]; then' >> /usr/bin/$RESTORE_SCRIPT_NAME + echo ' echo "Restoring ${1} database"' >> /usr/bin/$RESTORE_SCRIPT_NAME + echo ' restore_directory_from_usb "/root/temp${1}data" "${1}data"' >> /usr/bin/$RESTORE_SCRIPT_NAME + echo ' if [ ! -f /root/temp${1}data/${RESTORE_SUBDIR}/temp${1}data/${1}.sql ]; then' >> /usr/bin/$RESTORE_SCRIPT_NAME + echo ' echo "Unable to restore ${1} database"' >> /usr/bin/$RESTORE_SCRIPT_NAME + echo ' rm -rf /root/temp${1}data' >> /usr/bin/$RESTORE_SCRIPT_NAME + echo ' umount $USB_MOUNT' >> /usr/bin/$RESTORE_SCRIPT_NAME + echo ' rm -rf $USB_MOUNT' >> /usr/bin/$RESTORE_SCRIPT_NAME + echo ' exit 503' >> /usr/bin/$RESTORE_SCRIPT_NAME + echo ' fi' >> /usr/bin/$RESTORE_SCRIPT_NAME + echo -n ' mysqlsuccess=$(mysql -u root --password=$DATABASE_PASSWORD ' >> /usr/bin/$RESTORE_SCRIPT_NAME + echo '${1} -o < /root/temp${1}data/${RESTORE_SUBDIR}/temp${1}data/${1}.sql)' >> /usr/bin/$RESTORE_SCRIPT_NAME + echo ' if [ ! "$?" = "0" ]; then' >> /usr/bin/$RESTORE_SCRIPT_NAME + echo ' echo "$mysqlsuccess"' >> /usr/bin/$RESTORE_SCRIPT_NAME + echo ' umount $USB_MOUNT' >> /usr/bin/$RESTORE_SCRIPT_NAME + echo ' rm -rf $USB_MOUNT' >> /usr/bin/$RESTORE_SCRIPT_NAME + echo ' exit 964' >> /usr/bin/$RESTORE_SCRIPT_NAME + echo ' fi' >> /usr/bin/$RESTORE_SCRIPT_NAME + echo ' shred -zu /root/temp${1}data/${RESTORE_SUBDIR}/temp${1}data/*' >> /usr/bin/$RESTORE_SCRIPT_NAME echo ' rm -rf /root/temp${1}data' >> /usr/bin/$RESTORE_SCRIPT_NAME - echo " umount $USB_MOUNT" >> /usr/bin/$RESTORE_SCRIPT_NAME - echo " rm -rf $USB_MOUNT" >> /usr/bin/$RESTORE_SCRIPT_NAME - echo ' exit 503' >> /usr/bin/$RESTORE_SCRIPT_NAME - echo ' fi' >> /usr/bin/$RESTORE_SCRIPT_NAME - echo -n ' mysqlsuccess=$(mysql -u root --password=$DATABASE_PASSWORD ' >> /usr/bin/$RESTORE_SCRIPT_NAME - echo "${1} -o < /root/temp${1}data/${RESTORE_SUBDIR}/temp${1}data/${1}.sql)" >> /usr/bin/$RESTORE_SCRIPT_NAME - echo ' if [ ! "$?" = "0" ]; then' >> /usr/bin/$RESTORE_SCRIPT_NAME - echo ' echo "$mysqlsuccess"' >> /usr/bin/$RESTORE_SCRIPT_NAME - echo " umount $USB_MOUNT" >> /usr/bin/$RESTORE_SCRIPT_NAME - echo " rm -rf $USB_MOUNT" >> /usr/bin/$RESTORE_SCRIPT_NAME - echo ' exit 964' >> /usr/bin/$RESTORE_SCRIPT_NAME - echo ' fi' >> /usr/bin/$RESTORE_SCRIPT_NAME - echo " shred -zu /root/temp${1}data/${RESTORE_SUBDIR}/temp${1}data/*" >> /usr/bin/$RESTORE_SCRIPT_NAME - echo " rm -rf /root/temp${1}data" >> /usr/bin/$RESTORE_SCRIPT_NAME - echo " echo \"Restoring ${1} installation\"" >> /usr/bin/$RESTORE_SCRIPT_NAME - echo " if [ ! -d /root/temp${1} ]; then" >> /usr/bin/$RESTORE_SCRIPT_NAME - echo " mkdir /root/temp${1}" >> /usr/bin/$RESTORE_SCRIPT_NAME - echo ' fi' >> /usr/bin/$RESTORE_SCRIPT_NAME - restore_directory_from_usb "/root/temp${1}" "${1}" - RESTORE_SUBDIR='var' - if [[ $BACKUP_TYPE != 'obnam' ]]; then - RESTORE_SUBDIR="usb/backup/${1}" + echo ' echo "Restoring ${1} installation"' >> /usr/bin/$RESTORE_SCRIPT_NAME + echo ' if [ ! -d /root/temp${1} ]; then' >> /usr/bin/$RESTORE_SCRIPT_NAME + echo ' mkdir /root/temp${1}' >> /usr/bin/$RESTORE_SCRIPT_NAME + echo ' fi' >> /usr/bin/$RESTORE_SCRIPT_NAME + echo ' restore_directory_from_usb "/root/temp${1}" "${1}"' >> /usr/bin/$RESTORE_SCRIPT_NAME + if [[ $BACKUP_TYPE == 'obnam' ]]; then + echo ' RESTORE_SUBDIR="var"' >> /usr/bin/$RESTORE_SCRIPT_NAME + else + echo ' RESTORE_SUBDIR="usb/backup/${1}"' >> /usr/bin/$RESTORE_SCRIPT_NAME fi - echo " if [ ${2} ]; then" >> /usr/bin/$RESTORE_SCRIPT_NAME - echo " if [ -d /var/www/${2}/htdocs ]; then" >> /usr/bin/$RESTORE_SCRIPT_NAME - echo " rm -rf /var/www/${2}/htdocs" >> /usr/bin/$RESTORE_SCRIPT_NAME - echo " mv /root/temp${1}/${RESTORE_SUBDIR}/www/${2}/htdocs /var/www/${2}/" >> /usr/bin/$RESTORE_SCRIPT_NAME - echo ' if [ ! "$?" = "0" ]; then' >> /usr/bin/$RESTORE_SCRIPT_NAME - echo " umount $USB_MOUNT" >> /usr/bin/$RESTORE_SCRIPT_NAME - echo " rm -rf $USB_MOUNT" >> /usr/bin/$RESTORE_SCRIPT_NAME - echo ' exit 683' >> /usr/bin/$RESTORE_SCRIPT_NAME - echo ' fi' >> /usr/bin/$RESTORE_SCRIPT_NAME - echo ' # Ensure that the bundled SSL cert is being used' >> /usr/bin/$RESTORE_SCRIPT_NAME - echo " if [ -f /etc/ssl/certs/${2}.bundle.crt ]; then" >> /usr/bin/$RESTORE_SCRIPT_NAME - echo " sed -i 's|${2}.crt|${2}.bundle.crt|g' /etc/nginx/sites-available/${2}" >> /usr/bin/$RESTORE_SCRIPT_NAME + echo ' if [ ${2} ]; then' >> /usr/bin/$RESTORE_SCRIPT_NAME + echo ' if [ -d /var/www/${2}/htdocs ]; then' >> /usr/bin/$RESTORE_SCRIPT_NAME + echo ' rm -rf /var/www/${2}/htdocs' >> /usr/bin/$RESTORE_SCRIPT_NAME + echo ' mv /root/temp${1}/${RESTORE_SUBDIR}/www/${2}/htdocs /var/www/${2}/' >> /usr/bin/$RESTORE_SCRIPT_NAME + echo ' if [ ! "$?" = "0" ]; then' >> /usr/bin/$RESTORE_SCRIPT_NAME + echo ' umount $USB_MOUNT' >> /usr/bin/$RESTORE_SCRIPT_NAME + echo ' rm -rf $USB_MOUNT' >> /usr/bin/$RESTORE_SCRIPT_NAME + echo ' exit 683' >> /usr/bin/$RESTORE_SCRIPT_NAME + echo ' fi' >> /usr/bin/$RESTORE_SCRIPT_NAME + echo ' # Ensure that the bundled SSL cert is being used' >> /usr/bin/$RESTORE_SCRIPT_NAME + echo ' if [ -f /etc/ssl/certs/${2}.bundle.crt ]; then' >> /usr/bin/$RESTORE_SCRIPT_NAME + echo ' sed -i "s|${2}.crt|${2}.bundle.crt|g" /etc/nginx/sites-available/${2}' >> /usr/bin/$RESTORE_SCRIPT_NAME + echo ' fi' >> /usr/bin/$RESTORE_SCRIPT_NAME echo ' fi' >> /usr/bin/$RESTORE_SCRIPT_NAME echo ' fi' >> /usr/bin/$RESTORE_SCRIPT_NAME echo ' fi' >> /usr/bin/$RESTORE_SCRIPT_NAME - echo 'fi' >> /usr/bin/$RESTORE_SCRIPT_NAME + echo '}' >> /usr/bin/$RESTORE_SCRIPT_NAME } function create_restore_script { @@ -3019,6 +3029,11 @@ function create_restore_script { echo 'cp -r /home/$MY_USERNAME/.gnupg /root' >> /usr/bin/$RESTORE_SCRIPT_NAME echo '' >> /usr/bin/$RESTORE_SCRIPT_NAME + restore_directory_from_usb + echo '' >> /usr/bin/$RESTORE_SCRIPT_NAME + restore_database + echo '' >> /usr/bin/$RESTORE_SCRIPT_NAME + if [[ $BACKUP_TYPE != 'obnam' ]]; then echo "if [ -f $USB_MOUNT/backup/key.gpg ]; then" >> /usr/bin/$RESTORE_SCRIPT_NAME echo " if [ -f $BACKUP_CERTIFICATE.new ]; then" >> /usr/bin/$RESTORE_SCRIPT_NAME @@ -3070,7 +3085,7 @@ function create_restore_script { fi echo "if [ -d $USB_MOUNT/backup/mariadb ]; then" >> /usr/bin/$RESTORE_SCRIPT_NAME echo ' echo "Restoring mysql settings"' >> /usr/bin/$RESTORE_SCRIPT_NAME - restore_directory_from_usb '/root/tempmariadb' 'mariadb' + echo ' restore_directory_from_usb /root/tempmariadb mariadb' >> /usr/bin/$RESTORE_SCRIPT_NAME echo ' echo "Get the MariaDB password from the backup"' >> /usr/bin/$RESTORE_SCRIPT_NAME echo " if [ ! -f /root/tempmariadb/${RESTORE_SUBDIR}tempmariadb/db ]; then" >> /usr/bin/$RESTORE_SCRIPT_NAME echo ' echo "MariaDB password file not found"' >> /usr/bin/$RESTORE_SCRIPT_NAME @@ -3115,7 +3130,7 @@ function create_restore_script { fi echo "if [ -d $USB_MOUNT/backup/mutt ]; then" >> /usr/bin/$RESTORE_SCRIPT_NAME echo ' echo "Restoring Mutt settings"' >> /usr/bin/$RESTORE_SCRIPT_NAME - restore_directory_from_usb '/root/tempmutt' 'mutt' + echo ' restore_directory_from_usb /root/tempmutt mutt' >> /usr/bin/$RESTORE_SCRIPT_NAME echo -n " if [ -f /root/tempmutt/${RESTORE_SUBDIR}" >> /usr/bin/$RESTORE_SCRIPT_NAME echo '$MY_USERNAME/tempbackup/.muttrc ]; then' >> /usr/bin/$RESTORE_SCRIPT_NAME echo -n " cp -f /root/tempmutt/${RESTORE_SUBDIR}" >> /usr/bin/$RESTORE_SCRIPT_NAME @@ -3142,7 +3157,7 @@ function create_restore_script { fi echo "if [ -d $USB_MOUNT/backup/gnupg ]; then" >> /usr/bin/$RESTORE_SCRIPT_NAME echo ' echo "Restoring gnupg settings"' >> /usr/bin/$RESTORE_SCRIPT_NAME - restore_directory_from_usb '/root/tempgnupg' 'gnupg' + echo ' restore_directory_from_usb /root/tempgnupg gnupg' >> /usr/bin/$RESTORE_SCRIPT_NAME echo -n " cp -r /root/tempgnupg/${RESTORE_SUBDIR}" >> /usr/bin/$RESTORE_SCRIPT_NAME echo '$MY_USERNAME/.gnupg /home/$MY_USERNAME/' >> /usr/bin/$RESTORE_SCRIPT_NAME echo ' if [ ! "$?" = "0" ]; then' >> /usr/bin/$RESTORE_SCRIPT_NAME @@ -3167,7 +3182,7 @@ function create_restore_script { fi echo "if [ -d $USB_MOUNT/backup/procmail ]; then" >> /usr/bin/$RESTORE_SCRIPT_NAME echo ' echo "Restoring procmail settings"' >> /usr/bin/$RESTORE_SCRIPT_NAME - restore_directory_from_usb '/root/tempprocmail' 'procmail' + echo ' restore_directory_from_usb /root/tempprocmail procmail' >> /usr/bin/$RESTORE_SCRIPT_NAME echo -n " cp -f /root/tempprocmail/${RESTORE_SUBDIR}" >> /usr/bin/$RESTORE_SCRIPT_NAME echo '$MY_USERNAME/tempbackup/.procmailrc /home/$MY_USERNAME/' >> /usr/bin/$RESTORE_SCRIPT_NAME echo ' if [ ! "$?" = "0" ]; then' >> /usr/bin/$RESTORE_SCRIPT_NAME @@ -3186,7 +3201,7 @@ function create_restore_script { fi echo "if [ -d $USB_MOUNT/backup/spamassassin ]; then" >> /usr/bin/$RESTORE_SCRIPT_NAME echo ' echo "Restoring spamassassin settings"' >> /usr/bin/$RESTORE_SCRIPT_NAME - restore_directory_from_usb '/root/tempspamassassin' 'spamassassin' + echo 'restore_directory_from_usb /root/tempspamassassin spamassassin' >> /usr/bin/$RESTORE_SCRIPT_NAME echo -n " cp -rf /root/tempspamassassin/${RESTORE_SUBDIR}" >> /usr/bin/$RESTORE_SCRIPT_NAME echo '$MY_USERNAME/.spamassassin /home/$MY_USERNAME/' >> /usr/bin/$RESTORE_SCRIPT_NAME echo ' if [ ! "$?" = "0" ]; then' >> /usr/bin/$RESTORE_SCRIPT_NAME @@ -3205,7 +3220,7 @@ function create_restore_script { fi echo "if [ -d $USB_MOUNT/backup/readme ]; then" >> /usr/bin/$RESTORE_SCRIPT_NAME echo ' echo "Restoring README"' >> /usr/bin/$RESTORE_SCRIPT_NAME - restore_directory_from_usb '/root/tempreadme' 'readme' + echo ' restore_directory_from_usb /root/tempreadme readme' >> /usr/bin/$RESTORE_SCRIPT_NAME echo -n " cp -f /root/tempreadme/${RESTORE_SUBDIR}" >> /usr/bin/$RESTORE_SCRIPT_NAME echo '$MY_USERNAME/tempbackup/README /home/$MY_USERNAME/' >> /usr/bin/$RESTORE_SCRIPT_NAME echo ' if [ ! "$?" = "0" ]; then' >> /usr/bin/$RESTORE_SCRIPT_NAME @@ -3224,7 +3239,7 @@ function create_restore_script { fi echo "if [ -d $USB_MOUNT/backup/ipfs ]; then" >> /usr/bin/$RESTORE_SCRIPT_NAME echo ' echo "Restoring IPFS"' >> /usr/bin/$RESTORE_SCRIPT_NAME - restore_directory_from_usb '/root/tempipfs' 'ipfs' + echo ' restore_directory_from_usb /root/tempipfs ipfs' >> /usr/bin/$RESTORE_SCRIPT_NAME echo -n " cp -f /root/tempipfs/${RESTORE_SUBDIR}" >> /usr/bin/$RESTORE_SCRIPT_NAME echo '$MY_USERNAME/tempbackup/ipfs/* /home/$MY_USERNAME/.ipfs' >> /usr/bin/$RESTORE_SCRIPT_NAME echo ' if [ ! "$?" = "0" ]; then' >> /usr/bin/$RESTORE_SCRIPT_NAME @@ -3243,7 +3258,7 @@ function create_restore_script { fi echo "if [ -d $USB_MOUNT/backup/ssh ]; then" >> /usr/bin/$RESTORE_SCRIPT_NAME echo ' echo "Restoring ssh keys"' >> /usr/bin/$RESTORE_SCRIPT_NAME - restore_directory_from_usb '/root/tempssh' 'ssh' + echo ' restore_directory_from_usb /root/tempssh ssh' >> /usr/bin/$RESTORE_SCRIPT_NAME echo -n " cp -r /root/tempssh/${RESTORE_SUBDIR}" >> /usr/bin/$RESTORE_SCRIPT_NAME echo '$MY_USERNAME/.ssh /home/$MY_USERNAME/' >> /usr/bin/$RESTORE_SCRIPT_NAME echo ' if [ ! "$?" = "0" ]; then' >> /usr/bin/$RESTORE_SCRIPT_NAME @@ -3263,7 +3278,7 @@ function create_restore_script { echo "if [ -d $USB_MOUNT/backup/ssl ]; then" >> /usr/bin/$RESTORE_SCRIPT_NAME echo ' echo "Restoring certificates"' >> /usr/bin/$RESTORE_SCRIPT_NAME echo ' mkdir /root/tempssl' >> /usr/bin/$RESTORE_SCRIPT_NAME - restore_directory_from_usb '/root/tempssl' 'ssl' + echo ' restore_directory_from_usb /root/tempssl ssl' >> /usr/bin/$RESTORE_SCRIPT_NAME echo " cp -r /root/tempssl/${RESTORE_SUBDIR}ssl/* /etc/ssl" >> /usr/bin/$RESTORE_SCRIPT_NAME echo ' if [ ! "$?" = "0" ]; then' >> /usr/bin/$RESTORE_SCRIPT_NAME echo " umount $USB_MOUNT" >> /usr/bin/$RESTORE_SCRIPT_NAME @@ -3280,7 +3295,7 @@ function create_restore_script { fi echo "if [ -d $USB_MOUNT/backup/projects ]; then" >> /usr/bin/$RESTORE_SCRIPT_NAME echo ' echo "Restoring projects"' >> /usr/bin/$RESTORE_SCRIPT_NAME - restore_directory_from_usb '/root/tempprojects' 'projects' + echo ' restore_directory_from_usb /root/tempprojects projects' >> /usr/bin/$RESTORE_SCRIPT_NAME echo ' if [ -d /home/$MY_USERNAME/projects ]; then' >> /usr/bin/$RESTORE_SCRIPT_NAME echo ' rm -rf /home/$MY_USERNAME/projects' >> /usr/bin/$RESTORE_SCRIPT_NAME echo ' fi' >> /usr/bin/$RESTORE_SCRIPT_NAME @@ -3301,7 +3316,7 @@ function create_restore_script { fi echo "if [ -d $USB_MOUNT/backup/personal ]; then" >> /usr/bin/$RESTORE_SCRIPT_NAME echo ' echo "Restoring personal settings"' >> /usr/bin/$RESTORE_SCRIPT_NAME - restore_directory_from_usb '/root/temppersonal' 'personal' + echo ' restore_directory_from_usb /root/temppersonal personal' >> /usr/bin/$RESTORE_SCRIPT_NAME echo ' if [ -d /home/$MY_USERNAME/personal ]; then' >> /usr/bin/$RESTORE_SCRIPT_NAME echo ' rm -rf /home/$MY_USERNAME/personal' >> /usr/bin/$RESTORE_SCRIPT_NAME echo ' fi' >> /usr/bin/$RESTORE_SCRIPT_NAME @@ -3322,7 +3337,7 @@ function create_restore_script { fi echo "if [ -d $PUBLIC_MAILING_LIST_DIRECTORY ]; then" >> /usr/bin/$RESTORE_SCRIPT_NAME echo ' echo "Restoring public mailing list"' >> /usr/bin/$RESTORE_SCRIPT_NAME - restore_directory_from_usb '/root/tempmailinglist' 'mailinglist' + echo ' restore_directory_from_usb /root/tempmailinglist mailinglist' >> /usr/bin/$RESTORE_SCRIPT_NAME echo " cp -r /root/tempmailinglist/${RESTORE_SUBDIR}spool/mlmmj/* $PUBLIC_MAILING_LIST_DIRECTORY" >> /usr/bin/$RESTORE_SCRIPT_NAME echo ' if [ ! "$?" = "0" ]; then' >> /usr/bin/$RESTORE_SCRIPT_NAME echo " umount $USB_MOUNT" >> /usr/bin/$RESTORE_SCRIPT_NAME @@ -3339,7 +3354,7 @@ function create_restore_script { fi echo "if [ -d $XMPP_DIRECTORY ]; then" >> /usr/bin/$RESTORE_SCRIPT_NAME echo ' echo "Restoring XMPP settings"' >> /usr/bin/$RESTORE_SCRIPT_NAME - restore_directory_from_usb '/root/tempxmpp' 'xmpp' + echo ' restore_directory_from_usb /root/tempxmpp xmpp' >> /usr/bin/$RESTORE_SCRIPT_NAME echo " cp -r /root/tempxmpp/${RESTORE_SUBDIR}lib/prosody/* $XMPP_DIRECTORY" >> /usr/bin/$RESTORE_SCRIPT_NAME echo ' if [ ! "$?" = "0" ]; then' >> /usr/bin/$RESTORE_SCRIPT_NAME echo " umount $USB_MOUNT" >> /usr/bin/$RESTORE_SCRIPT_NAME @@ -3356,7 +3371,7 @@ function create_restore_script { if grep -Fxq "install_gnu_social" $COMPLETION_FILE; then BACKUP_INCLUDES_WEBSITES="yes" - restore_database gnusocial $MICROBLOG_DOMAIN_NAME + echo "restore_database gnusocial $MICROBLOG_DOMAIN_NAME" >> /usr/bin/$RESTORE_SCRIPT_NAME echo 'if [ -d /root/tempgnusocial ]; then' >> /usr/bin/$RESTORE_SCRIPT_NAME echo ' rm -rf /root/tempgnusocial' >> /usr/bin/$RESTORE_SCRIPT_NAME echo 'fi' >> /usr/bin/$RESTORE_SCRIPT_NAME @@ -3364,7 +3379,7 @@ function create_restore_script { if grep -Fxq "install_hubzilla" $COMPLETION_FILE; then BACKUP_INCLUDES_WEBSITES="yes" - restore_database hubzilla $HUBZILLA_DOMAIN_NAME + echo "restore_database hubzilla $HUBZILLA_DOMAIN_NAME" >> /usr/bin/$RESTORE_SCRIPT_NAME echo "if [ -d $USB_MOUNT/backup/hubzilla ]; then" >> /usr/bin/$RESTORE_SCRIPT_NAME echo " if [ ! -d /var/www/$HUBZILLA_DOMAIN_NAME/htdocs/store/[data]/smarty3 ]; then" >> /usr/bin/$RESTORE_SCRIPT_NAME echo " mkdir -p /var/www/$HUBZILLA_DOMAIN_NAME/htdocs/store/[data]/smarty3" >> /usr/bin/$RESTORE_SCRIPT_NAME @@ -3380,9 +3395,9 @@ function create_restore_script { if grep -Fxq "install_owncloud" $COMPLETION_FILE; then BACKUP_INCLUDES_WEBSITES="yes" - restore_database owncloud $OWNCLOUD_DOMAIN_NAME + echo "restore_database owncloud $OWNCLOUD_DOMAIN_NAME" >> /usr/bin/$RESTORE_SCRIPT_NAME echo "if [ -d $USB_MOUNT/backup/owncloud2 ]; then" >> /usr/bin/$RESTORE_SCRIPT_NAME - restore_directory_from_usb '/root/tempowncloud2' 'owncloud2' + echo 'restore_directory_from_usb /root/tempowncloud2 owncloud2' >> /usr/bin/$RESTORE_SCRIPT_NAME RESTORE_SUBDIR='etc/' if [[ $BACKUP_TYPE != 'obnam' ]]; then RESTORE_SUBDIR='usb/backup/owncloud2/' @@ -3406,7 +3421,7 @@ function create_restore_script { if grep -Fxq "install_gogs" $COMPLETION_FILE; then BACKUP_INCLUDES_WEBSITES="yes" - restore_database gogs $GIT_DOMAIN_NAME + echo "restore_database gogs $GIT_DOMAIN_NAME" >> /usr/bin/$RESTORE_SCRIPT_NAME RESTORE_SUBDIR='home' if [[ $BACKUP_TYPE != 'obnam' ]]; then RESTORE_SUBDIR='usb/backup/gogs' @@ -3423,7 +3438,7 @@ function create_restore_script { echo ' exit 981' >> /usr/bin/$RESTORE_SCRIPT_NAME echo ' fi' >> /usr/bin/$RESTORE_SCRIPT_NAME echo ' echo "Restoring Gogs repos"' >> /usr/bin/$RESTORE_SCRIPT_NAME - restore_directory_from_usb '/root/tempgogsrepos' 'gogsrepos' + echo 'restore_directory_from_usb /root/tempgogsrepos gogsrepos' >> /usr/bin/$RESTORE_SCRIPT_NAME if [[ $BACKUP_TYPE != 'obnam' ]]; then RESTORE_SUBDIR='usb/backup/gogsrepos' fi @@ -3434,7 +3449,7 @@ function create_restore_script { echo ' exit 67574' >> /usr/bin/$RESTORE_SCRIPT_NAME echo ' fi' >> /usr/bin/$RESTORE_SCRIPT_NAME echo ' echo "Restoring Gogs authorized_keys"' >> /usr/bin/$RESTORE_SCRIPT_NAME - restore_directory_from_usb '/root/tempgogsssh' 'gogsssh' + echo ' restore_directory_from_usb /root/tempgogsssh gogsssh' >> /usr/bin/$RESTORE_SCRIPT_NAME echo ' if [ ! -d /home/git/.ssh ]; then' >> /usr/bin/$RESTORE_SCRIPT_NAME echo ' mkdir /home/git/.ssh' >> /usr/bin/$RESTORE_SCRIPT_NAME echo ' fi' >> /usr/bin/$RESTORE_SCRIPT_NAME @@ -3461,14 +3476,14 @@ function create_restore_script { fi echo "if [ -d $USB_MOUNT/backup/wiki ]; then" >> /usr/bin/$RESTORE_SCRIPT_NAME echo ' echo "Restoring Wiki installation"' >> /usr/bin/$RESTORE_SCRIPT_NAME - restore_directory_from_usb '/root/tempwiki' 'wiki' + echo ' restore_directory_from_usb /root/tempwiki wiki' >> /usr/bin/$RESTORE_SCRIPT_NAME echo " cp -r /root/tempwiki/${RESTORE_SUBDIR}/lib/dokuwiki/* /var/lib/dokuwiki/" >> /usr/bin/$RESTORE_SCRIPT_NAME echo ' if [ ! "$?" = "0" ]; then' >> /usr/bin/$RESTORE_SCRIPT_NAME echo " umount $USB_MOUNT" >> /usr/bin/$RESTORE_SCRIPT_NAME echo " rm -rf $USB_MOUNT" >> /usr/bin/$RESTORE_SCRIPT_NAME echo ' exit 868' >> /usr/bin/$RESTORE_SCRIPT_NAME echo ' fi' >> /usr/bin/$RESTORE_SCRIPT_NAME - restore_directory_from_usb '/root/tempwiki2' 'wiki2' + echo ' restore_directory_from_usb /root/tempwiki2 wiki2' >> /usr/bin/$RESTORE_SCRIPT_NAME RESTORE_SUBDIR='etc' if [[ $BACKUP_TYPE != 'obnam' ]]; then RESTORE_SUBDIR='usb/backup/wiki2' @@ -3495,7 +3510,7 @@ function create_restore_script { fi echo "if [ -d $USB_MOUNT/backup/blog ]; then" >> /usr/bin/$RESTORE_SCRIPT_NAME echo ' echo "Restoring blog installation"' >> /usr/bin/$RESTORE_SCRIPT_NAME - restore_directory_from_usb '/root/tempblog' 'blog' + echo ' restore_directory_from_usb /root/tempblog blog' >> /usr/bin/$RESTORE_SCRIPT_NAME echo " rm -rf /var/www/$FULLBLOG_DOMAIN_NAME/htdocs" >> /usr/bin/$RESTORE_SCRIPT_NAME echo " cp -r /root/tempblog/${RESTORE_SUBDIR}/www/$FULLBLOG_DOMAIN_NAME/htdocs /var/www/$FULLBLOG_DOMAIN_NAME/" >> /usr/bin/$RESTORE_SCRIPT_NAME echo ' if [ ! "$?" = "0" ]; then' >> /usr/bin/$RESTORE_SCRIPT_NAME @@ -3524,7 +3539,7 @@ function create_restore_script { fi echo "if [ -d $USB_MOUNT/backup/cjdns ]; then" >> /usr/bin/$RESTORE_SCRIPT_NAME echo ' echo "Restoring cjdns installation"' >> /usr/bin/$RESTORE_SCRIPT_NAME - restore_directory_from_usb '/root/tempcjdns' 'cjdns' + echo ' restore_directory_from_usb /root/tempcjdns cjdns' >> /usr/bin/$RESTORE_SCRIPT_NAME echo " rm -rf /etc/cjdns" >> /usr/bin/$RESTORE_SCRIPT_NAME echo " cp -r /root/tempcjdns/${RESTORE_SUBDIR}/cjdns /etc/" >> /usr/bin/$RESTORE_SCRIPT_NAME echo ' if [ ! "$?" = "0" ]; then' >> /usr/bin/$RESTORE_SCRIPT_NAME @@ -3542,7 +3557,7 @@ function create_restore_script { fi echo "if [ -d $USB_MOUNT/backup/mail ]; then" >> /usr/bin/$RESTORE_SCRIPT_NAME echo ' echo "Restoring emails"' >> /usr/bin/$RESTORE_SCRIPT_NAME - restore_directory_from_usb '/root/tempmail' 'mail' + echo ' restore_directory_from_usb /root/tempmail mail' >> /usr/bin/$RESTORE_SCRIPT_NAME echo ' if [ ! -d /home/$MY_USERNAME/Maildir ]; then' >> /usr/bin/$RESTORE_SCRIPT_NAME echo ' mkdir /home/$MY_USERNAME/Maildir' >> /usr/bin/$RESTORE_SCRIPT_NAME echo ' fi' >> /usr/bin/$RESTORE_SCRIPT_NAME @@ -3563,7 +3578,7 @@ function create_restore_script { echo "if [ -d /var/cache/minidlna ]; then" >> /usr/bin/$RESTORE_SCRIPT_NAME echo " if [ -d $USB_MOUNT/backup/dlna ]; then" >> /usr/bin/$RESTORE_SCRIPT_NAME echo ' echo "Restoring DLNA cache"' >> /usr/bin/$RESTORE_SCRIPT_NAME - restore_directory_from_usb '/root/tempdlna' 'dlna' + echo ' restore_directory_from_usb /root/tempdlna dlna' >> /usr/bin/$RESTORE_SCRIPT_NAME echo " cp -r /root/tempdlna/${RESTORE_SUBDIR}/cache/minidlna/* /var/cache/minidlna/" >> /usr/bin/$RESTORE_SCRIPT_NAME echo ' if [ ! "$?" = "0" ]; then' >> /usr/bin/$RESTORE_SCRIPT_NAME echo " umount $USB_MOUNT" >> /usr/bin/$RESTORE_SCRIPT_NAME @@ -3577,7 +3592,7 @@ function create_restore_script { echo "if [ -d $USB_MOUNT/backup/voip ]; then" >> /usr/bin/$RESTORE_SCRIPT_NAME echo ' echo "Restoring VoIP settings"' >> /usr/bin/$RESTORE_SCRIPT_NAME - restore_directory_from_usb '/root/tempvoip' 'voip' + echo ' restore_directory_from_usb /root/tempvoip voip' >> /usr/bin/$RESTORE_SCRIPT_NAME RESTORE_SUBDIR='home' if [[ $BACKUP_TYPE != 'obnam' ]]; then RESTORE_SUBDIR='usb/backup/voip' @@ -3609,7 +3624,7 @@ function create_restore_script { echo "if [ -d $USB_MOUNT/backup/tox ]; then" >> /usr/bin/$RESTORE_SCRIPT_NAME echo ' echo "Restoring Tox node settings"' >> /usr/bin/$RESTORE_SCRIPT_NAME - restore_directory_from_usb '/var/lib/tox-bootstrapd' 'tox' + echo ' restore_directory_from_usb /var/lib/tox-bootstrapd tox' >> /usr/bin/$RESTORE_SCRIPT_NAME echo ' if [ ! "$?" = "0" ]; then' >> /usr/bin/$RESTORE_SCRIPT_NAME echo " umount $USB_MOUNT" >> /usr/bin/$RESTORE_SCRIPT_NAME echo " rm -rf $USB_MOUNT" >> /usr/bin/$RESTORE_SCRIPT_NAME