Bladeren bron

Different directory structure for rsync and obnam restore

Bob Mottram 10 jaren geleden
bovenliggende
commit
05f7f694ca
1 gewijzigde bestanden met toevoegingen van 299 en 71 verwijderingen
  1. 299
    71
      src/freedombone

+ 299
- 71
src/freedombone Bestand weergeven

2874
 }
2874
 }
2875
 
2875
 
2876
 function restore_database {
2876
 function restore_database {
2877
+  RESTORE_SUBDIR='root'
2878
+  if [[ $BACKUP_TYPE != 'obnam' ]]; then
2879
+      RESTORE_SUBDIR="usb/backup/${1}data"
2880
+  fi
2877
   echo '' >> /usr/bin/$RESTORE_SCRIPT_NAME
2881
   echo '' >> /usr/bin/$RESTORE_SCRIPT_NAME
2878
   echo "if [ -d $USB_MOUNT/backup/${1} ]; then" >> /usr/bin/$RESTORE_SCRIPT_NAME
2882
   echo "if [ -d $USB_MOUNT/backup/${1} ]; then" >> /usr/bin/$RESTORE_SCRIPT_NAME
2879
   echo "  echo \"Restoring ${1} database\"" >> /usr/bin/$RESTORE_SCRIPT_NAME
2883
   echo "  echo \"Restoring ${1} database\"" >> /usr/bin/$RESTORE_SCRIPT_NAME
2880
   restore_directory_from_usb /root/temp${1}data ${1}data
2884
   restore_directory_from_usb /root/temp${1}data ${1}data
2881
-  echo "  if [ ! -f /root/temp${1}data/usb/backup/${1}data/temp${1}data/${1}.sql ]; then" >> /usr/bin/$RESTORE_SCRIPT_NAME
2885
+  echo "  if [ ! -f /root/temp${1}data/${RESTORE_SUBDIR}/temp${1}data/${1}.sql ]; then" >> /usr/bin/$RESTORE_SCRIPT_NAME
2882
   echo "    echo \"Unable to restore ${1} database\"" >> /usr/bin/$RESTORE_SCRIPT_NAME
2886
   echo "    echo \"Unable to restore ${1} database\"" >> /usr/bin/$RESTORE_SCRIPT_NAME
2883
   echo '    rm -rf /root/temp${1}data' >> /usr/bin/$RESTORE_SCRIPT_NAME
2887
   echo '    rm -rf /root/temp${1}data' >> /usr/bin/$RESTORE_SCRIPT_NAME
2884
   echo "    umount $USB_MOUNT" >> /usr/bin/$RESTORE_SCRIPT_NAME
2888
   echo "    umount $USB_MOUNT" >> /usr/bin/$RESTORE_SCRIPT_NAME
2886
   echo '    exit 503' >> /usr/bin/$RESTORE_SCRIPT_NAME
2890
   echo '    exit 503' >> /usr/bin/$RESTORE_SCRIPT_NAME
2887
   echo '  fi' >> /usr/bin/$RESTORE_SCRIPT_NAME
2891
   echo '  fi' >> /usr/bin/$RESTORE_SCRIPT_NAME
2888
   echo '  mysqlsuccess=$(mysql -u root --password=$DATABASE_PASSWORD ' >> /usr/bin/$RESTORE_SCRIPT_NAME
2892
   echo '  mysqlsuccess=$(mysql -u root --password=$DATABASE_PASSWORD ' >> /usr/bin/$RESTORE_SCRIPT_NAME
2889
-  echo "${1} -o < /root/temp${1}data/usb/backup/${1}data/temp${1}data/${1}.sql)" >> /usr/bin/$RESTORE_SCRIPT_NAME
2893
+  echo "${1} -o < /root/temp${1}data/${RESTORE_SUBDIR}/temp${1}data/${1}.sql)" >> /usr/bin/$RESTORE_SCRIPT_NAME
2890
   echo '  if [ ! "$?" = "0" ]; then' >> /usr/bin/$RESTORE_SCRIPT_NAME
2894
   echo '  if [ ! "$?" = "0" ]; then' >> /usr/bin/$RESTORE_SCRIPT_NAME
2891
   echo '    echo "$mysqlsuccess"' >> /usr/bin/$RESTORE_SCRIPT_NAME
2895
   echo '    echo "$mysqlsuccess"' >> /usr/bin/$RESTORE_SCRIPT_NAME
2892
   echo "    umount $USB_MOUNT" >> /usr/bin/$RESTORE_SCRIPT_NAME
2896
   echo "    umount $USB_MOUNT" >> /usr/bin/$RESTORE_SCRIPT_NAME
2893
   echo "    rm -rf $USB_MOUNT" >> /usr/bin/$RESTORE_SCRIPT_NAME
2897
   echo "    rm -rf $USB_MOUNT" >> /usr/bin/$RESTORE_SCRIPT_NAME
2894
   echo '    exit 964' >> /usr/bin/$RESTORE_SCRIPT_NAME
2898
   echo '    exit 964' >> /usr/bin/$RESTORE_SCRIPT_NAME
2895
   echo '  fi' >> /usr/bin/$RESTORE_SCRIPT_NAME
2899
   echo '  fi' >> /usr/bin/$RESTORE_SCRIPT_NAME
2896
-  echo "  shred -zu /root/temp${1}data/usb/backup/${1}data/temp${1}data/*" >> /usr/bin/$RESTORE_SCRIPT_NAME
2900
+  echo "  shred -zu /root/temp${1}data/${RESTORE_SUBDIR}/temp${1}data/*" >> /usr/bin/$RESTORE_SCRIPT_NAME
2897
   echo "  rm -rf /root/temp${1}data" >> /usr/bin/$RESTORE_SCRIPT_NAME
2901
   echo "  rm -rf /root/temp${1}data" >> /usr/bin/$RESTORE_SCRIPT_NAME
2898
   echo "  echo \"Restoring ${1} installation\"" >> /usr/bin/$RESTORE_SCRIPT_NAME
2902
   echo "  echo \"Restoring ${1} installation\"" >> /usr/bin/$RESTORE_SCRIPT_NAME
2899
   echo "  if [ ! -d /root/temp${1} ]; then" >> /usr/bin/$RESTORE_SCRIPT_NAME
2903
   echo "  if [ ! -d /root/temp${1} ]; then" >> /usr/bin/$RESTORE_SCRIPT_NAME
2900
   echo "    mkdir /root/temp${1}" >> /usr/bin/$RESTORE_SCRIPT_NAME
2904
   echo "    mkdir /root/temp${1}" >> /usr/bin/$RESTORE_SCRIPT_NAME
2901
   echo '  fi' >> /usr/bin/$RESTORE_SCRIPT_NAME
2905
   echo '  fi' >> /usr/bin/$RESTORE_SCRIPT_NAME
2902
   restore_directory_from_usb /root/temp${1} ${1}
2906
   restore_directory_from_usb /root/temp${1} ${1}
2907
+  if [[ $BACKUP_TYPE != 'obnam' ]]; then
2908
+      RESTORE_SUBDIR="usb/backup/${1}"
2909
+  fi
2903
   echo "  if [ ${2} ]; then" >> /usr/bin/$RESTORE_SCRIPT_NAME
2910
   echo "  if [ ${2} ]; then" >> /usr/bin/$RESTORE_SCRIPT_NAME
2904
   echo "    if [ -d /var/www/${2}/htdocs ]; then" >> /usr/bin/$RESTORE_SCRIPT_NAME
2911
   echo "    if [ -d /var/www/${2}/htdocs ]; then" >> /usr/bin/$RESTORE_SCRIPT_NAME
2905
   echo "      rm -rf /var/www/${2}/htdocs" >> /usr/bin/$RESTORE_SCRIPT_NAME
2912
   echo "      rm -rf /var/www/${2}/htdocs" >> /usr/bin/$RESTORE_SCRIPT_NAME
2906
-  echo "      mv /root/temp${1}/usb/backup/${1}/www/${2}/htdocs /var/www/${2}/" >> /usr/bin/$RESTORE_SCRIPT_NAME
2913
+  echo "      mv /root/temp${1}/${RESTORE_SUBDIR}/www/${2}/htdocs /var/www/${2}/" >> /usr/bin/$RESTORE_SCRIPT_NAME
2907
   echo '      if [ ! "$?" = "0" ]; then' >> /usr/bin/$RESTORE_SCRIPT_NAME
2914
   echo '      if [ ! "$?" = "0" ]; then' >> /usr/bin/$RESTORE_SCRIPT_NAME
2908
   echo "        umount $USB_MOUNT" >> /usr/bin/$RESTORE_SCRIPT_NAME
2915
   echo "        umount $USB_MOUNT" >> /usr/bin/$RESTORE_SCRIPT_NAME
2909
   echo "        rm -rf $USB_MOUNT" >> /usr/bin/$RESTORE_SCRIPT_NAME
2916
   echo "        rm -rf $USB_MOUNT" >> /usr/bin/$RESTORE_SCRIPT_NAME
3027
   echo '' >> /usr/bin/$RESTORE_SCRIPT_NAME
3034
   echo '' >> /usr/bin/$RESTORE_SCRIPT_NAME
3028
 
3035
 
3029
   if [[ $BACKUP_INCLUDES_DATABASES == "yes" ]]; then
3036
   if [[ $BACKUP_INCLUDES_DATABASES == "yes" ]]; then
3037
+      RESTORE_SUBDIR='root/'
3038
+      if [[ $BACKUP_TYPE != 'obnam' ]]; then
3039
+          RESTORE_SUBDIR='usb/backup/mariadb/'
3040
+      fi
3030
       echo "if [ -d $USB_MOUNT/backup/mariadb ]; then" >> /usr/bin/$RESTORE_SCRIPT_NAME
3041
       echo "if [ -d $USB_MOUNT/backup/mariadb ]; then" >> /usr/bin/$RESTORE_SCRIPT_NAME
3031
       echo '  echo "Restoring mysql settings"' >> /usr/bin/$RESTORE_SCRIPT_NAME
3042
       echo '  echo "Restoring mysql settings"' >> /usr/bin/$RESTORE_SCRIPT_NAME
3032
       restore_directory_from_usb /root/tempmariadb mariadb
3043
       restore_directory_from_usb /root/tempmariadb mariadb
3033
       echo '  echo "Get the MariaDB password from the backup"' >> /usr/bin/$RESTORE_SCRIPT_NAME
3044
       echo '  echo "Get the MariaDB password from the backup"' >> /usr/bin/$RESTORE_SCRIPT_NAME
3034
-      echo '  if [ ! -f /root/tempmariadb/usb/backup/mariadb/tempmariadb/db ]; then' >> /usr/bin/$RESTORE_SCRIPT_NAME
3045
+      echo "  if [ ! -f /root/tempmariadb/${RESTORE_SUBDIR}tempmariadb/db ]; then" >> /usr/bin/$RESTORE_SCRIPT_NAME
3035
       echo '    echo "MariaDB password file not found"' >> /usr/bin/$RESTORE_SCRIPT_NAME
3046
       echo '    echo "MariaDB password file not found"' >> /usr/bin/$RESTORE_SCRIPT_NAME
3036
       echo '    exit 495' >> /usr/bin/$RESTORE_SCRIPT_NAME
3047
       echo '    exit 495' >> /usr/bin/$RESTORE_SCRIPT_NAME
3037
       echo '  fi' >> /usr/bin/$RESTORE_SCRIPT_NAME
3048
       echo '  fi' >> /usr/bin/$RESTORE_SCRIPT_NAME
3038
-      echo '  BACKUP_MARIADB_PASSWORD=$(cat /root/tempmariadb/usb/backup/mariadb/tempmariadb/db)' >> /usr/bin/$RESTORE_SCRIPT_NAME
3049
+      echo -n '  BACKUP_MARIADB_PASSWORD=$(cat /root/tempmariadb/' >> /usr/bin/$RESTORE_SCRIPT_NAME
3050
+      echo "${RESTORE_SUBDIR}tempmariadb/db)" >> /usr/bin/$RESTORE_SCRIPT_NAME
3039
       echo '  if [[ $BACKUP_MARIADB_PASSWORD != $DATABASE_PASSWORD ]]; then' >> /usr/bin/$RESTORE_SCRIPT_NAME
3051
       echo '  if [[ $BACKUP_MARIADB_PASSWORD != $DATABASE_PASSWORD ]]; then' >> /usr/bin/$RESTORE_SCRIPT_NAME
3040
       echo '    echo "Restore the MariaDB user table"' >> /usr/bin/$RESTORE_SCRIPT_NAME
3052
       echo '    echo "Restore the MariaDB user table"' >> /usr/bin/$RESTORE_SCRIPT_NAME
3041
-      echo '    mysqlsuccess=$(mysql -u root --password=$DATABASE_PASSWORD mysql -o < /root/tempmariadb/usb/backup/mariadb/tempmariadb/mysql.sql)' >> /usr/bin/$RESTORE_SCRIPT_NAME
3053
+      echo -n '    mysqlsuccess=$(mysql -u root --password=$DATABASE_PASSWORD mysql -o < ' >> /usr/bin/$RESTORE_SCRIPT_NAME
3054
+      echo "/root/tempmariadb/${RESTORE_SUBDIR}tempmariadb/mysql.sql)" >> /usr/bin/$RESTORE_SCRIPT_NAME
3042
       echo '    if [ ! "$?" = "0" ]; then' >> /usr/bin/$RESTORE_SCRIPT_NAME
3055
       echo '    if [ ! "$?" = "0" ]; then' >> /usr/bin/$RESTORE_SCRIPT_NAME
3043
       echo '      echo "Try again using the password obtained from backup"' >> /usr/bin/$RESTORE_SCRIPT_NAME
3056
       echo '      echo "Try again using the password obtained from backup"' >> /usr/bin/$RESTORE_SCRIPT_NAME
3044
-      echo '      mysqlsuccess=$(mysql -u root --password=$BACKUP_MARIADB_PASSWORD mysql -o < /root/tempmariadb/usb/backup/mariadb/tempmariadb/mysql.sql)' >> /usr/bin/$RESTORE_SCRIPT_NAME
3057
+      echo -n '      mysqlsuccess=$(mysql -u root --password=$BACKUP_MARIADB_PASSWORD mysql -o < ' >> /usr/bin/$RESTORE_SCRIPT_NAME
3058
+      echo "/root/tempmariadb/${RESTORE_SUBDIR}tempmariadb/mysql.sql)" >> /usr/bin/$RESTORE_SCRIPT_NAME
3045
       echo '    fi' >> /usr/bin/$RESTORE_SCRIPT_NAME
3059
       echo '    fi' >> /usr/bin/$RESTORE_SCRIPT_NAME
3046
       echo '    if [ ! "$?" = "0" ]; then' >> /usr/bin/$RESTORE_SCRIPT_NAME
3060
       echo '    if [ ! "$?" = "0" ]; then' >> /usr/bin/$RESTORE_SCRIPT_NAME
3047
       echo '      echo "$mysqlsuccess"' >> /usr/bin/$RESTORE_SCRIPT_NAME
3061
       echo '      echo "$mysqlsuccess"' >> /usr/bin/$RESTORE_SCRIPT_NAME
3054
       echo '    echo "Change the MariaDB password to the backup version"' >> /usr/bin/$RESTORE_SCRIPT_NAME
3068
       echo '    echo "Change the MariaDB password to the backup version"' >> /usr/bin/$RESTORE_SCRIPT_NAME
3055
       echo '    DATABASE_PASSWORD=$BACKUP_MARIADB_PASSWORD' >> /usr/bin/$RESTORE_SCRIPT_NAME
3069
       echo '    DATABASE_PASSWORD=$BACKUP_MARIADB_PASSWORD' >> /usr/bin/$RESTORE_SCRIPT_NAME
3056
       echo '  fi' >> /usr/bin/$RESTORE_SCRIPT_NAME
3070
       echo '  fi' >> /usr/bin/$RESTORE_SCRIPT_NAME
3057
-      echo '  shred -zu /root/tempmariadb/usb/backup/mariadb/tempmariadb/db' >> /usr/bin/$RESTORE_SCRIPT_NAME
3071
+      echo "  shred -zu /root/tempmariadb/${RESTORE_SUBDIR}tempmariadb/db" >> /usr/bin/$RESTORE_SCRIPT_NAME
3058
       echo '  rm -rf /root/tempmariadb' >> /usr/bin/$RESTORE_SCRIPT_NAME
3072
       echo '  rm -rf /root/tempmariadb' >> /usr/bin/$RESTORE_SCRIPT_NAME
3059
       echo '' >> /usr/bin/$RESTORE_SCRIPT_NAME
3073
       echo '' >> /usr/bin/$RESTORE_SCRIPT_NAME
3060
       echo '  # Change database password file' >> /usr/bin/$RESTORE_SCRIPT_NAME
3074
       echo '  # Change database password file' >> /usr/bin/$RESTORE_SCRIPT_NAME
3065
       echo '' >> /usr/bin/$RESTORE_SCRIPT_NAME
3079
       echo '' >> /usr/bin/$RESTORE_SCRIPT_NAME
3066
   fi
3080
   fi
3067
 
3081
 
3082
+  RESTORE_SUBDIR='root/'
3083
+  if [[ $BACKUP_TYPE != 'obnam' ]]; then
3084
+      RESTORE_SUBDIR='usb/backup/mutt/'
3085
+  fi
3068
   echo "if [ -d $USB_MOUNT/backup/mutt ]; then" >> /usr/bin/$RESTORE_SCRIPT_NAME
3086
   echo "if [ -d $USB_MOUNT/backup/mutt ]; then" >> /usr/bin/$RESTORE_SCRIPT_NAME
3069
   echo '  echo "Restoring Mutt settings"' >> /usr/bin/$RESTORE_SCRIPT_NAME
3087
   echo '  echo "Restoring Mutt settings"' >> /usr/bin/$RESTORE_SCRIPT_NAME
3070
   restore_directory_from_usb /root/tempmutt mutt
3088
   restore_directory_from_usb /root/tempmutt mutt
3071
-  echo '  if [ -f /root/tempmutt/usb/backup/mutt/$MY_USERNAME/tempbackup/.muttrc ]; then' >> /usr/bin/$RESTORE_SCRIPT_NAME
3072
-  echo '    cp -f /root/tempmutt/usb/backup/mutt/$MY_USERNAME/tempbackup/.muttrc /home/$MY_USERNAME/.muttrc' >> /usr/bin/$RESTORE_SCRIPT_NAME
3089
+  echo -n "  if [ -f /root/tempmutt/${RESTORE_SUBDIR}" >> /usr/bin/$RESTORE_SCRIPT_NAME
3090
+  echo '$MY_USERNAME/tempbackup/.muttrc ]; then' >> /usr/bin/$RESTORE_SCRIPT_NAME
3091
+  echo -n "    cp -f /root/tempmutt/${RESTORE_SUBDIR}" >> /usr/bin/$RESTORE_SCRIPT_NAME
3092
+  echo '$MY_USERNAME/tempbackup/.muttrc /home/$MY_USERNAME/.muttrc' >> /usr/bin/$RESTORE_SCRIPT_NAME
3073
   echo '  fi' >> /usr/bin/$RESTORE_SCRIPT_NAME
3093
   echo '  fi' >> /usr/bin/$RESTORE_SCRIPT_NAME
3074
-  echo '  if [ -f /root/tempmutt/usb/backup/mutt/$MY_USERNAME/tempbackup/Muttrc ]; then' >> /usr/bin/$RESTORE_SCRIPT_NAME
3075
-  echo '    cp -f /root/tempmutt/usb/backup/mutt/$MY_USERNAME/tempbackup/Muttrc /etc/Muttrc' >> /usr/bin/$RESTORE_SCRIPT_NAME
3094
+  echo -n "  if [ -f /root/tempmutt/${RESTORE_SUBDIR}" >> /usr/bin/$RESTORE_SCRIPT_NAME
3095
+  echo '$MY_USERNAME/tempbackup/Muttrc ]; then' >> /usr/bin/$RESTORE_SCRIPT_NAME
3096
+  echo -n "    cp -f /root/tempmutt/${RESTORE_SUBDIR}" >> /usr/bin/$RESTORE_SCRIPT_NAME
3097
+  echo '$MY_USERNAME/tempbackup/Muttrc /etc/Muttrc' >> /usr/bin/$RESTORE_SCRIPT_NAME
3076
   echo '  fi' >> /usr/bin/$RESTORE_SCRIPT_NAME
3098
   echo '  fi' >> /usr/bin/$RESTORE_SCRIPT_NAME
3077
   echo '  if [ ! "$?" = "0" ]; then' >> /usr/bin/$RESTORE_SCRIPT_NAME
3099
   echo '  if [ ! "$?" = "0" ]; then' >> /usr/bin/$RESTORE_SCRIPT_NAME
3078
   echo "    umount $USB_MOUNT" >> /usr/bin/$RESTORE_SCRIPT_NAME
3100
   echo "    umount $USB_MOUNT" >> /usr/bin/$RESTORE_SCRIPT_NAME
3084
   echo 'fi' >> /usr/bin/$RESTORE_SCRIPT_NAME
3106
   echo 'fi' >> /usr/bin/$RESTORE_SCRIPT_NAME
3085
   echo '' >> /usr/bin/$RESTORE_SCRIPT_NAME
3107
   echo '' >> /usr/bin/$RESTORE_SCRIPT_NAME
3086
 
3108
 
3109
+  RESTORE_SUBDIR='root/'
3110
+  if [[ $BACKUP_TYPE != 'obnam' ]]; then
3111
+      RESTORE_SUBDIR='usb/backup/gnupg/'
3112
+  fi
3087
   echo "if [ -d $USB_MOUNT/backup/gnupg ]; then" >> /usr/bin/$RESTORE_SCRIPT_NAME
3113
   echo "if [ -d $USB_MOUNT/backup/gnupg ]; then" >> /usr/bin/$RESTORE_SCRIPT_NAME
3088
   echo '  echo "Restoring gnupg settings"' >> /usr/bin/$RESTORE_SCRIPT_NAME
3114
   echo '  echo "Restoring gnupg settings"' >> /usr/bin/$RESTORE_SCRIPT_NAME
3089
   restore_directory_from_usb /root/tempgnupg gnupg
3115
   restore_directory_from_usb /root/tempgnupg gnupg
3090
-  echo '  cp -r /root/tempgnupg/usb/backup/gnupg/$MY_USERNAME/.gnupg /home/$MY_USERNAME/' >> /usr/bin/$RESTORE_SCRIPT_NAME
3116
+  echo -n "  cp -r /root/tempgnupg/${RESTORE_SUBDIR}" >> /usr/bin/$RESTORE_SCRIPT_NAME
3117
+  echo '$MY_USERNAME/.gnupg /home/$MY_USERNAME/' >> /usr/bin/$RESTORE_SCRIPT_NAME
3091
   echo '  if [ ! "$?" = "0" ]; then' >> /usr/bin/$RESTORE_SCRIPT_NAME
3118
   echo '  if [ ! "$?" = "0" ]; then' >> /usr/bin/$RESTORE_SCRIPT_NAME
3092
   echo "    umount $USB_MOUNT" >> /usr/bin/$RESTORE_SCRIPT_NAME
3119
   echo "    umount $USB_MOUNT" >> /usr/bin/$RESTORE_SCRIPT_NAME
3093
   echo "    rm -rf $USB_MOUNT" >> /usr/bin/$RESTORE_SCRIPT_NAME
3120
   echo "    rm -rf $USB_MOUNT" >> /usr/bin/$RESTORE_SCRIPT_NAME
3104
   echo 'fi' >> /usr/bin/$RESTORE_SCRIPT_NAME
3131
   echo 'fi' >> /usr/bin/$RESTORE_SCRIPT_NAME
3105
   echo '' >> /usr/bin/$RESTORE_SCRIPT_NAME
3132
   echo '' >> /usr/bin/$RESTORE_SCRIPT_NAME
3106
 
3133
 
3134
+  RESTORE_SUBDIR='root/'
3135
+  if [[ $BACKUP_TYPE != 'obnam' ]]; then
3136
+      RESTORE_SUBDIR='usb/backup/procmail/'
3137
+  fi
3107
   echo "if [ -d $USB_MOUNT/backup/procmail ]; then" >> /usr/bin/$RESTORE_SCRIPT_NAME
3138
   echo "if [ -d $USB_MOUNT/backup/procmail ]; then" >> /usr/bin/$RESTORE_SCRIPT_NAME
3108
   echo '  echo "Restoring procmail settings"' >> /usr/bin/$RESTORE_SCRIPT_NAME
3139
   echo '  echo "Restoring procmail settings"' >> /usr/bin/$RESTORE_SCRIPT_NAME
3109
   restore_directory_from_usb /root/tempprocmail procmail
3140
   restore_directory_from_usb /root/tempprocmail procmail
3110
-  echo '  cp -f /root/tempprocmail/usb/backup/procmail/$MY_USERNAME/tempbackup/.procmailrc /home/$MY_USERNAME/' >> /usr/bin/$RESTORE_SCRIPT_NAME
3141
+  echo -n "  cp -f /root/tempprocmail/${RESTORE_SUBDIR}" >> /usr/bin/$RESTORE_SCRIPT_NAME
3142
+  echo '$MY_USERNAME/tempbackup/.procmailrc /home/$MY_USERNAME/' >> /usr/bin/$RESTORE_SCRIPT_NAME
3111
   echo '  if [ ! "$?" = "0" ]; then' >> /usr/bin/$RESTORE_SCRIPT_NAME
3143
   echo '  if [ ! "$?" = "0" ]; then' >> /usr/bin/$RESTORE_SCRIPT_NAME
3112
   echo "    umount $USB_MOUNT" >> /usr/bin/$RESTORE_SCRIPT_NAME
3144
   echo "    umount $USB_MOUNT" >> /usr/bin/$RESTORE_SCRIPT_NAME
3113
   echo "    rm -rf $USB_MOUNT" >> /usr/bin/$RESTORE_SCRIPT_NAME
3145
   echo "    rm -rf $USB_MOUNT" >> /usr/bin/$RESTORE_SCRIPT_NAME
3118
   echo 'fi' >> /usr/bin/$RESTORE_SCRIPT_NAME
3150
   echo 'fi' >> /usr/bin/$RESTORE_SCRIPT_NAME
3119
   echo '' >> /usr/bin/$RESTORE_SCRIPT_NAME
3151
   echo '' >> /usr/bin/$RESTORE_SCRIPT_NAME
3120
 
3152
 
3153
+  RESTORE_SUBDIR='root/'
3154
+  if [[ $BACKUP_TYPE != 'obnam' ]]; then
3155
+      RESTORE_SUBDIR='usb/backup/spamassassin/'
3156
+  fi
3121
   echo "if [ -d $USB_MOUNT/backup/spamassassin ]; then" >> /usr/bin/$RESTORE_SCRIPT_NAME
3157
   echo "if [ -d $USB_MOUNT/backup/spamassassin ]; then" >> /usr/bin/$RESTORE_SCRIPT_NAME
3122
   echo '  echo "Restoring spamassassin settings"' >> /usr/bin/$RESTORE_SCRIPT_NAME
3158
   echo '  echo "Restoring spamassassin settings"' >> /usr/bin/$RESTORE_SCRIPT_NAME
3123
   restore_directory_from_usb /root/tempspamassassin spamassassin
3159
   restore_directory_from_usb /root/tempspamassassin spamassassin
3124
-  echo '  cp -rf /root/tempspamassassin/usb/backup/spamassassin/$MY_USERNAME/.spamassassin /home/$MY_USERNAME/' >> /usr/bin/$RESTORE_SCRIPT_NAME
3160
+  echo -n "  cp -rf /root/tempspamassassin/${RESTORE_SUBDIR}" >> /usr/bin/$RESTORE_SCRIPT_NAME
3161
+  echo '$MY_USERNAME/.spamassassin /home/$MY_USERNAME/' >> /usr/bin/$RESTORE_SCRIPT_NAME
3125
   echo '  if [ ! "$?" = "0" ]; then' >> /usr/bin/$RESTORE_SCRIPT_NAME
3162
   echo '  if [ ! "$?" = "0" ]; then' >> /usr/bin/$RESTORE_SCRIPT_NAME
3126
   echo "    umount $USB_MOUNT" >> /usr/bin/$RESTORE_SCRIPT_NAME
3163
   echo "    umount $USB_MOUNT" >> /usr/bin/$RESTORE_SCRIPT_NAME
3127
   echo "    rm -rf $USB_MOUNT" >> /usr/bin/$RESTORE_SCRIPT_NAME
3164
   echo "    rm -rf $USB_MOUNT" >> /usr/bin/$RESTORE_SCRIPT_NAME
3132
   echo 'fi' >> /usr/bin/$RESTORE_SCRIPT_NAME
3169
   echo 'fi' >> /usr/bin/$RESTORE_SCRIPT_NAME
3133
   echo '' >> /usr/bin/$RESTORE_SCRIPT_NAME
3170
   echo '' >> /usr/bin/$RESTORE_SCRIPT_NAME
3134
 
3171
 
3172
+  RESTORE_SUBDIR='root/'
3173
+  if [[ $BACKUP_TYPE != 'obnam' ]]; then
3174
+      RESTORE_SUBDIR='usb/backup/readme/'
3175
+  fi
3135
   echo "if [ -d $USB_MOUNT/backup/readme ]; then" >> /usr/bin/$RESTORE_SCRIPT_NAME
3176
   echo "if [ -d $USB_MOUNT/backup/readme ]; then" >> /usr/bin/$RESTORE_SCRIPT_NAME
3136
   echo '  echo "Restoring README"' >> /usr/bin/$RESTORE_SCRIPT_NAME
3177
   echo '  echo "Restoring README"' >> /usr/bin/$RESTORE_SCRIPT_NAME
3137
   restore_directory_from_usb /root/tempreadme readme
3178
   restore_directory_from_usb /root/tempreadme readme
3138
-  echo '  cp -f /root/tempreadme/usb/backup/readme/$MY_USERNAME/tempbackup/README /home/$MY_USERNAME/' >> /usr/bin/$RESTORE_SCRIPT_NAME
3179
+  echo -n "  cp -f /root/tempreadme/${RESTORE_SUBDIR}" >> /usr/bin/$RESTORE_SCRIPT_NAME
3180
+  echo '$MY_USERNAME/tempbackup/README /home/$MY_USERNAME/' >> /usr/bin/$RESTORE_SCRIPT_NAME
3139
   echo '  if [ ! "$?" = "0" ]; then' >> /usr/bin/$RESTORE_SCRIPT_NAME
3181
   echo '  if [ ! "$?" = "0" ]; then' >> /usr/bin/$RESTORE_SCRIPT_NAME
3140
   echo "    umount $USB_MOUNT" >> /usr/bin/$RESTORE_SCRIPT_NAME
3182
   echo "    umount $USB_MOUNT" >> /usr/bin/$RESTORE_SCRIPT_NAME
3141
   echo "    rm -rf $USB_MOUNT" >> /usr/bin/$RESTORE_SCRIPT_NAME
3183
   echo "    rm -rf $USB_MOUNT" >> /usr/bin/$RESTORE_SCRIPT_NAME
3146
   echo 'fi' >> /usr/bin/$RESTORE_SCRIPT_NAME
3188
   echo 'fi' >> /usr/bin/$RESTORE_SCRIPT_NAME
3147
   echo '' >> /usr/bin/$RESTORE_SCRIPT_NAME
3189
   echo '' >> /usr/bin/$RESTORE_SCRIPT_NAME
3148
 
3190
 
3191
+  RESTORE_SUBDIR='root/'
3192
+  if [[ $BACKUP_TYPE != 'obnam' ]]; then
3193
+      RESTORE_SUBDIR='usb/backup/ssh/'
3194
+  fi
3149
   echo "if [ -d $USB_MOUNT/backup/ssh ]; then" >> /usr/bin/$RESTORE_SCRIPT_NAME
3195
   echo "if [ -d $USB_MOUNT/backup/ssh ]; then" >> /usr/bin/$RESTORE_SCRIPT_NAME
3150
   echo '  echo "Restoring ssh keys"' >> /usr/bin/$RESTORE_SCRIPT_NAME
3196
   echo '  echo "Restoring ssh keys"' >> /usr/bin/$RESTORE_SCRIPT_NAME
3151
   restore_directory_from_usb /root/tempssh ssh
3197
   restore_directory_from_usb /root/tempssh ssh
3152
-  echo '  cp -r /root/tempssh/usb/backup/ssh/$MY_USERNAME/.ssh /home/$MY_USERNAME/' >> /usr/bin/$RESTORE_SCRIPT_NAME
3198
+  echo -n "  cp -r /root/tempssh/${RESTORE_SUBDIR}" >> /usr/bin/$RESTORE_SCRIPT_NAME
3199
+  echo '$MY_USERNAME/.ssh /home/$MY_USERNAME/' >> /usr/bin/$RESTORE_SCRIPT_NAME
3153
   echo '  if [ ! "$?" = "0" ]; then' >> /usr/bin/$RESTORE_SCRIPT_NAME
3200
   echo '  if [ ! "$?" = "0" ]; then' >> /usr/bin/$RESTORE_SCRIPT_NAME
3154
   echo "    umount $USB_MOUNT" >> /usr/bin/$RESTORE_SCRIPT_NAME
3201
   echo "    umount $USB_MOUNT" >> /usr/bin/$RESTORE_SCRIPT_NAME
3155
   echo "    rm -rf $USB_MOUNT" >> /usr/bin/$RESTORE_SCRIPT_NAME
3202
   echo "    rm -rf $USB_MOUNT" >> /usr/bin/$RESTORE_SCRIPT_NAME
3160
   echo 'fi' >> /usr/bin/$RESTORE_SCRIPT_NAME
3207
   echo 'fi' >> /usr/bin/$RESTORE_SCRIPT_NAME
3161
   echo '' >> /usr/bin/$RESTORE_SCRIPT_NAME
3208
   echo '' >> /usr/bin/$RESTORE_SCRIPT_NAME
3162
 
3209
 
3210
+  RESTORE_SUBDIR='root/'
3211
+  if [[ $BACKUP_TYPE != 'obnam' ]]; then
3212
+      RESTORE_SUBDIR='usb/backup/ssl/'
3213
+  fi
3163
   echo "if [ -d $USB_MOUNT/backup/ssl ]; then" >> /usr/bin/$RESTORE_SCRIPT_NAME
3214
   echo "if [ -d $USB_MOUNT/backup/ssl ]; then" >> /usr/bin/$RESTORE_SCRIPT_NAME
3164
   echo '  echo "Restoring certificates"' >> /usr/bin/$RESTORE_SCRIPT_NAME
3215
   echo '  echo "Restoring certificates"' >> /usr/bin/$RESTORE_SCRIPT_NAME
3165
   echo '  mkdir /root/tempssl' >> /usr/bin/$RESTORE_SCRIPT_NAME
3216
   echo '  mkdir /root/tempssl' >> /usr/bin/$RESTORE_SCRIPT_NAME
3166
   restore_directory_from_usb /root/tempssl ssl
3217
   restore_directory_from_usb /root/tempssl ssl
3167
-  echo '  cp -r /root/tempssl/usb/backup/ssl/ssl/* /etc/ssl' >> /usr/bin/$RESTORE_SCRIPT_NAME
3218
+  echo "  cp -r /root/tempssl/${RESTORE_SUBDIR}ssl/* /etc/ssl" >> /usr/bin/$RESTORE_SCRIPT_NAME
3168
   echo '  if [ ! "$?" = "0" ]; then' >> /usr/bin/$RESTORE_SCRIPT_NAME
3219
   echo '  if [ ! "$?" = "0" ]; then' >> /usr/bin/$RESTORE_SCRIPT_NAME
3169
   echo "    umount $USB_MOUNT" >> /usr/bin/$RESTORE_SCRIPT_NAME
3220
   echo "    umount $USB_MOUNT" >> /usr/bin/$RESTORE_SCRIPT_NAME
3170
   echo "    rm -rf $USB_MOUNT" >> /usr/bin/$RESTORE_SCRIPT_NAME
3221
   echo "    rm -rf $USB_MOUNT" >> /usr/bin/$RESTORE_SCRIPT_NAME
3174
   echo 'fi' >> /usr/bin/$RESTORE_SCRIPT_NAME
3225
   echo 'fi' >> /usr/bin/$RESTORE_SCRIPT_NAME
3175
   echo '' >> /usr/bin/$RESTORE_SCRIPT_NAME
3226
   echo '' >> /usr/bin/$RESTORE_SCRIPT_NAME
3176
 
3227
 
3228
+  RESTORE_SUBDIR='root/'
3229
+  if [[ $BACKUP_TYPE != 'obnam' ]]; then
3230
+      RESTORE_SUBDIR='usb/backup/projects/'
3231
+  fi
3177
   echo "if [ -d $USB_MOUNT/backup/projects ]; then" >> /usr/bin/$RESTORE_SCRIPT_NAME
3232
   echo "if [ -d $USB_MOUNT/backup/projects ]; then" >> /usr/bin/$RESTORE_SCRIPT_NAME
3178
   echo '  echo "Restoring projects"' >> /usr/bin/$RESTORE_SCRIPT_NAME
3233
   echo '  echo "Restoring projects"' >> /usr/bin/$RESTORE_SCRIPT_NAME
3179
   restore_directory_from_usb /root/tempprojects projects
3234
   restore_directory_from_usb /root/tempprojects projects
3180
   echo '  if [ -d /home/$MY_USERNAME/projects ]; then' >> /usr/bin/$RESTORE_SCRIPT_NAME
3235
   echo '  if [ -d /home/$MY_USERNAME/projects ]; then' >> /usr/bin/$RESTORE_SCRIPT_NAME
3181
   echo '    rm -rf /home/$MY_USERNAME/projects' >> /usr/bin/$RESTORE_SCRIPT_NAME
3236
   echo '    rm -rf /home/$MY_USERNAME/projects' >> /usr/bin/$RESTORE_SCRIPT_NAME
3182
   echo '  fi' >> /usr/bin/$RESTORE_SCRIPT_NAME
3237
   echo '  fi' >> /usr/bin/$RESTORE_SCRIPT_NAME
3183
-  echo '  mv /root/tempprojects/usb/backup/projects/$MY_USERNAME/projects /home/$MY_USERNAME' >> /usr/bin/$RESTORE_SCRIPT_NAME
3238
+  echo -n "  mv /root/tempprojects/${RESTORE_SUBDIR}" >> /usr/bin/$RESTORE_SCRIPT_NAME
3239
+  echo '$MY_USERNAME/projects /home/$MY_USERNAME' >> /usr/bin/$RESTORE_SCRIPT_NAME
3184
   echo '  if [ ! "$?" = "0" ]; then' >> /usr/bin/$RESTORE_SCRIPT_NAME
3240
   echo '  if [ ! "$?" = "0" ]; then' >> /usr/bin/$RESTORE_SCRIPT_NAME
3185
   echo "    umount $USB_MOUNT" >> /usr/bin/$RESTORE_SCRIPT_NAME
3241
   echo "    umount $USB_MOUNT" >> /usr/bin/$RESTORE_SCRIPT_NAME
3186
   echo "    rm -rf $USB_MOUNT" >> /usr/bin/$RESTORE_SCRIPT_NAME
3242
   echo "    rm -rf $USB_MOUNT" >> /usr/bin/$RESTORE_SCRIPT_NAME
3190
   echo 'fi' >> /usr/bin/$RESTORE_SCRIPT_NAME
3246
   echo 'fi' >> /usr/bin/$RESTORE_SCRIPT_NAME
3191
   echo '' >> /usr/bin/$RESTORE_SCRIPT_NAME
3247
   echo '' >> /usr/bin/$RESTORE_SCRIPT_NAME
3192
 
3248
 
3249
+  RESTORE_SUBDIR='root/'
3250
+  if [[ $BACKUP_TYPE != 'obnam' ]]; then
3251
+      RESTORE_SUBDIR='usb/backup/personal/'
3252
+  fi
3193
   echo "if [ -d $USB_MOUNT/backup/personal ]; then" >> /usr/bin/$RESTORE_SCRIPT_NAME
3253
   echo "if [ -d $USB_MOUNT/backup/personal ]; then" >> /usr/bin/$RESTORE_SCRIPT_NAME
3194
   echo '  echo "Restoring personal settings"' >> /usr/bin/$RESTORE_SCRIPT_NAME
3254
   echo '  echo "Restoring personal settings"' >> /usr/bin/$RESTORE_SCRIPT_NAME
3195
   restore_directory_from_usb /root/temppersonal personal
3255
   restore_directory_from_usb /root/temppersonal personal
3196
   echo '  if [ -d /home/$MY_USERNAME/personal ]; then' >> /usr/bin/$RESTORE_SCRIPT_NAME
3256
   echo '  if [ -d /home/$MY_USERNAME/personal ]; then' >> /usr/bin/$RESTORE_SCRIPT_NAME
3197
   echo '    rm -rf /home/$MY_USERNAME/personal' >> /usr/bin/$RESTORE_SCRIPT_NAME
3257
   echo '    rm -rf /home/$MY_USERNAME/personal' >> /usr/bin/$RESTORE_SCRIPT_NAME
3198
   echo '  fi' >> /usr/bin/$RESTORE_SCRIPT_NAME
3258
   echo '  fi' >> /usr/bin/$RESTORE_SCRIPT_NAME
3199
-  echo '  mv /root/temppersonal/usb/backup/personal/$MY_USERNAME/personal /home/$MY_USERNAME' >> /usr/bin/$RESTORE_SCRIPT_NAME
3259
+  echo -n "  mv /root/temppersonal/${RESTORE_SUBDIR}" >> /usr/bin/$RESTORE_SCRIPT_NAME
3260
+  echo '$MY_USERNAME/personal /home/$MY_USERNAME' >> /usr/bin/$RESTORE_SCRIPT_NAME
3200
   echo '  if [ ! "$?" = "0" ]; then' >> /usr/bin/$RESTORE_SCRIPT_NAME
3261
   echo '  if [ ! "$?" = "0" ]; then' >> /usr/bin/$RESTORE_SCRIPT_NAME
3201
   echo "    umount $USB_MOUNT" >> /usr/bin/$RESTORE_SCRIPT_NAME
3262
   echo "    umount $USB_MOUNT" >> /usr/bin/$RESTORE_SCRIPT_NAME
3202
   echo "    rm -rf $USB_MOUNT" >> /usr/bin/$RESTORE_SCRIPT_NAME
3263
   echo "    rm -rf $USB_MOUNT" >> /usr/bin/$RESTORE_SCRIPT_NAME
3206
   echo 'fi' >> /usr/bin/$RESTORE_SCRIPT_NAME
3267
   echo 'fi' >> /usr/bin/$RESTORE_SCRIPT_NAME
3207
   echo '' >> /usr/bin/$RESTORE_SCRIPT_NAME
3268
   echo '' >> /usr/bin/$RESTORE_SCRIPT_NAME
3208
 
3269
 
3270
+  RESTORE_SUBDIR='root/'
3271
+  if [[ $BACKUP_TYPE != 'obnam' ]]; then
3272
+      RESTORE_SUBDIR='usb/backup/mailinglist/'
3273
+  fi
3209
   echo "if [ -d $PUBLIC_MAILING_LIST_DIRECTORY ]; then" >> /usr/bin/$RESTORE_SCRIPT_NAME
3274
   echo "if [ -d $PUBLIC_MAILING_LIST_DIRECTORY ]; then" >> /usr/bin/$RESTORE_SCRIPT_NAME
3210
   echo '  echo "Restoring public mailing list"' >> /usr/bin/$RESTORE_SCRIPT_NAME
3275
   echo '  echo "Restoring public mailing list"' >> /usr/bin/$RESTORE_SCRIPT_NAME
3211
   restore_directory_from_usb /root/tempmailinglist mailinglist
3276
   restore_directory_from_usb /root/tempmailinglist mailinglist
3212
-  echo "  cp -r /root/tempmailinglist/usb/backup/mailinglist/spool/mlmmj/* $PUBLIC_MAILING_LIST_DIRECTORY" >> /usr/bin/$RESTORE_SCRIPT_NAME
3277
+  echo "  cp -r /root/tempmailinglist/${RESTORE_SUBDIR}spool/mlmmj/* $PUBLIC_MAILING_LIST_DIRECTORY" >> /usr/bin/$RESTORE_SCRIPT_NAME
3213
   echo '  if [ ! "$?" = "0" ]; then' >> /usr/bin/$RESTORE_SCRIPT_NAME
3278
   echo '  if [ ! "$?" = "0" ]; then' >> /usr/bin/$RESTORE_SCRIPT_NAME
3214
   echo "    umount $USB_MOUNT" >> /usr/bin/$RESTORE_SCRIPT_NAME
3279
   echo "    umount $USB_MOUNT" >> /usr/bin/$RESTORE_SCRIPT_NAME
3215
   echo "    rm -rf $USB_MOUNT" >> /usr/bin/$RESTORE_SCRIPT_NAME
3280
   echo "    rm -rf $USB_MOUNT" >> /usr/bin/$RESTORE_SCRIPT_NAME
3219
   echo 'fi' >> /usr/bin/$RESTORE_SCRIPT_NAME
3284
   echo 'fi' >> /usr/bin/$RESTORE_SCRIPT_NAME
3220
   echo '' >> /usr/bin/$RESTORE_SCRIPT_NAME
3285
   echo '' >> /usr/bin/$RESTORE_SCRIPT_NAME
3221
 
3286
 
3287
+  RESTORE_SUBDIR='root/'
3288
+  if [[ $BACKUP_TYPE != 'obnam' ]]; then
3289
+      RESTORE_SUBDIR='usb/backup/xmpp/'
3290
+  fi
3222
   echo "if [ -d $XMPP_DIRECTORY ]; then" >> /usr/bin/$RESTORE_SCRIPT_NAME
3291
   echo "if [ -d $XMPP_DIRECTORY ]; then" >> /usr/bin/$RESTORE_SCRIPT_NAME
3223
   echo '  echo "Restoring XMPP settings"' >> /usr/bin/$RESTORE_SCRIPT_NAME
3292
   echo '  echo "Restoring XMPP settings"' >> /usr/bin/$RESTORE_SCRIPT_NAME
3224
   restore_directory_from_usb /root/tempxmpp xmpp
3293
   restore_directory_from_usb /root/tempxmpp xmpp
3225
-  echo "  cp -r /root/tempxmpp/usb/backup/xmpp/lib/prosody/* $XMPP_DIRECTORY" >> /usr/bin/$RESTORE_SCRIPT_NAME
3294
+  echo "  cp -r /root/tempxmpp/${RESTORE_SUBDIR}lib/prosody/* $XMPP_DIRECTORY" >> /usr/bin/$RESTORE_SCRIPT_NAME
3226
   echo '  if [ ! "$?" = "0" ]; then' >> /usr/bin/$RESTORE_SCRIPT_NAME
3295
   echo '  if [ ! "$?" = "0" ]; then' >> /usr/bin/$RESTORE_SCRIPT_NAME
3227
   echo "    umount $USB_MOUNT" >> /usr/bin/$RESTORE_SCRIPT_NAME
3296
   echo "    umount $USB_MOUNT" >> /usr/bin/$RESTORE_SCRIPT_NAME
3228
   echo "    rm -rf $USB_MOUNT" >> /usr/bin/$RESTORE_SCRIPT_NAME
3297
   echo "    rm -rf $USB_MOUNT" >> /usr/bin/$RESTORE_SCRIPT_NAME
3261
   fi
3330
   fi
3262
 
3331
 
3263
   if grep -Fxq "install_owncloud" $COMPLETION_FILE; then
3332
   if grep -Fxq "install_owncloud" $COMPLETION_FILE; then
3333
+      RESTORE_SUBDIR='root/'
3334
+      if [[ $BACKUP_TYPE != 'obnam' ]]; then
3335
+          RESTORE_SUBDIR='usb/backup/owncloud2/'
3336
+      fi
3264
       BACKUP_INCLUDES_WEBSITES="yes"
3337
       BACKUP_INCLUDES_WEBSITES="yes"
3265
       restore_database owncloud $OWNCLOUD_DOMAIN_NAME
3338
       restore_database owncloud $OWNCLOUD_DOMAIN_NAME
3266
       echo "if [ -d $USB_MOUNT/backup/owncloud2 ]; then" >> /usr/bin/$RESTORE_SCRIPT_NAME
3339
       echo "if [ -d $USB_MOUNT/backup/owncloud2 ]; then" >> /usr/bin/$RESTORE_SCRIPT_NAME
3267
       restore_directory_from_usb /root/tempowncloud2 owncloud2
3340
       restore_directory_from_usb /root/tempowncloud2 owncloud2
3268
-      echo "  cp -r /root/tempowncloud2/usb/backup/owncloud2/owncloud/* /etc/owncloud/" >> /usr/bin/$RESTORE_SCRIPT_NAME
3341
+      echo "  cp -r /root/tempowncloud2/${RESTORE_SUBDIR}owncloud/* /etc/owncloud/" >> /usr/bin/$RESTORE_SCRIPT_NAME
3269
       echo '  if [ ! "$?" = "0" ]; then' >> /usr/bin/$RESTORE_SCRIPT_NAME
3342
       echo '  if [ ! "$?" = "0" ]; then' >> /usr/bin/$RESTORE_SCRIPT_NAME
3270
       echo "    umount $USB_MOUNT" >> /usr/bin/$RESTORE_SCRIPT_NAME
3343
       echo "    umount $USB_MOUNT" >> /usr/bin/$RESTORE_SCRIPT_NAME
3271
       echo "    rm -rf $USB_MOUNT" >> /usr/bin/$RESTORE_SCRIPT_NAME
3344
       echo "    rm -rf $USB_MOUNT" >> /usr/bin/$RESTORE_SCRIPT_NAME
3282
   fi
3355
   fi
3283
 
3356
 
3284
   if grep -Fxq "install_gogs" $COMPLETION_FILE; then
3357
   if grep -Fxq "install_gogs" $COMPLETION_FILE; then
3358
+      RESTORE_SUBDIR='root'
3359
+      if [[ $BACKUP_TYPE != 'obnam' ]]; then
3360
+          RESTORE_SUBDIR='usb/backup/gogs'
3361
+      fi
3285
       BACKUP_INCLUDES_WEBSITES="yes"
3362
       BACKUP_INCLUDES_WEBSITES="yes"
3286
       restore_database gogs $GIT_DOMAIN_NAME
3363
       restore_database gogs $GIT_DOMAIN_NAME
3287
       echo "if [ -d $USB_MOUNT/backup/gogs ]; then" >> /usr/bin/$RESTORE_SCRIPT_NAME
3364
       echo "if [ -d $USB_MOUNT/backup/gogs ]; then" >> /usr/bin/$RESTORE_SCRIPT_NAME
3289
       echo '  if [ ! -d /home/git/go/src/github.com/gogits/gogs/custom ]; then' >> /usr/bin/$RESTORE_SCRIPT_NAME
3366
       echo '  if [ ! -d /home/git/go/src/github.com/gogits/gogs/custom ]; then' >> /usr/bin/$RESTORE_SCRIPT_NAME
3290
       echo '    mkdir -p /home/git/go/src/github.com/gogits/gogs/custom' >> /usr/bin/$RESTORE_SCRIPT_NAME
3367
       echo '    mkdir -p /home/git/go/src/github.com/gogits/gogs/custom' >> /usr/bin/$RESTORE_SCRIPT_NAME
3291
       echo '  fi' >> /usr/bin/$RESTORE_SCRIPT_NAME
3368
       echo '  fi' >> /usr/bin/$RESTORE_SCRIPT_NAME
3292
-      echo "  cp -r /root/tempgogs/usb/backup/gogs/git/go/src/github.com/gogits/gogs/custom/* /home/git/go/src/github.com/gogits/gogs/custom" >> /usr/bin/$RESTORE_SCRIPT_NAME
3369
+      echo "  cp -r /root/tempgogs/${RESTORE_SUBDIR}/git/go/src/github.com/gogits/gogs/custom/* /home/git/go/src/github.com/gogits/gogs/custom" >> /usr/bin/$RESTORE_SCRIPT_NAME
3293
       echo '  if [ ! "$?" = "0" ]; then' >> /usr/bin/$RESTORE_SCRIPT_NAME
3370
       echo '  if [ ! "$?" = "0" ]; then' >> /usr/bin/$RESTORE_SCRIPT_NAME
3294
       echo "    umount $USB_MOUNT" >> /usr/bin/$RESTORE_SCRIPT_NAME
3371
       echo "    umount $USB_MOUNT" >> /usr/bin/$RESTORE_SCRIPT_NAME
3295
       echo "    rm -rf $USB_MOUNT" >> /usr/bin/$RESTORE_SCRIPT_NAME
3372
       echo "    rm -rf $USB_MOUNT" >> /usr/bin/$RESTORE_SCRIPT_NAME
3297
       echo '  fi' >> /usr/bin/$RESTORE_SCRIPT_NAME
3374
       echo '  fi' >> /usr/bin/$RESTORE_SCRIPT_NAME
3298
       echo '  echo "Restoring Gogs repos"' >> /usr/bin/$RESTORE_SCRIPT_NAME
3375
       echo '  echo "Restoring Gogs repos"' >> /usr/bin/$RESTORE_SCRIPT_NAME
3299
       restore_directory_from_usb /root/tempgogsrepos gogsrepos
3376
       restore_directory_from_usb /root/tempgogsrepos gogsrepos
3300
-      echo "  cp -r /root/tempgogsrepos/usb/backup/gogsrepos/git/gogs-repositories/* /home/git/gogs-repositories/" >> /usr/bin/$RESTORE_SCRIPT_NAME
3377
+      if [[ $BACKUP_TYPE != 'obnam' ]]; then
3378
+          RESTORE_SUBDIR='usb/backup/gogsrepos'
3379
+      fi
3380
+      echo "  cp -r /root/tempgogsrepos/${RESTORE_SUBDIR}/git/gogs-repositories/* /home/git/gogs-repositories/" >> /usr/bin/$RESTORE_SCRIPT_NAME
3301
       echo '  if [ ! "$?" = "0" ]; then' >> /usr/bin/$RESTORE_SCRIPT_NAME
3381
       echo '  if [ ! "$?" = "0" ]; then' >> /usr/bin/$RESTORE_SCRIPT_NAME
3302
       echo "    umount $USB_MOUNT" >> /usr/bin/$RESTORE_SCRIPT_NAME
3382
       echo "    umount $USB_MOUNT" >> /usr/bin/$RESTORE_SCRIPT_NAME
3303
       echo "    rm -rf $USB_MOUNT" >> /usr/bin/$RESTORE_SCRIPT_NAME
3383
       echo "    rm -rf $USB_MOUNT" >> /usr/bin/$RESTORE_SCRIPT_NAME
3308
       echo '  if [ ! -d /home/git/.ssh ]; then' >> /usr/bin/$RESTORE_SCRIPT_NAME
3388
       echo '  if [ ! -d /home/git/.ssh ]; then' >> /usr/bin/$RESTORE_SCRIPT_NAME
3309
       echo '    mkdir /home/git/.ssh' >> /usr/bin/$RESTORE_SCRIPT_NAME
3389
       echo '    mkdir /home/git/.ssh' >> /usr/bin/$RESTORE_SCRIPT_NAME
3310
       echo '  fi' >> /usr/bin/$RESTORE_SCRIPT_NAME
3390
       echo '  fi' >> /usr/bin/$RESTORE_SCRIPT_NAME
3311
-      echo "  cp -r /root/tempgogsssh/usb/backup/gogsssh/git/.ssh/* /home/git/.ssh/" >> /usr/bin/$RESTORE_SCRIPT_NAME
3391
+      if [[ $BACKUP_TYPE != 'obnam' ]]; then
3392
+          RESTORE_SUBDIR='usb/backup/gogsssh'
3393
+      fi
3394
+      echo "  cp -r /root/tempgogsssh/${RESTORE_SUBDIR}/git/.ssh/* /home/git/.ssh/" >> /usr/bin/$RESTORE_SCRIPT_NAME
3312
       echo '  if [ ! "$?" = "0" ]; then' >> /usr/bin/$RESTORE_SCRIPT_NAME
3395
       echo '  if [ ! "$?" = "0" ]; then' >> /usr/bin/$RESTORE_SCRIPT_NAME
3313
       echo "    umount $USB_MOUNT" >> /usr/bin/$RESTORE_SCRIPT_NAME
3396
       echo "    umount $USB_MOUNT" >> /usr/bin/$RESTORE_SCRIPT_NAME
3314
       echo "    rm -rf $USB_MOUNT" >> /usr/bin/$RESTORE_SCRIPT_NAME
3397
       echo "    rm -rf $USB_MOUNT" >> /usr/bin/$RESTORE_SCRIPT_NAME
3322
       echo '' >> /usr/bin/$RESTORE_SCRIPT_NAME
3405
       echo '' >> /usr/bin/$RESTORE_SCRIPT_NAME
3323
   fi
3406
   fi
3324
 
3407
 
3408
+  RESTORE_SUBDIR='root'
3409
+  if [[ $BACKUP_TYPE != 'obnam' ]]; then
3410
+      RESTORE_SUBDIR='usb/backup/wiki'
3411
+  fi
3325
   echo "if [ -d $USB_MOUNT/backup/wiki ]; then" >> /usr/bin/$RESTORE_SCRIPT_NAME
3412
   echo "if [ -d $USB_MOUNT/backup/wiki ]; then" >> /usr/bin/$RESTORE_SCRIPT_NAME
3326
   echo '  echo "Restoring Wiki installation"' >> /usr/bin/$RESTORE_SCRIPT_NAME
3413
   echo '  echo "Restoring Wiki installation"' >> /usr/bin/$RESTORE_SCRIPT_NAME
3327
   restore_directory_from_usb /root/tempwiki wiki
3414
   restore_directory_from_usb /root/tempwiki wiki
3328
-  echo "  cp -r /root/tempwiki/usb/backup/wiki/lib/dokuwiki/* /var/lib/dokuwiki/" >> /usr/bin/$RESTORE_SCRIPT_NAME
3415
+  echo "  cp -r /root/tempwiki/${RESTORE_SUBDIR}/lib/dokuwiki/* /var/lib/dokuwiki/" >> /usr/bin/$RESTORE_SCRIPT_NAME
3329
   echo '  if [ ! "$?" = "0" ]; then' >> /usr/bin/$RESTORE_SCRIPT_NAME
3416
   echo '  if [ ! "$?" = "0" ]; then' >> /usr/bin/$RESTORE_SCRIPT_NAME
3330
   echo "    umount $USB_MOUNT" >> /usr/bin/$RESTORE_SCRIPT_NAME
3417
   echo "    umount $USB_MOUNT" >> /usr/bin/$RESTORE_SCRIPT_NAME
3331
   echo "    rm -rf $USB_MOUNT" >> /usr/bin/$RESTORE_SCRIPT_NAME
3418
   echo "    rm -rf $USB_MOUNT" >> /usr/bin/$RESTORE_SCRIPT_NAME
3332
   echo '    exit 868' >> /usr/bin/$RESTORE_SCRIPT_NAME
3419
   echo '    exit 868' >> /usr/bin/$RESTORE_SCRIPT_NAME
3333
   echo '  fi' >> /usr/bin/$RESTORE_SCRIPT_NAME
3420
   echo '  fi' >> /usr/bin/$RESTORE_SCRIPT_NAME
3334
   restore_directory_from_usb /root/tempwiki2 wiki2
3421
   restore_directory_from_usb /root/tempwiki2 wiki2
3335
-  echo "  cp -r /root/tempwiki2/usb/backup/wiki2/dokuwiki/* /etc/dokuwiki/" >> /usr/bin/$RESTORE_SCRIPT_NAME
3422
+  if [[ $BACKUP_TYPE != 'obnam' ]]; then
3423
+      RESTORE_SUBDIR='usb/backup/wiki2'
3424
+  fi
3425
+  echo "  cp -r /root/tempwiki2/${RESTORE_SUBDIR}/dokuwiki/* /etc/dokuwiki/" >> /usr/bin/$RESTORE_SCRIPT_NAME
3336
   echo '  if [ ! "$?" = "0" ]; then' >> /usr/bin/$RESTORE_SCRIPT_NAME
3426
   echo '  if [ ! "$?" = "0" ]; then' >> /usr/bin/$RESTORE_SCRIPT_NAME
3337
   echo "    umount $USB_MOUNT" >> /usr/bin/$RESTORE_SCRIPT_NAME
3427
   echo "    umount $USB_MOUNT" >> /usr/bin/$RESTORE_SCRIPT_NAME
3338
   echo "    rm -rf $USB_MOUNT" >> /usr/bin/$RESTORE_SCRIPT_NAME
3428
   echo "    rm -rf $USB_MOUNT" >> /usr/bin/$RESTORE_SCRIPT_NAME
3348
   echo 'fi' >> /usr/bin/$RESTORE_SCRIPT_NAME
3438
   echo 'fi' >> /usr/bin/$RESTORE_SCRIPT_NAME
3349
   echo '' >> /usr/bin/$RESTORE_SCRIPT_NAME
3439
   echo '' >> /usr/bin/$RESTORE_SCRIPT_NAME
3350
 
3440
 
3441
+  RESTORE_SUBDIR='root'
3442
+  if [[ $BACKUP_TYPE != 'obnam' ]]; then
3443
+      RESTORE_SUBDIR='usb/backup/blog'
3444
+  fi
3351
   echo "if [ -d $USB_MOUNT/backup/blog ]; then" >> /usr/bin/$RESTORE_SCRIPT_NAME
3445
   echo "if [ -d $USB_MOUNT/backup/blog ]; then" >> /usr/bin/$RESTORE_SCRIPT_NAME
3352
   echo '  echo "Restoring blog installation"' >> /usr/bin/$RESTORE_SCRIPT_NAME
3446
   echo '  echo "Restoring blog installation"' >> /usr/bin/$RESTORE_SCRIPT_NAME
3353
   restore_directory_from_usb /root/tempblog blog
3447
   restore_directory_from_usb /root/tempblog blog
3354
   echo "  rm -rf /var/www/$FULLBLOG_DOMAIN_NAME/htdocs" >> /usr/bin/$RESTORE_SCRIPT_NAME
3448
   echo "  rm -rf /var/www/$FULLBLOG_DOMAIN_NAME/htdocs" >> /usr/bin/$RESTORE_SCRIPT_NAME
3355
-  echo "  cp -r /root/tempblog/usb/backup/blog/www/$FULLBLOG_DOMAIN_NAME/htdocs /var/www/$FULLBLOG_DOMAIN_NAME/" >> /usr/bin/$RESTORE_SCRIPT_NAME
3449
+  echo "  cp -r /root/tempblog/${RESTORE_SUBDIR}/www/$FULLBLOG_DOMAIN_NAME/htdocs /var/www/$FULLBLOG_DOMAIN_NAME/" >> /usr/bin/$RESTORE_SCRIPT_NAME
3356
   echo '  if [ ! "$?" = "0" ]; then' >> /usr/bin/$RESTORE_SCRIPT_NAME
3450
   echo '  if [ ! "$?" = "0" ]; then' >> /usr/bin/$RESTORE_SCRIPT_NAME
3357
   echo "    umount $USB_MOUNT" >> /usr/bin/$RESTORE_SCRIPT_NAME
3451
   echo "    umount $USB_MOUNT" >> /usr/bin/$RESTORE_SCRIPT_NAME
3358
   echo "    rm -rf $USB_MOUNT" >> /usr/bin/$RESTORE_SCRIPT_NAME
3452
   echo "    rm -rf $USB_MOUNT" >> /usr/bin/$RESTORE_SCRIPT_NAME
3373
   echo 'fi' >> /usr/bin/$RESTORE_SCRIPT_NAME
3467
   echo 'fi' >> /usr/bin/$RESTORE_SCRIPT_NAME
3374
   echo '' >> /usr/bin/$RESTORE_SCRIPT_NAME
3468
   echo '' >> /usr/bin/$RESTORE_SCRIPT_NAME
3375
 
3469
 
3470
+  RESTORE_SUBDIR='root'
3471
+  if [[ $BACKUP_TYPE != 'obnam' ]]; then
3472
+      RESTORE_SUBDIR='usb/backup/cjdns'
3473
+  fi
3376
   echo "if [ -d $USB_MOUNT/backup/cjdns ]; then" >> /usr/bin/$RESTORE_SCRIPT_NAME
3474
   echo "if [ -d $USB_MOUNT/backup/cjdns ]; then" >> /usr/bin/$RESTORE_SCRIPT_NAME
3377
   echo '  echo "Restoring cjdns installation"' >> /usr/bin/$RESTORE_SCRIPT_NAME
3475
   echo '  echo "Restoring cjdns installation"' >> /usr/bin/$RESTORE_SCRIPT_NAME
3378
   restore_directory_from_usb /root/tempcjdns cjdns
3476
   restore_directory_from_usb /root/tempcjdns cjdns
3379
   echo "  rm -rf /etc/cjdns" >> /usr/bin/$RESTORE_SCRIPT_NAME
3477
   echo "  rm -rf /etc/cjdns" >> /usr/bin/$RESTORE_SCRIPT_NAME
3380
-  echo "  cp -r /root/tempcjdns/usb/backup/cjdns/cjdns /etc/" >> /usr/bin/$RESTORE_SCRIPT_NAME
3478
+  echo "  cp -r /root/tempcjdns/${RESTORE_SUBDIR}/cjdns /etc/" >> /usr/bin/$RESTORE_SCRIPT_NAME
3381
   echo '  if [ ! "$?" = "0" ]; then' >> /usr/bin/$RESTORE_SCRIPT_NAME
3479
   echo '  if [ ! "$?" = "0" ]; then' >> /usr/bin/$RESTORE_SCRIPT_NAME
3382
   echo "    umount $USB_MOUNT" >> /usr/bin/$RESTORE_SCRIPT_NAME
3480
   echo "    umount $USB_MOUNT" >> /usr/bin/$RESTORE_SCRIPT_NAME
3383
   echo "    rm -rf $USB_MOUNT" >> /usr/bin/$RESTORE_SCRIPT_NAME
3481
   echo "    rm -rf $USB_MOUNT" >> /usr/bin/$RESTORE_SCRIPT_NAME
3387
   echo 'fi' >> /usr/bin/$RESTORE_SCRIPT_NAME
3485
   echo 'fi' >> /usr/bin/$RESTORE_SCRIPT_NAME
3388
   echo '' >> /usr/bin/$RESTORE_SCRIPT_NAME
3486
   echo '' >> /usr/bin/$RESTORE_SCRIPT_NAME
3389
 
3487
 
3488
+  RESTORE_SUBDIR='root'
3489
+  if [[ $BACKUP_TYPE != 'obnam' ]]; then
3490
+      RESTORE_SUBDIR='usb/backup/mail'
3491
+  fi
3390
   echo "if [ -d $USB_MOUNT/backup/mail ]; then" >> /usr/bin/$RESTORE_SCRIPT_NAME
3492
   echo "if [ -d $USB_MOUNT/backup/mail ]; then" >> /usr/bin/$RESTORE_SCRIPT_NAME
3391
   echo '  echo "Restoring emails"' >> /usr/bin/$RESTORE_SCRIPT_NAME
3493
   echo '  echo "Restoring emails"' >> /usr/bin/$RESTORE_SCRIPT_NAME
3392
   restore_directory_from_usb /root/tempmail mail
3494
   restore_directory_from_usb /root/tempmail mail
3393
   echo '  if [ ! -d /home/$MY_USERNAME/Maildir ]; then' >> /usr/bin/$RESTORE_SCRIPT_NAME
3495
   echo '  if [ ! -d /home/$MY_USERNAME/Maildir ]; then' >> /usr/bin/$RESTORE_SCRIPT_NAME
3394
   echo '    mkdir /home/$MY_USERNAME/Maildir' >> /usr/bin/$RESTORE_SCRIPT_NAME
3496
   echo '    mkdir /home/$MY_USERNAME/Maildir' >> /usr/bin/$RESTORE_SCRIPT_NAME
3395
   echo '  fi' >> /usr/bin/$RESTORE_SCRIPT_NAME
3497
   echo '  fi' >> /usr/bin/$RESTORE_SCRIPT_NAME
3396
-  echo '  tar -xzvf /root/tempmail/usb/backup/mail/backupemail/maildir.tar.gz -C /' >> /usr/bin/$RESTORE_SCRIPT_NAME
3498
+  echo "  tar -xzvf /root/tempmail/${RESTORE_SUBDIR}/backupemail/maildir.tar.gz -C /" >> /usr/bin/$RESTORE_SCRIPT_NAME
3397
   echo '  if [ ! "$?" = "0" ]; then' >> /usr/bin/$RESTORE_SCRIPT_NAME
3499
   echo '  if [ ! "$?" = "0" ]; then' >> /usr/bin/$RESTORE_SCRIPT_NAME
3398
   echo "    umount $USB_MOUNT" >> /usr/bin/$RESTORE_SCRIPT_NAME
3500
   echo "    umount $USB_MOUNT" >> /usr/bin/$RESTORE_SCRIPT_NAME
3399
   echo "    rm -rf $USB_MOUNT" >> /usr/bin/$RESTORE_SCRIPT_NAME
3501
   echo "    rm -rf $USB_MOUNT" >> /usr/bin/$RESTORE_SCRIPT_NAME
3403
   echo 'fi' >> /usr/bin/$RESTORE_SCRIPT_NAME
3505
   echo 'fi' >> /usr/bin/$RESTORE_SCRIPT_NAME
3404
   echo '' >> /usr/bin/$RESTORE_SCRIPT_NAME
3506
   echo '' >> /usr/bin/$RESTORE_SCRIPT_NAME
3405
 
3507
 
3508
+  RESTORE_SUBDIR='root'
3509
+  if [[ $BACKUP_TYPE != 'obnam' ]]; then
3510
+      RESTORE_SUBDIR='usb/backup/dlna'
3511
+  fi
3406
   echo "if [ -d /var/cache/minidlna ]; then" >> /usr/bin/$RESTORE_SCRIPT_NAME
3512
   echo "if [ -d /var/cache/minidlna ]; then" >> /usr/bin/$RESTORE_SCRIPT_NAME
3407
   echo "  if [ -d $USB_MOUNT/backup/dlna ]; then" >> /usr/bin/$RESTORE_SCRIPT_NAME
3513
   echo "  if [ -d $USB_MOUNT/backup/dlna ]; then" >> /usr/bin/$RESTORE_SCRIPT_NAME
3408
   echo '    echo "Restoring DLNA cache"' >> /usr/bin/$RESTORE_SCRIPT_NAME
3514
   echo '    echo "Restoring DLNA cache"' >> /usr/bin/$RESTORE_SCRIPT_NAME
3409
   restore_directory_from_usb /root/tempdlna dlna
3515
   restore_directory_from_usb /root/tempdlna dlna
3410
-  echo "    cp -r /root/tempdlna/usb/backup/dlna/cache/minidlna/* /var/cache/minidlna/" >> /usr/bin/$RESTORE_SCRIPT_NAME
3516
+  echo "    cp -r /root/tempdlna/${RESTORE_SUBDIR}/cache/minidlna/* /var/cache/minidlna/" >> /usr/bin/$RESTORE_SCRIPT_NAME
3411
   echo '    if [ ! "$?" = "0" ]; then' >> /usr/bin/$RESTORE_SCRIPT_NAME
3517
   echo '    if [ ! "$?" = "0" ]; then' >> /usr/bin/$RESTORE_SCRIPT_NAME
3412
   echo "      umount $USB_MOUNT" >> /usr/bin/$RESTORE_SCRIPT_NAME
3518
   echo "      umount $USB_MOUNT" >> /usr/bin/$RESTORE_SCRIPT_NAME
3413
   echo "      rm -rf $USB_MOUNT" >> /usr/bin/$RESTORE_SCRIPT_NAME
3519
   echo "      rm -rf $USB_MOUNT" >> /usr/bin/$RESTORE_SCRIPT_NAME
3418
   echo 'fi' >> /usr/bin/$RESTORE_SCRIPT_NAME
3524
   echo 'fi' >> /usr/bin/$RESTORE_SCRIPT_NAME
3419
   echo '' >> /usr/bin/$RESTORE_SCRIPT_NAME
3525
   echo '' >> /usr/bin/$RESTORE_SCRIPT_NAME
3420
 
3526
 
3527
+  RESTORE_SUBDIR='root'
3528
+  if [[ $BACKUP_TYPE != 'obnam' ]]; then
3529
+      RESTORE_SUBDIR='usb/backup/voip'
3530
+  fi
3421
   echo "if [ -d $USB_MOUNT/backup/voip ]; then" >> /usr/bin/$RESTORE_SCRIPT_NAME
3531
   echo "if [ -d $USB_MOUNT/backup/voip ]; then" >> /usr/bin/$RESTORE_SCRIPT_NAME
3422
   echo '  echo "Restoring VoIP settings"' >> /usr/bin/$RESTORE_SCRIPT_NAME
3532
   echo '  echo "Restoring VoIP settings"' >> /usr/bin/$RESTORE_SCRIPT_NAME
3423
   restore_directory_from_usb /root/tempvoip voip
3533
   restore_directory_from_usb /root/tempvoip voip
3424
-  echo -n '  cp -f /root/tempvoip/usb/backup/voip/$MY_USERNAME/tempbackup/' >> /usr/bin/$RESTORE_SCRIPT_NAME
3534
+  echo -n "  cp -f /root/tempvoip/${RESTORE_SUBDIR}/" >> /usr/bin/$RESTORE_SCRIPT_NAME
3535
+  echo -n '$MY_USERNAME/tempbackup/' >> /usr/bin/$RESTORE_SCRIPT_NAME
3425
   echo "$VOIP_CONFIG_FILE /etc/" >> /usr/bin/$RESTORE_SCRIPT_NAME
3536
   echo "$VOIP_CONFIG_FILE /etc/" >> /usr/bin/$RESTORE_SCRIPT_NAME
3426
-  echo -n '  cp -f /root/tempvoip/usb/backup/voip/$MY_USERNAME/tempbackup/' >> /usr/bin/$RESTORE_SCRIPT_NAME
3537
+  echo -n "  cp -f /root/tempvoip/${RESTORE_SUBDIR}/" >> /usr/bin/$RESTORE_SCRIPT_NAME
3538
+  echo -n '$MY_USERNAME/tempbackup/' >> /usr/bin/$RESTORE_SCRIPT_NAME
3427
   echo "$VOIP_DATABASE /var/lib/mumble-server/" >> /usr/bin/$RESTORE_SCRIPT_NAME
3539
   echo "$VOIP_DATABASE /var/lib/mumble-server/" >> /usr/bin/$RESTORE_SCRIPT_NAME
3428
   echo '  if [ ! "$?" = "0" ]; then' >> /usr/bin/$RESTORE_SCRIPT_NAME
3540
   echo '  if [ ! "$?" = "0" ]; then' >> /usr/bin/$RESTORE_SCRIPT_NAME
3429
   echo "    umount $USB_MOUNT" >> /usr/bin/$RESTORE_SCRIPT_NAME
3541
   echo "    umount $USB_MOUNT" >> /usr/bin/$RESTORE_SCRIPT_NAME
4115
 }
4227
 }
4116
 
4228
 
4117
 function restore_database_from_friend {
4229
 function restore_database_from_friend {
4230
+  RESTORE_SUBDIR='root'
4231
+  if [[ $BACKUP_TYPE != 'obnam' ]]; then
4232
+      RESTORE_SUBDIR="remoterestore/backup/${1}data"
4233
+  fi
4118
   echo '' >> /usr/bin/$RESTORE_FROM_FRIEND_SCRIPT_NAME
4234
   echo '' >> /usr/bin/$RESTORE_FROM_FRIEND_SCRIPT_NAME
4119
   echo "if [ -d $SERVER_DIRECTORY/backup/${1} ]; then" >> /usr/bin/$RESTORE_FROM_FRIEND_SCRIPT_NAME
4235
   echo "if [ -d $SERVER_DIRECTORY/backup/${1} ]; then" >> /usr/bin/$RESTORE_FROM_FRIEND_SCRIPT_NAME
4120
   echo "  echo \"Restoring ${1} database\"" >> /usr/bin/$RESTORE_FROM_FRIEND_SCRIPT_NAME
4236
   echo "  echo \"Restoring ${1} database\"" >> /usr/bin/$RESTORE_FROM_FRIEND_SCRIPT_NAME
4121
   restore_directory_from_friend /root/temp${1}data ${1}data
4237
   restore_directory_from_friend /root/temp${1}data ${1}data
4122
-  echo "  if [ ! -f /root/temp${1}data/remoterestore/backup/${1}data/temp${1}data/${1}.sql ]; then" >> /usr/bin/$RESTORE_FROM_FRIEND_SCRIPT_NAME
4238
+  echo "  if [ ! -f /root/temp${1}data/${RESTORE_SUBDIR}/temp${1}data/${1}.sql ]; then" >> /usr/bin/$RESTORE_FROM_FRIEND_SCRIPT_NAME
4123
   echo "    echo \"Unable to restore ${1} database\"" >> /usr/bin/$RESTORE_FROM_FRIEND_SCRIPT_NAME
4239
   echo "    echo \"Unable to restore ${1} database\"" >> /usr/bin/$RESTORE_FROM_FRIEND_SCRIPT_NAME
4124
   echo "    rm -rf /root/temp${1}data" >> /usr/bin/$RESTORE_FROM_FRIEND_SCRIPT_NAME
4240
   echo "    rm -rf /root/temp${1}data" >> /usr/bin/$RESTORE_FROM_FRIEND_SCRIPT_NAME
4125
   echo '    exit 503' >> /usr/bin/$RESTORE_FROM_FRIEND_SCRIPT_NAME
4241
   echo '    exit 503' >> /usr/bin/$RESTORE_FROM_FRIEND_SCRIPT_NAME
4126
   echo '  fi' >> /usr/bin/$RESTORE_FROM_FRIEND_SCRIPT_NAME
4242
   echo '  fi' >> /usr/bin/$RESTORE_FROM_FRIEND_SCRIPT_NAME
4127
   echo -n '  mysqlsuccess=$(mysql -u root --password=$DATABASE_PASSWORD ' >> /usr/bin/$RESTORE_FROM_FRIEND_SCRIPT_NAME
4243
   echo -n '  mysqlsuccess=$(mysql -u root --password=$DATABASE_PASSWORD ' >> /usr/bin/$RESTORE_FROM_FRIEND_SCRIPT_NAME
4128
-  echo "${1} -o < /root/temp${1}data/remoterestore/backup/${1}data/temp${1}data/${1}.sql)" >> /usr/bin/$RESTORE_FROM_FRIEND_SCRIPT_NAME
4244
+  echo "${1} -o < /root/temp${1}data/${RESTORE_SUBDIR}/temp${1}data/${1}.sql)" >> /usr/bin/$RESTORE_FROM_FRIEND_SCRIPT_NAME
4129
   echo '  if [ ! "$?" = "0" ]; then' >> /usr/bin/$RESTORE_FROM_FRIEND_SCRIPT_NAME
4245
   echo '  if [ ! "$?" = "0" ]; then' >> /usr/bin/$RESTORE_FROM_FRIEND_SCRIPT_NAME
4130
   echo '    echo "$mysqlsuccess"' >> /usr/bin/$RESTORE_FROM_FRIEND_SCRIPT_NAME
4246
   echo '    echo "$mysqlsuccess"' >> /usr/bin/$RESTORE_FROM_FRIEND_SCRIPT_NAME
4131
   echo '    exit 964' >> /usr/bin/$RESTORE_FROM_FRIEND_SCRIPT_NAME
4247
   echo '    exit 964' >> /usr/bin/$RESTORE_FROM_FRIEND_SCRIPT_NAME
4132
   echo '  fi' >> /usr/bin/$RESTORE_FROM_FRIEND_SCRIPT_NAME
4248
   echo '  fi' >> /usr/bin/$RESTORE_FROM_FRIEND_SCRIPT_NAME
4133
-  echo "  shred -zu /root/temp${1}data/remoterestore/backup/${1}data/temp${1}data/*" >> /usr/bin/$RESTORE_FROM_FRIEND_SCRIPT_NAME
4249
+  echo "  shred -zu /root/temp${1}data/${RESTORE_SUBDIR}/temp${1}data/*" >> /usr/bin/$RESTORE_FROM_FRIEND_SCRIPT_NAME
4134
   echo "  rm -rf /root/temp${1}data" >> /usr/bin/$RESTORE_FROM_FRIEND_SCRIPT_NAME
4250
   echo "  rm -rf /root/temp${1}data" >> /usr/bin/$RESTORE_FROM_FRIEND_SCRIPT_NAME
4135
   echo "  echo \"Restoring ${1} installation\"" >> /usr/bin/$RESTORE_FROM_FRIEND_SCRIPT_NAME
4251
   echo "  echo \"Restoring ${1} installation\"" >> /usr/bin/$RESTORE_FROM_FRIEND_SCRIPT_NAME
4136
   restore_directory_from_friend /root/temp${1} ${1}
4252
   restore_directory_from_friend /root/temp${1} ${1}
4253
+  if [[ $BACKUP_TYPE != 'obnam' ]]; then
4254
+      RESTORE_SUBDIR="remoterestore/backup/${1}"
4255
+  fi
4137
   echo "  if [ ${1} ]; then" >> /usr/bin/$RESTORE_FROM_FRIEND_SCRIPT_NAME
4256
   echo "  if [ ${1} ]; then" >> /usr/bin/$RESTORE_FROM_FRIEND_SCRIPT_NAME
4138
   echo "    if [ -d /var/www/${2}/htdocs ]; then" >> /usr/bin/$RESTORE_FROM_FRIEND_SCRIPT_NAME
4257
   echo "    if [ -d /var/www/${2}/htdocs ]; then" >> /usr/bin/$RESTORE_FROM_FRIEND_SCRIPT_NAME
4139
   echo "      rm -rf /var/www/${2}/htdocs" >> /usr/bin/$RESTORE_FROM_FRIEND_SCRIPT_NAME
4258
   echo "      rm -rf /var/www/${2}/htdocs" >> /usr/bin/$RESTORE_FROM_FRIEND_SCRIPT_NAME
4140
-  echo "      mv /root/temp${1}/remoterestore/backup/${1}/www/${2}/htdocs /var/www/${2}/" >> /usr/bin/$RESTORE_FROM_FRIEND_SCRIPT_NAME
4259
+  echo "      mv /root/temp${1}/${RESTORE_SUBDIR}/www/${2}/htdocs /var/www/${2}/" >> /usr/bin/$RESTORE_FROM_FRIEND_SCRIPT_NAME
4141
   echo '      if [ ! "$?" = "0" ]; then' >> /usr/bin/$RESTORE_FROM_FRIEND_SCRIPT_NAME
4260
   echo '      if [ ! "$?" = "0" ]; then' >> /usr/bin/$RESTORE_FROM_FRIEND_SCRIPT_NAME
4142
   echo '        exit 683' >> /usr/bin/$RESTORE_FROM_FRIEND_SCRIPT_NAME
4261
   echo '        exit 683' >> /usr/bin/$RESTORE_FROM_FRIEND_SCRIPT_NAME
4143
   echo '      fi' >> /usr/bin/$RESTORE_FROM_FRIEND_SCRIPT_NAME
4262
   echo '      fi' >> /usr/bin/$RESTORE_FROM_FRIEND_SCRIPT_NAME
4251
   echo '' >> /usr/bin/$RESTORE_FROM_FRIEND_SCRIPT_NAME
4370
   echo '' >> /usr/bin/$RESTORE_FROM_FRIEND_SCRIPT_NAME
4252
 
4371
 
4253
   echo 'if [ -d $SERVER_DIRECTORY/backup/mariadb ]; then' >> /usr/bin/$RESTORE_FROM_FRIEND_SCRIPT_NAME
4372
   echo 'if [ -d $SERVER_DIRECTORY/backup/mariadb ]; then' >> /usr/bin/$RESTORE_FROM_FRIEND_SCRIPT_NAME
4373
+  RESTORE_SUBDIR='root/'
4374
+  if [[ $BACKUP_TYPE != 'obnam' ]]; then
4375
+      RESTORE_SUBDIR='remoterestore/backup/mariadb/'
4376
+  fi
4254
   echo '  echo "Restoring mysql settings"' >> /usr/bin/$RESTORE_FROM_FRIEND_SCRIPT_NAME
4377
   echo '  echo "Restoring mysql settings"' >> /usr/bin/$RESTORE_FROM_FRIEND_SCRIPT_NAME
4255
   restore_directory_from_friend /root/tempmariadb mariadb
4378
   restore_directory_from_friend /root/tempmariadb mariadb
4256
   echo '  echo "Get the MariaDB password from the backup"' >> /usr/bin/$RESTORE_FROM_FRIEND_SCRIPT_NAME
4379
   echo '  echo "Get the MariaDB password from the backup"' >> /usr/bin/$RESTORE_FROM_FRIEND_SCRIPT_NAME
4257
-  echo '  if [ ! -f /root/tempmariadb/remoterestore/backup/mariadb/tempmariadb/db ]; then' >> /usr/bin/$RESTORE_FROM_FRIEND_SCRIPT_NAME
4380
+  echo "  if [ ! -f /root/tempmariadb/${RESTORE_SUBDIR}tempmariadb/db ]; then" >> /usr/bin/$RESTORE_FROM_FRIEND_SCRIPT_NAME
4258
   echo '    echo "MariaDB password file not found"' >> /usr/bin/$RESTORE_FROM_FRIEND_SCRIPT_NAME
4381
   echo '    echo "MariaDB password file not found"' >> /usr/bin/$RESTORE_FROM_FRIEND_SCRIPT_NAME
4259
   echo '    exit 495' >> /usr/bin/$RESTORE_FROM_FRIEND_SCRIPT_NAME
4382
   echo '    exit 495' >> /usr/bin/$RESTORE_FROM_FRIEND_SCRIPT_NAME
4260
   echo '  fi' >> /usr/bin/$RESTORE_FROM_FRIEND_SCRIPT_NAME
4383
   echo '  fi' >> /usr/bin/$RESTORE_FROM_FRIEND_SCRIPT_NAME
4261
-  echo '  BACKUP_MARIADB_PASSWORD=$(cat /root/tempmariadb/remoterestore/backup/mariadb/tempmariadb/db)' >> /usr/bin/$RESTORE_FROM_FRIEND_SCRIPT_NAME
4384
+  echo -n '  BACKUP_MARIADB_PASSWORD=$(cat /root/tempmariadb/' >> /usr/bin/$RESTORE_FROM_FRIEND_SCRIPT_NAME
4385
+  echo "${RESTORE_SUBDIR}tempmariadb/db)" >> /usr/bin/$RESTORE_FROM_FRIEND_SCRIPT_NAME
4262
   echo '  if [[ $BACKUP_MARIADB_PASSWORD != $DATABASE_PASSWORD ]]; then' >> /usr/bin/$RESTORE_FROM_FRIEND_SCRIPT_NAME
4386
   echo '  if [[ $BACKUP_MARIADB_PASSWORD != $DATABASE_PASSWORD ]]; then' >> /usr/bin/$RESTORE_FROM_FRIEND_SCRIPT_NAME
4263
   echo '    echo "Restore the MariaDB user table"' >> /usr/bin/$RESTORE_FROM_FRIEND_SCRIPT_NAME
4387
   echo '    echo "Restore the MariaDB user table"' >> /usr/bin/$RESTORE_FROM_FRIEND_SCRIPT_NAME
4264
-  echo '    mysqlsuccess=$(mysql -u root --password=$DATABASE_PASSWORD mysql -o < /root/tempmariadb/remoterestore/backup/mariadb/tempmariadb/mysql.sql)' >> /usr/bin/$RESTORE_FROM_FRIEND_SCRIPT_NAME
4388
+  echo -n '    mysqlsuccess=$(mysql -u root --password=$DATABASE_PASSWORD mysql -o < ' >> /usr/bin/$RESTORE_FROM_FRIEND_SCRIPT_NAME
4389
+  echo "/root/tempmariadb/${RESTORE_SUBDIR}tempmariadb/mysql.sql)" >> /usr/bin/$RESTORE_FROM_FRIEND_SCRIPT_NAME
4265
   echo '    if [ ! "$?" = "0" ]; then' >> /usr/bin/$RESTORE_FROM_FRIEND_SCRIPT_NAME
4390
   echo '    if [ ! "$?" = "0" ]; then' >> /usr/bin/$RESTORE_FROM_FRIEND_SCRIPT_NAME
4266
   echo '      echo "Try again using the password obtained from backup"' >> /usr/bin/$RESTORE_FROM_FRIEND_SCRIPT_NAME
4391
   echo '      echo "Try again using the password obtained from backup"' >> /usr/bin/$RESTORE_FROM_FRIEND_SCRIPT_NAME
4267
-  echo '      mysqlsuccess=$(mysql -u root --password=$BACKUP_MARIADB_PASSWORD mysql -o < /root/tempmariadb/remoterestore/backup/mariadb/tempmariadb/mysql.sql)' >> /usr/bin/$RESTORE_FROM_FRIEND_SCRIPT_NAME
4392
+  echo -n '      mysqlsuccess=$(mysql -u root --password=$BACKUP_MARIADB_PASSWORD mysql -o < ' >> /usr/bin/$RESTORE_FROM_FRIEND_SCRIPT_NAME
4393
+  echo "/root/tempmariadb/${RESTORE_SUBDIR}tempmariadb/mysql.sql)" >> /usr/bin/$RESTORE_FROM_FRIEND_SCRIPT_NAME
4268
   echo '    fi' >> /usr/bin/$RESTORE_FROM_FRIEND_SCRIPT_NAME
4394
   echo '    fi' >> /usr/bin/$RESTORE_FROM_FRIEND_SCRIPT_NAME
4269
   echo '    if [ ! "$?" = "0" ]; then' >> /usr/bin/$RESTORE_FROM_FRIEND_SCRIPT_NAME
4395
   echo '    if [ ! "$?" = "0" ]; then' >> /usr/bin/$RESTORE_FROM_FRIEND_SCRIPT_NAME
4270
   echo '      echo "$mysqlsuccess"' >> /usr/bin/$RESTORE_FROM_FRIEND_SCRIPT_NAME
4396
   echo '      echo "$mysqlsuccess"' >> /usr/bin/$RESTORE_FROM_FRIEND_SCRIPT_NAME
4275
   echo '    echo "Change the MariaDB password to the backup version"' >> /usr/bin/$RESTORE_FROM_FRIEND_SCRIPT_NAME
4401
   echo '    echo "Change the MariaDB password to the backup version"' >> /usr/bin/$RESTORE_FROM_FRIEND_SCRIPT_NAME
4276
   echo '    DATABASE_PASSWORD=$BACKUP_MARIADB_PASSWORD' >> /usr/bin/$RESTORE_FROM_FRIEND_SCRIPT_NAME
4402
   echo '    DATABASE_PASSWORD=$BACKUP_MARIADB_PASSWORD' >> /usr/bin/$RESTORE_FROM_FRIEND_SCRIPT_NAME
4277
   echo '  fi' >> /usr/bin/$RESTORE_FROM_FRIEND_SCRIPT_NAME
4403
   echo '  fi' >> /usr/bin/$RESTORE_FROM_FRIEND_SCRIPT_NAME
4278
-  echo '  shred -zu /root/tempmariadb/remoterestore/backup/mariadb/tempmariadb/db' >> /usr/bin/$RESTORE_FROM_FRIEND_SCRIPT_NAME
4404
+  echo "  shred -zu /root/tempmariadb/${RESTORE_SUBDIR}tempmariadb/db" >> /usr/bin/$RESTORE_FROM_FRIEND_SCRIPT_NAME
4279
   echo '  rm -rf /root/tempmariadb' >> /usr/bin/$RESTORE_FROM_FRIEND_SCRIPT_NAME
4405
   echo '  rm -rf /root/tempmariadb' >> /usr/bin/$RESTORE_FROM_FRIEND_SCRIPT_NAME
4280
   echo '' >> /usr/bin/$RESTORE_FROM_FRIEND_SCRIPT_NAME
4406
   echo '' >> /usr/bin/$RESTORE_FROM_FRIEND_SCRIPT_NAME
4281
   echo '  # Change database password file' >> /usr/bin/$RESTORE_FROM_FRIEND_SCRIPT_NAME
4407
   echo '  # Change database password file' >> /usr/bin/$RESTORE_FROM_FRIEND_SCRIPT_NAME
4285
   echo 'fi' >> /usr/bin/$RESTORE_FROM_FRIEND_SCRIPT_NAME
4411
   echo 'fi' >> /usr/bin/$RESTORE_FROM_FRIEND_SCRIPT_NAME
4286
   echo '' >> /usr/bin/$RESTORE_FROM_FRIEND_SCRIPT_NAME
4412
   echo '' >> /usr/bin/$RESTORE_FROM_FRIEND_SCRIPT_NAME
4287
 
4413
 
4414
+  RESTORE_SUBDIR='root/'
4415
+  if [[ $BACKUP_TYPE != 'obnam' ]]; then
4416
+      RESTORE_SUBDIR='remoterestore/backup/mutt/'
4417
+  fi
4288
   echo 'if [ -d $SERVER_DIRECTORY/backup/mutt ]; then' >> /usr/bin/$RESTORE_FROM_FRIEND_SCRIPT_NAME
4418
   echo 'if [ -d $SERVER_DIRECTORY/backup/mutt ]; then' >> /usr/bin/$RESTORE_FROM_FRIEND_SCRIPT_NAME
4289
   echo '  echo "Restoring Mutt settings"' >> /usr/bin/$RESTORE_FROM_FRIEND_SCRIPT_NAME
4419
   echo '  echo "Restoring Mutt settings"' >> /usr/bin/$RESTORE_FROM_FRIEND_SCRIPT_NAME
4290
   restore_directory_from_friend /root/tempmutt mutt
4420
   restore_directory_from_friend /root/tempmutt mutt
4291
-  echo '  if [ -f /root/tempmutt/remoterestore/backup/mutt/$MY_USERNAME/tempbackup/.muttrc ]; then' >> /usr/bin/$RESTORE_FROM_FRIEND_SCRIPT_NAME
4292
-  echo '    cp -f /root/tempmutt/remoterestore/backup/mutt/$MY_USERNAME/tempbackup/.muttrc /home/$MY_USERNAME/.muttrc' >> /usr/bin/$RESTORE_FROM_FRIEND_SCRIPT_NAME
4421
+  echo -n "  if [ -f /root/tempmutt/${RESTORE_SUBDIR}" >> /usr/bin/$RESTORE_FROM_FRIEND_SCRIPT_NAME
4422
+  echo '$MY_USERNAME/tempbackup/.muttrc ]; then' >> /usr/bin/$RESTORE_FROM_FRIEND_SCRIPT_NAME
4423
+  echo -n "    cp -f /root/tempmutt/${RESTORE_SUBDIR}" >> /usr/bin/$RESTORE_FROM_FRIEND_SCRIPT_NAME
4424
+  echo '$MY_USERNAME/tempbackup/.muttrc /home/$MY_USERNAME/.muttrc' >> /usr/bin/$RESTORE_FROM_FRIEND_SCRIPT_NAME
4293
   echo '  fi' >> /usr/bin/$RESTORE_FROM_FRIEND_SCRIPT_NAME
4425
   echo '  fi' >> /usr/bin/$RESTORE_FROM_FRIEND_SCRIPT_NAME
4294
-  echo '  if [ -f /root/tempmutt/remoterestore/backup/mutt/$MY_USERNAME/tempbackup/Muttrc ]; then' >> /usr/bin/$RESTORE_FROM_FRIEND_SCRIPT_NAME
4295
-  echo '    cp -f /root/tempmutt/remoterestore/backup/mutt/$MY_USERNAME/tempbackup/Muttrc /etc/Muttrc' >> /usr/bin/$RESTORE_FROM_FRIEND_SCRIPT_NAME
4426
+  echo -n "  if [ -f /root/tempmutt/${RESTORE_SUBDIR}" >> /usr/bin/$RESTORE_FROM_FRIEND_SCRIPT_NAME
4427
+  echo '$MY_USERNAME/tempbackup/Muttrc ]; then' >> /usr/bin/$RESTORE_FROM_FRIEND_SCRIPT_NAME
4428
+  echo -n "    cp -f /root/tempmutt/${RESTORE_SUBDIR}" >> /usr/bin/$RESTORE_FROM_FRIEND_SCRIPT_NAME
4429
+  echo '$MY_USERNAME/tempbackup/Muttrc /etc/Muttrc' >> /usr/bin/$RESTORE_FROM_FRIEND_SCRIPT_NAME
4296
   echo '  fi' >> /usr/bin/$RESTORE_FROM_FRIEND_SCRIPT_NAME
4430
   echo '  fi' >> /usr/bin/$RESTORE_FROM_FRIEND_SCRIPT_NAME
4297
   echo '  if [ ! "$?" = "0" ]; then' >> /usr/bin/$RESTORE_FROM_FRIEND_SCRIPT_NAME
4431
   echo '  if [ ! "$?" = "0" ]; then' >> /usr/bin/$RESTORE_FROM_FRIEND_SCRIPT_NAME
4298
   echo '    rm -rf /root/tempmutt' >> /usr/bin/$RESTORE_FROM_FRIEND_SCRIPT_NAME
4432
   echo '    rm -rf /root/tempmutt' >> /usr/bin/$RESTORE_FROM_FRIEND_SCRIPT_NAME
4302
   echo 'fi' >> /usr/bin/$RESTORE_FROM_FRIEND_SCRIPT_NAME
4436
   echo 'fi' >> /usr/bin/$RESTORE_FROM_FRIEND_SCRIPT_NAME
4303
   echo '' >> /usr/bin/$RESTORE_FROM_FRIEND_SCRIPT_NAME
4437
   echo '' >> /usr/bin/$RESTORE_FROM_FRIEND_SCRIPT_NAME
4304
 
4438
 
4439
+  RESTORE_SUBDIR='root'
4440
+  if [[ $BACKUP_TYPE != 'obnam' ]]; then
4441
+      RESTORE_SUBDIR='remoterestore/backup/gnupg'
4442
+  fi
4305
   echo 'if [ -d $SERVER_DIRECTORY/backup/gnupg ]; then' >> /usr/bin/$RESTORE_FROM_FRIEND_SCRIPT_NAME
4443
   echo 'if [ -d $SERVER_DIRECTORY/backup/gnupg ]; then' >> /usr/bin/$RESTORE_FROM_FRIEND_SCRIPT_NAME
4306
   echo '  echo "Restoring gnupg settings"' >> /usr/bin/$RESTORE_FROM_FRIEND_SCRIPT_NAME
4444
   echo '  echo "Restoring gnupg settings"' >> /usr/bin/$RESTORE_FROM_FRIEND_SCRIPT_NAME
4307
   restore_directory_from_friend /root/tempgnupg gnupg
4445
   restore_directory_from_friend /root/tempgnupg gnupg
4308
-  echo '  cp -r /root/tempgnupg/remoterestore/backup/gnupg/$MY_USERNAME/.gnupg /home/$MY_USERNAME/' >> /usr/bin/$RESTORE_FROM_FRIEND_SCRIPT_NAME
4446
+  echo -n "  cp -r /root/tempgnupg/${RESTORE_SUBDIR}/" >> /usr/bin/$RESTORE_FROM_FRIEND_SCRIPT_NAME
4447
+  echo '$MY_USERNAME/.gnupg /home/$MY_USERNAME/' >> /usr/bin/$RESTORE_FROM_FRIEND_SCRIPT_NAME
4309
   echo '  if [ ! "$?" = "0" ]; then' >> /usr/bin/$RESTORE_FROM_FRIEND_SCRIPT_NAME
4448
   echo '  if [ ! "$?" = "0" ]; then' >> /usr/bin/$RESTORE_FROM_FRIEND_SCRIPT_NAME
4310
   echo '    rm -rf /root/tempgnupg' >> /usr/bin/$RESTORE_FROM_FRIEND_SCRIPT_NAME
4449
   echo '    rm -rf /root/tempgnupg' >> /usr/bin/$RESTORE_FROM_FRIEND_SCRIPT_NAME
4311
   echo '    exit 276' >> /usr/bin/$RESTORE_FROM_FRIEND_SCRIPT_NAME
4450
   echo '    exit 276' >> /usr/bin/$RESTORE_FROM_FRIEND_SCRIPT_NAME
4318
   echo 'fi' >> /usr/bin/$RESTORE_FROM_FRIEND_SCRIPT_NAME
4457
   echo 'fi' >> /usr/bin/$RESTORE_FROM_FRIEND_SCRIPT_NAME
4319
   echo '' >> /usr/bin/$RESTORE_FROM_FRIEND_SCRIPT_NAME
4458
   echo '' >> /usr/bin/$RESTORE_FROM_FRIEND_SCRIPT_NAME
4320
 
4459
 
4460
+  RESTORE_SUBDIR='root'
4461
+  if [[ $BACKUP_TYPE != 'obnam' ]]; then
4462
+      RESTORE_SUBDIR='remoterestore/backup/procmail'
4463
+  fi
4321
   echo 'if [ -d $SERVER_DIRECTORY/backup/procmail ]; then' >> /usr/bin/$RESTORE_FROM_FRIEND_SCRIPT_NAME
4464
   echo 'if [ -d $SERVER_DIRECTORY/backup/procmail ]; then' >> /usr/bin/$RESTORE_FROM_FRIEND_SCRIPT_NAME
4322
   echo '  echo "Restoring procmail settings"' >> /usr/bin/$RESTORE_FROM_FRIEND_SCRIPT_NAME
4465
   echo '  echo "Restoring procmail settings"' >> /usr/bin/$RESTORE_FROM_FRIEND_SCRIPT_NAME
4323
   restore_directory_from_friend /root/tempprocmail procmail
4466
   restore_directory_from_friend /root/tempprocmail procmail
4324
-  echo '  cp -f /root/tempprocmail/remoterestore/backup/procmail/$MY_USERNAME/tempbackup/.procmailrc /home/$MY_USERNAME/' >> /usr/bin/$RESTORE_FROM_FRIEND_SCRIPT_NAME
4467
+  echo -n "  cp -f /root/tempprocmail/${RESTORE_SUBDIR}" >> /usr/bin/$RESTORE_FROM_FRIEND_SCRIPT_NAME
4468
+  echo '/$MY_USERNAME/tempbackup/.procmailrc /home/$MY_USERNAME/' >> /usr/bin/$RESTORE_FROM_FRIEND_SCRIPT_NAME
4325
   echo '  if [ ! "$?" = "0" ]; then' >> /usr/bin/$RESTORE_FROM_FRIEND_SCRIPT_NAME
4469
   echo '  if [ ! "$?" = "0" ]; then' >> /usr/bin/$RESTORE_FROM_FRIEND_SCRIPT_NAME
4326
   echo '    rm -rf /root/tempprocmail' >> /usr/bin/$RESTORE_FROM_FRIEND_SCRIPT_NAME
4470
   echo '    rm -rf /root/tempprocmail' >> /usr/bin/$RESTORE_FROM_FRIEND_SCRIPT_NAME
4327
   echo '    exit 276' >> /usr/bin/$RESTORE_FROM_FRIEND_SCRIPT_NAME
4471
   echo '    exit 276' >> /usr/bin/$RESTORE_FROM_FRIEND_SCRIPT_NAME
4330
   echo 'fi' >> /usr/bin/$RESTORE_FROM_FRIEND_SCRIPT_NAME
4474
   echo 'fi' >> /usr/bin/$RESTORE_FROM_FRIEND_SCRIPT_NAME
4331
   echo '' >> /usr/bin/$RESTORE_FROM_FRIEND_SCRIPT_NAME
4475
   echo '' >> /usr/bin/$RESTORE_FROM_FRIEND_SCRIPT_NAME
4332
 
4476
 
4477
+  RESTORE_SUBDIR='root'
4478
+  if [[ $BACKUP_TYPE != 'obnam' ]]; then
4479
+      RESTORE_SUBDIR='remoterestore/backup/spamassassin'
4480
+  fi
4333
   echo 'if [ -d $SERVER_DIRECTORY/backup/spamassassin ]; then' >> /usr/bin/$RESTORE_FROM_FRIEND_SCRIPT_NAME
4481
   echo 'if [ -d $SERVER_DIRECTORY/backup/spamassassin ]; then' >> /usr/bin/$RESTORE_FROM_FRIEND_SCRIPT_NAME
4334
   echo '  echo "Restoring spamassassin settings"' >> /usr/bin/$RESTORE_FROM_FRIEND_SCRIPT_NAME
4482
   echo '  echo "Restoring spamassassin settings"' >> /usr/bin/$RESTORE_FROM_FRIEND_SCRIPT_NAME
4335
   restore_directory_from_friend /root/tempspamassassin spamassassin
4483
   restore_directory_from_friend /root/tempspamassassin spamassassin
4336
-  echo '  cp -rf /root/tempspamassassin/remoterestore/backup/spamassassin/$MY_USERNAME/.spamassassin /home/$MY_USERNAME/' >> /usr/bin/$RESTORE_FROM_FRIEND_SCRIPT_NAME
4484
+  echo -n "  cp -rf /root/tempspamassassin/${RESTORE_SUBDIR}/" >> /usr/bin/$RESTORE_FROM_FRIEND_SCRIPT_NAME
4485
+  echo '$MY_USERNAME/.spamassassin /home/$MY_USERNAME/' >> /usr/bin/$RESTORE_FROM_FRIEND_SCRIPT_NAME
4337
   echo '  if [ ! "$?" = "0" ]; then' >> /usr/bin/$RESTORE_FROM_FRIEND_SCRIPT_NAME
4486
   echo '  if [ ! "$?" = "0" ]; then' >> /usr/bin/$RESTORE_FROM_FRIEND_SCRIPT_NAME
4338
   echo '    rm -rf /root/tempspamassassin' >> /usr/bin/$RESTORE_FROM_FRIEND_SCRIPT_NAME
4487
   echo '    rm -rf /root/tempspamassassin' >> /usr/bin/$RESTORE_FROM_FRIEND_SCRIPT_NAME
4339
   echo '    exit 276' >> /usr/bin/$RESTORE_FROM_FRIEND_SCRIPT_NAME
4488
   echo '    exit 276' >> /usr/bin/$RESTORE_FROM_FRIEND_SCRIPT_NAME
4342
   echo 'fi' >> /usr/bin/$RESTORE_FROM_FRIEND_SCRIPT_NAME
4491
   echo 'fi' >> /usr/bin/$RESTORE_FROM_FRIEND_SCRIPT_NAME
4343
   echo '' >> /usr/bin/$RESTORE_FROM_FRIEND_SCRIPT_NAME
4492
   echo '' >> /usr/bin/$RESTORE_FROM_FRIEND_SCRIPT_NAME
4344
 
4493
 
4494
+  RESTORE_SUBDIR='root'
4495
+  if [[ $BACKUP_TYPE != 'obnam' ]]; then
4496
+      RESTORE_SUBDIR='remoterestore/backup/readme'
4497
+  fi
4345
   echo 'if [ -d $SERVER_DIRECTORY/backup/readme ]; then' >> /usr/bin/$RESTORE_FROM_FRIEND_SCRIPT_NAME
4498
   echo 'if [ -d $SERVER_DIRECTORY/backup/readme ]; then' >> /usr/bin/$RESTORE_FROM_FRIEND_SCRIPT_NAME
4346
   echo '  echo "Restoring README"' >> /usr/bin/$RESTORE_FROM_FRIEND_SCRIPT_NAME
4499
   echo '  echo "Restoring README"' >> /usr/bin/$RESTORE_FROM_FRIEND_SCRIPT_NAME
4347
   restore_directory_from_friend /root/tempreadme readme
4500
   restore_directory_from_friend /root/tempreadme readme
4348
-  echo '  cp -f /root/tempreadme/remoterestore/backup/readme/$MY_USERNAME/tempbackup/README /home/$MY_USERNAME/' >> /usr/bin/$RESTORE_FROM_FRIEND_SCRIPT_NAME
4501
+  echo -n "  cp -f /root/tempreadme/${RESTORE_SUBDIR}/" >> /usr/bin/$RESTORE_FROM_FRIEND_SCRIPT_NAME
4502
+  echo '$MY_USERNAME/tempbackup/README /home/$MY_USERNAME/' >> /usr/bin/$RESTORE_FROM_FRIEND_SCRIPT_NAME
4349
   echo '  if [ ! "$?" = "0" ]; then' >> /usr/bin/$RESTORE_FROM_FRIEND_SCRIPT_NAME
4503
   echo '  if [ ! "$?" = "0" ]; then' >> /usr/bin/$RESTORE_FROM_FRIEND_SCRIPT_NAME
4350
   echo '    rm -rf /root/tempreadme' >> /usr/bin/$RESTORE_FROM_FRIEND_SCRIPT_NAME
4504
   echo '    rm -rf /root/tempreadme' >> /usr/bin/$RESTORE_FROM_FRIEND_SCRIPT_NAME
4351
   echo '    exit 276' >> /usr/bin/$RESTORE_FROM_FRIEND_SCRIPT_NAME
4505
   echo '    exit 276' >> /usr/bin/$RESTORE_FROM_FRIEND_SCRIPT_NAME
4354
   echo 'fi' >> /usr/bin/$RESTORE_FROM_FRIEND_SCRIPT_NAME
4508
   echo 'fi' >> /usr/bin/$RESTORE_FROM_FRIEND_SCRIPT_NAME
4355
   echo '' >> /usr/bin/$RESTORE_FROM_FRIEND_SCRIPT_NAME
4509
   echo '' >> /usr/bin/$RESTORE_FROM_FRIEND_SCRIPT_NAME
4356
 
4510
 
4511
+  RESTORE_SUBDIR='root'
4512
+  if [[ $BACKUP_TYPE != 'obnam' ]]; then
4513
+      RESTORE_SUBDIR='remoterestore/backup/ssh'
4514
+  fi
4357
   echo 'if [ -d $SERVER_DIRECTORY/backup/ssh ]; then' >> /usr/bin/$RESTORE_FROM_FRIEND_SCRIPT_NAME
4515
   echo 'if [ -d $SERVER_DIRECTORY/backup/ssh ]; then' >> /usr/bin/$RESTORE_FROM_FRIEND_SCRIPT_NAME
4358
   echo '  echo "Restoring ssh keys"' >> /usr/bin/$RESTORE_FROM_FRIEND_SCRIPT_NAME
4516
   echo '  echo "Restoring ssh keys"' >> /usr/bin/$RESTORE_FROM_FRIEND_SCRIPT_NAME
4359
   restore_directory_from_friend /root/tempssh ssh
4517
   restore_directory_from_friend /root/tempssh ssh
4360
-  echo '  cp -r /root/tempssh/remoterestore/backup/ssh/$MY_USERNAME/.ssh /home/$MY_USERNAME/' >> /usr/bin/$RESTORE_FROM_FRIEND_SCRIPT_NAME
4518
+  echo -n "  cp -r /root/tempssh/${RESTORE_SUBDIR}/" >> /usr/bin/$RESTORE_FROM_FRIEND_SCRIPT_NAME
4519
+  echo '$MY_USERNAME/.ssh /home/$MY_USERNAME/' >> /usr/bin/$RESTORE_FROM_FRIEND_SCRIPT_NAME
4361
   echo '  if [ ! "$?" = "0" ]; then' >> /usr/bin/$RESTORE_FROM_FRIEND_SCRIPT_NAME
4520
   echo '  if [ ! "$?" = "0" ]; then' >> /usr/bin/$RESTORE_FROM_FRIEND_SCRIPT_NAME
4362
   echo '    rm -rf /root/tempssh' >> /usr/bin/$RESTORE_FROM_FRIEND_SCRIPT_NAME
4521
   echo '    rm -rf /root/tempssh' >> /usr/bin/$RESTORE_FROM_FRIEND_SCRIPT_NAME
4363
   echo '    exit 664' >> /usr/bin/$RESTORE_FROM_FRIEND_SCRIPT_NAME
4522
   echo '    exit 664' >> /usr/bin/$RESTORE_FROM_FRIEND_SCRIPT_NAME
4366
   echo 'fi' >> /usr/bin/$RESTORE_FROM_FRIEND_SCRIPT_NAME
4525
   echo 'fi' >> /usr/bin/$RESTORE_FROM_FRIEND_SCRIPT_NAME
4367
   echo '' >> /usr/bin/$RESTORE_FROM_FRIEND_SCRIPT_NAME
4526
   echo '' >> /usr/bin/$RESTORE_FROM_FRIEND_SCRIPT_NAME
4368
 
4527
 
4528
+  RESTORE_SUBDIR='root'
4529
+  if [[ $BACKUP_TYPE != 'obnam' ]]; then
4530
+      RESTORE_SUBDIR='remoterestore/backup/ssl'
4531
+  fi
4369
   echo 'if [ -d $SERVER_DIRECTORY/backup/ssl ]; then' >> /usr/bin/$RESTORE_FROM_FRIEND_SCRIPT_NAME
4532
   echo 'if [ -d $SERVER_DIRECTORY/backup/ssl ]; then' >> /usr/bin/$RESTORE_FROM_FRIEND_SCRIPT_NAME
4370
   echo '  echo "Restoring certificates"' >> /usr/bin/$RESTORE_FROM_FRIEND_SCRIPT_NAME
4533
   echo '  echo "Restoring certificates"' >> /usr/bin/$RESTORE_FROM_FRIEND_SCRIPT_NAME
4371
   restore_directory_from_friend /root/tempssl ssl
4534
   restore_directory_from_friend /root/tempssl ssl
4372
-  echo '  cp -r /root/tempssl/remoterestore/backup/ssl/ssl/* /etc/ssl' >> /usr/bin/$RESTORE_FROM_FRIEND_SCRIPT_NAME
4535
+  echo -n "  cp -r /root/tempssl/${RESTORE_SUBDIR}/" >> /usr/bin/$RESTORE_FROM_FRIEND_SCRIPT_NAME
4536
+  echo 'ssl/* /etc/ssl' >> /usr/bin/$RESTORE_FROM_FRIEND_SCRIPT_NAME
4373
   echo '  if [ ! "$?" = "0" ]; then' >> /usr/bin/$RESTORE_FROM_FRIEND_SCRIPT_NAME
4537
   echo '  if [ ! "$?" = "0" ]; then' >> /usr/bin/$RESTORE_FROM_FRIEND_SCRIPT_NAME
4374
   echo '    exit 276' >> /usr/bin/$RESTORE_FROM_FRIEND_SCRIPT_NAME
4538
   echo '    exit 276' >> /usr/bin/$RESTORE_FROM_FRIEND_SCRIPT_NAME
4375
   echo '  fi' >> /usr/bin/$RESTORE_FROM_FRIEND_SCRIPT_NAME
4539
   echo '  fi' >> /usr/bin/$RESTORE_FROM_FRIEND_SCRIPT_NAME
4377
   echo 'fi' >> /usr/bin/$RESTORE_FROM_FRIEND_SCRIPT_NAME
4541
   echo 'fi' >> /usr/bin/$RESTORE_FROM_FRIEND_SCRIPT_NAME
4378
   echo '' >> /usr/bin/$RESTORE_FROM_FRIEND_SCRIPT_NAME
4542
   echo '' >> /usr/bin/$RESTORE_FROM_FRIEND_SCRIPT_NAME
4379
 
4543
 
4544
+  RESTORE_SUBDIR='root'
4545
+  if [[ $BACKUP_TYPE != 'obnam' ]]; then
4546
+      RESTORE_SUBDIR='remoterestore/backup/projects'
4547
+  fi
4380
   echo 'if [ -d $SERVER_DIRECTORY/backup/projects ]; then' >> /usr/bin/$RESTORE_FROM_FRIEND_SCRIPT_NAME
4548
   echo 'if [ -d $SERVER_DIRECTORY/backup/projects ]; then' >> /usr/bin/$RESTORE_FROM_FRIEND_SCRIPT_NAME
4381
   echo '  echo "Restoring projects"' >> /usr/bin/$RESTORE_FROM_FRIEND_SCRIPT_NAME
4549
   echo '  echo "Restoring projects"' >> /usr/bin/$RESTORE_FROM_FRIEND_SCRIPT_NAME
4382
   restore_directory_from_friend /root/tempprojects projects
4550
   restore_directory_from_friend /root/tempprojects projects
4383
   echo '  if [ -d /home/$MY_USERNAME/projects ]; then' >> /usr/bin/$RESTORE_FROM_FRIEND_SCRIPT_NAME
4551
   echo '  if [ -d /home/$MY_USERNAME/projects ]; then' >> /usr/bin/$RESTORE_FROM_FRIEND_SCRIPT_NAME
4384
   echo '    rm -rf /home/$MY_USERNAME/projects' >> /usr/bin/$RESTORE_FROM_FRIEND_SCRIPT_NAME
4552
   echo '    rm -rf /home/$MY_USERNAME/projects' >> /usr/bin/$RESTORE_FROM_FRIEND_SCRIPT_NAME
4385
   echo '  fi' >> /usr/bin/$RESTORE_FROM_FRIEND_SCRIPT_NAME
4553
   echo '  fi' >> /usr/bin/$RESTORE_FROM_FRIEND_SCRIPT_NAME
4386
-  echo '  mv /root/tempprojects/remoterestore/backup/projects/$MY_USERNAME/projects /home/$MY_USERNAME' >> /usr/bin/$RESTORE_FROM_FRIEND_SCRIPT_NAME
4554
+  echo -n "  mv /root/tempprojects/${RESTORE_SUBDIR}/" >> /usr/bin/$RESTORE_FROM_FRIEND_SCRIPT_NAME
4555
+  echo '$MY_USERNAME/projects /home/$MY_USERNAME' >> /usr/bin/$RESTORE_FROM_FRIEND_SCRIPT_NAME
4387
   echo '  if [ ! "$?" = "0" ]; then' >> /usr/bin/$RESTORE_FROM_FRIEND_SCRIPT_NAME
4556
   echo '  if [ ! "$?" = "0" ]; then' >> /usr/bin/$RESTORE_FROM_FRIEND_SCRIPT_NAME
4388
   echo '    exit 166' >> /usr/bin/$RESTORE_FROM_FRIEND_SCRIPT_NAME
4557
   echo '    exit 166' >> /usr/bin/$RESTORE_FROM_FRIEND_SCRIPT_NAME
4389
   echo '  fi' >> /usr/bin/$RESTORE_FROM_FRIEND_SCRIPT_NAME
4558
   echo '  fi' >> /usr/bin/$RESTORE_FROM_FRIEND_SCRIPT_NAME
4391
   echo 'fi' >> /usr/bin/$RESTORE_FROM_FRIEND_SCRIPT_NAME
4560
   echo 'fi' >> /usr/bin/$RESTORE_FROM_FRIEND_SCRIPT_NAME
4392
   echo '' >> /usr/bin/$RESTORE_FROM_FRIEND_SCRIPT_NAME
4561
   echo '' >> /usr/bin/$RESTORE_FROM_FRIEND_SCRIPT_NAME
4393
 
4562
 
4563
+  RESTORE_SUBDIR='root'
4564
+  if [[ $BACKUP_TYPE != 'obnam' ]]; then
4565
+      RESTORE_SUBDIR='remoterestore/backup/personal'
4566
+  fi
4394
   echo 'if [ -d $SERVER_DIRECTORY/backup/personal ]; then' >> /usr/bin/$RESTORE_FROM_FRIEND_SCRIPT_NAME
4567
   echo 'if [ -d $SERVER_DIRECTORY/backup/personal ]; then' >> /usr/bin/$RESTORE_FROM_FRIEND_SCRIPT_NAME
4395
   echo '  echo "Restoring personal settings"' >> /usr/bin/$RESTORE_FROM_FRIEND_SCRIPT_NAME
4568
   echo '  echo "Restoring personal settings"' >> /usr/bin/$RESTORE_FROM_FRIEND_SCRIPT_NAME
4396
   restore_directory_from_friend /root/temppersonal personal
4569
   restore_directory_from_friend /root/temppersonal personal
4397
   echo '  if [ -d /home/$MY_USERNAME/personal ]; then' >> /usr/bin/$RESTORE_FROM_FRIEND_SCRIPT_NAME
4570
   echo '  if [ -d /home/$MY_USERNAME/personal ]; then' >> /usr/bin/$RESTORE_FROM_FRIEND_SCRIPT_NAME
4398
   echo '    rm -rf /home/$MY_USERNAME/personal' >> /usr/bin/$RESTORE_FROM_FRIEND_SCRIPT_NAME
4571
   echo '    rm -rf /home/$MY_USERNAME/personal' >> /usr/bin/$RESTORE_FROM_FRIEND_SCRIPT_NAME
4399
   echo '  fi' >> /usr/bin/$RESTORE_FROM_FRIEND_SCRIPT_NAME
4572
   echo '  fi' >> /usr/bin/$RESTORE_FROM_FRIEND_SCRIPT_NAME
4400
-  echo '  mv /root/temppersonal/remoterestore/backup/personal/$MY_USERNAME/personal /home/$MY_USERNAME' >> /usr/bin/$RESTORE_FROM_FRIEND_SCRIPT_NAME
4573
+  echo -n "  mv /root/temppersonal/${RESTORE_SUBDIR}/" >> /usr/bin/$RESTORE_FROM_FRIEND_SCRIPT_NAME
4574
+  echo '$MY_USERNAME/personal /home/$MY_USERNAME' >> /usr/bin/$RESTORE_FROM_FRIEND_SCRIPT_NAME
4401
   echo '  if [ ! "$?" = "0" ]; then' >> /usr/bin/$RESTORE_FROM_FRIEND_SCRIPT_NAME
4575
   echo '  if [ ! "$?" = "0" ]; then' >> /usr/bin/$RESTORE_FROM_FRIEND_SCRIPT_NAME
4402
   echo '    exit 184' >> /usr/bin/$RESTORE_FROM_FRIEND_SCRIPT_NAME
4576
   echo '    exit 184' >> /usr/bin/$RESTORE_FROM_FRIEND_SCRIPT_NAME
4403
   echo '  fi' >> /usr/bin/$RESTORE_FROM_FRIEND_SCRIPT_NAME
4577
   echo '  fi' >> /usr/bin/$RESTORE_FROM_FRIEND_SCRIPT_NAME
4405
   echo 'fi' >> /usr/bin/$RESTORE_FROM_FRIEND_SCRIPT_NAME
4579
   echo 'fi' >> /usr/bin/$RESTORE_FROM_FRIEND_SCRIPT_NAME
4406
   echo '' >> /usr/bin/$RESTORE_FROM_FRIEND_SCRIPT_NAME
4580
   echo '' >> /usr/bin/$RESTORE_FROM_FRIEND_SCRIPT_NAME
4407
 
4581
 
4582
+  RESTORE_SUBDIR='root'
4583
+  if [[ $BACKUP_TYPE != 'obnam' ]]; then
4584
+      RESTORE_SUBDIR='remoterestore/backup/mailinglist'
4585
+  fi
4408
   echo "if [ -d $PUBLIC_MAILING_LIST_DIRECTORY ]; then" >> /usr/bin/$RESTORE_FROM_FRIEND_SCRIPT_NAME
4586
   echo "if [ -d $PUBLIC_MAILING_LIST_DIRECTORY ]; then" >> /usr/bin/$RESTORE_FROM_FRIEND_SCRIPT_NAME
4409
   echo '  echo "Restoring public mailing list"' >> /usr/bin/$RESTORE_FROM_FRIEND_SCRIPT_NAME
4587
   echo '  echo "Restoring public mailing list"' >> /usr/bin/$RESTORE_FROM_FRIEND_SCRIPT_NAME
4410
   restore_directory_from_friend /root/tempmailinglist mailinglist
4588
   restore_directory_from_friend /root/tempmailinglist mailinglist
4411
-  echo "  cp -r /root/tempmailinglist/remoterestore/backup/mailinglist/spool/mlmmj/* $PUBLIC_MAILING_LIST_DIRECTORY" >> /usr/bin/$RESTORE_FROM_FRIEND_SCRIPT_NAME
4589
+  echo "  cp -r /root/tempmailinglist/${RESTORE_SUBDIR}/spool/mlmmj/* $PUBLIC_MAILING_LIST_DIRECTORY" >> /usr/bin/$RESTORE_FROM_FRIEND_SCRIPT_NAME
4412
   echo '  if [ ! "$?" = "0" ]; then' >> /usr/bin/$RESTORE_FROM_FRIEND_SCRIPT_NAME
4590
   echo '  if [ ! "$?" = "0" ]; then' >> /usr/bin/$RESTORE_FROM_FRIEND_SCRIPT_NAME
4413
   echo '    exit 526' >> /usr/bin/$RESTORE_FROM_FRIEND_SCRIPT_NAME
4591
   echo '    exit 526' >> /usr/bin/$RESTORE_FROM_FRIEND_SCRIPT_NAME
4414
   echo '  fi' >> /usr/bin/$RESTORE_FROM_FRIEND_SCRIPT_NAME
4592
   echo '  fi' >> /usr/bin/$RESTORE_FROM_FRIEND_SCRIPT_NAME
4416
   echo 'fi' >> /usr/bin/$RESTORE_FROM_FRIEND_SCRIPT_NAME
4594
   echo 'fi' >> /usr/bin/$RESTORE_FROM_FRIEND_SCRIPT_NAME
4417
   echo '' >> /usr/bin/$RESTORE_FROM_FRIEND_SCRIPT_NAME
4595
   echo '' >> /usr/bin/$RESTORE_FROM_FRIEND_SCRIPT_NAME
4418
 
4596
 
4597
+  RESTORE_SUBDIR='root'
4598
+  if [[ $BACKUP_TYPE != 'obnam' ]]; then
4599
+      RESTORE_SUBDIR='remoterestore/backup/xmpp'
4600
+  fi
4419
   echo "if [ -d $XMPP_DIRECTORY ]; then" >> /usr/bin/$RESTORE_FROM_FRIEND_SCRIPT_NAME
4601
   echo "if [ -d $XMPP_DIRECTORY ]; then" >> /usr/bin/$RESTORE_FROM_FRIEND_SCRIPT_NAME
4420
   echo '  echo "Restoring XMPP settings"' >> /usr/bin/$RESTORE_FROM_FRIEND_SCRIPT_NAME
4602
   echo '  echo "Restoring XMPP settings"' >> /usr/bin/$RESTORE_FROM_FRIEND_SCRIPT_NAME
4421
   restore_directory_from_friend /root/tempxmpp xmpp
4603
   restore_directory_from_friend /root/tempxmpp xmpp
4422
-  echo "  cp -r /root/tempxmpp/remoterestore/backup/xmpp/lib/prosody/* $XMPP_DIRECTORY" >> /usr/bin/$RESTORE_FROM_FRIEND_SCRIPT_NAME
4604
+  echo "  cp -r /root/tempxmpp/${RESTORE_SUBDIR}/lib/prosody/* $XMPP_DIRECTORY" >> /usr/bin/$RESTORE_FROM_FRIEND_SCRIPT_NAME
4423
   echo '  if [ ! "$?" = "0" ]; then' >> /usr/bin/$RESTORE_FROM_FRIEND_SCRIPT_NAME
4605
   echo '  if [ ! "$?" = "0" ]; then' >> /usr/bin/$RESTORE_FROM_FRIEND_SCRIPT_NAME
4424
   echo '    exit 725' >> /usr/bin/$RESTORE_FROM_FRIEND_SCRIPT_NAME
4606
   echo '    exit 725' >> /usr/bin/$RESTORE_FROM_FRIEND_SCRIPT_NAME
4425
   echo '  fi' >> /usr/bin/$RESTORE_FROM_FRIEND_SCRIPT_NAME
4607
   echo '  fi' >> /usr/bin/$RESTORE_FROM_FRIEND_SCRIPT_NAME
4456
   fi
4638
   fi
4457
 
4639
 
4458
   if grep -Fxq "install_owncloud" $COMPLETION_FILE; then
4640
   if grep -Fxq "install_owncloud" $COMPLETION_FILE; then
4641
+      RESTORE_SUBDIR='root'
4642
+      if [[ $BACKUP_TYPE != 'obnam' ]]; then
4643
+          RESTORE_SUBDIR='remoterestore/backup/owncloud'
4644
+      fi
4459
       BACKUP_INCLUDES_WEBSITES="yes"
4645
       BACKUP_INCLUDES_WEBSITES="yes"
4460
       restore_database_from_friend owncloud $OWNCLOUD_DOMAIN_NAME
4646
       restore_database_from_friend owncloud $OWNCLOUD_DOMAIN_NAME
4461
       echo 'if [ -d $SERVER_DIRECTORY/backup/owncloud ]; then' >> /usr/bin/$RESTORE_FROM_FRIEND_SCRIPT_NAME
4647
       echo 'if [ -d $SERVER_DIRECTORY/backup/owncloud ]; then' >> /usr/bin/$RESTORE_FROM_FRIEND_SCRIPT_NAME
4462
       echo '  echo "Restoring Owncloud installation"' >> /usr/bin/$RESTORE_FROM_FRIEND_SCRIPT_NAME
4648
       echo '  echo "Restoring Owncloud installation"' >> /usr/bin/$RESTORE_FROM_FRIEND_SCRIPT_NAME
4463
-      echo "  cp -r /root/tempowncloud/remoterestore/backup/owncloud/lib/owncloud/* /var/lib/owncloud/" >> /usr/bin/$RESTORE_FROM_FRIEND_SCRIPT_NAME
4649
+      echo "  cp -r /root/tempowncloud/${RESTORE_SUBDIR}/lib/owncloud/* /var/lib/owncloud/" >> /usr/bin/$RESTORE_FROM_FRIEND_SCRIPT_NAME
4464
       echo '  if [ ! "$?" = "0" ]; then' >> /usr/bin/$RESTORE_FROM_FRIEND_SCRIPT_NAME
4650
       echo '  if [ ! "$?" = "0" ]; then' >> /usr/bin/$RESTORE_FROM_FRIEND_SCRIPT_NAME
4465
       echo '    exit 981' >> /usr/bin/$RESTORE_FROM_FRIEND_SCRIPT_NAME
4651
       echo '    exit 981' >> /usr/bin/$RESTORE_FROM_FRIEND_SCRIPT_NAME
4466
       echo '  fi' >> /usr/bin/$RESTORE_FROM_FRIEND_SCRIPT_NAME
4652
       echo '  fi' >> /usr/bin/$RESTORE_FROM_FRIEND_SCRIPT_NAME
4467
       restore_directory_from_friend /root/tempowncloud2 owncloud2
4653
       restore_directory_from_friend /root/tempowncloud2 owncloud2
4468
-      echo "  cp -r /root/tempowncloud2/remoterestore/backup/owncloud2/owncloud/* /etc/owncloud/" >> /usr/bin/$RESTORE_FROM_FRIEND_SCRIPT_NAME
4654
+      if [[ $BACKUP_TYPE != 'obnam' ]]; then
4655
+          RESTORE_SUBDIR='remoterestore/backup/owncloud2'
4656
+      fi
4657
+      echo "  cp -r /root/tempowncloud2/${RESTORE_SUBDIR}/owncloud/* /etc/owncloud/" >> /usr/bin/$RESTORE_FROM_FRIEND_SCRIPT_NAME
4469
       echo '  if [ ! "$?" = "0" ]; then' >> /usr/bin/$RESTORE_FROM_FRIEND_SCRIPT_NAME
4658
       echo '  if [ ! "$?" = "0" ]; then' >> /usr/bin/$RESTORE_FROM_FRIEND_SCRIPT_NAME
4470
       echo '    exit 982' >> /usr/bin/$RESTORE_FROM_FRIEND_SCRIPT_NAME
4659
       echo '    exit 982' >> /usr/bin/$RESTORE_FROM_FRIEND_SCRIPT_NAME
4471
       echo '  fi' >> /usr/bin/$RESTORE_FROM_FRIEND_SCRIPT_NAME
4660
       echo '  fi' >> /usr/bin/$RESTORE_FROM_FRIEND_SCRIPT_NAME
4480
   fi
4669
   fi
4481
 
4670
 
4482
   if grep -Fxq "install_gogs" $COMPLETION_FILE; then
4671
   if grep -Fxq "install_gogs" $COMPLETION_FILE; then
4672
+      RESTORE_SUBDIR='root'
4673
+      if [[ $BACKUP_TYPE != 'obnam' ]]; then
4674
+          RESTORE_SUBDIR='remoterestore/backup/gogs'
4675
+      fi
4483
       BACKUP_INCLUDES_WEBSITES="yes"
4676
       BACKUP_INCLUDES_WEBSITES="yes"
4484
       restore_database_from_friend gogs $GIT_DOMAIN_NAME
4677
       restore_database_from_friend gogs $GIT_DOMAIN_NAME
4485
       echo 'if [ -d $SERVER_DIRECTORY/backup/gogs ]; then' >> /usr/bin/$RESTORE_FROM_FRIEND_SCRIPT_NAME
4678
       echo 'if [ -d $SERVER_DIRECTORY/backup/gogs ]; then' >> /usr/bin/$RESTORE_FROM_FRIEND_SCRIPT_NAME
4486
       echo '  if [ ! -d /home/git/go/src/github.com/gogits/gogs/custom ]; then' >> /usr/bin/$RESTORE_FROM_FRIEND_SCRIPT_NAME
4679
       echo '  if [ ! -d /home/git/go/src/github.com/gogits/gogs/custom ]; then' >> /usr/bin/$RESTORE_FROM_FRIEND_SCRIPT_NAME
4487
       echo '    mkdir -p /home/git/go/src/github.com/gogits/gogs/custom' >> /usr/bin/$RESTORE_FROM_FRIEND_SCRIPT_NAME
4680
       echo '    mkdir -p /home/git/go/src/github.com/gogits/gogs/custom' >> /usr/bin/$RESTORE_FROM_FRIEND_SCRIPT_NAME
4488
       echo '  fi' >> /usr/bin/$RESTORE_FROM_FRIEND_SCRIPT_NAME
4681
       echo '  fi' >> /usr/bin/$RESTORE_FROM_FRIEND_SCRIPT_NAME
4489
-      echo "  cp -r /root/tempgogs/remoterestore/backup/gogs/git/go/src/github.com/gogits/gogs/custom/* /home/git/go/src/github.com/gogits/gogs/custom/" >> /usr/bin/$RESTORE_FROM_FRIEND_SCRIPT_NAME
4682
+      echo "  cp -r /root/tempgogs/${RESTORE_SUBDIR}/git/go/src/github.com/gogits/gogs/custom/* /home/git/go/src/github.com/gogits/gogs/custom/" >> /usr/bin/$RESTORE_FROM_FRIEND_SCRIPT_NAME
4490
       echo '  if [ ! "$?" = "0" ]; then' >> /usr/bin/$RESTORE_FROM_FRIEND_SCRIPT_NAME
4683
       echo '  if [ ! "$?" = "0" ]; then' >> /usr/bin/$RESTORE_FROM_FRIEND_SCRIPT_NAME
4491
       echo '    exit 5885' >> /usr/bin/$RESTORE_FROM_FRIEND_SCRIPT_NAME
4684
       echo '    exit 5885' >> /usr/bin/$RESTORE_FROM_FRIEND_SCRIPT_NAME
4492
       echo '  fi' >> /usr/bin/$RESTORE_FROM_FRIEND_SCRIPT_NAME
4685
       echo '  fi' >> /usr/bin/$RESTORE_FROM_FRIEND_SCRIPT_NAME
4493
       echo '  echo "Restoring Gogs repos"' >> /usr/bin/$RESTORE_FROM_FRIEND_SCRIPT_NAME
4686
       echo '  echo "Restoring Gogs repos"' >> /usr/bin/$RESTORE_FROM_FRIEND_SCRIPT_NAME
4494
       restore_directory_from_friend /root/tempgogsrepos gogsrepos
4687
       restore_directory_from_friend /root/tempgogsrepos gogsrepos
4495
-      echo "  cp -r /root/tempgogsrepos/remoterestore/backup/gogsrepos/git/gogs-repositories/* /home/git/gogs-repositories/" >> /usr/bin/$RESTORE_FROM_FRIEND_SCRIPT_NAME
4688
+      if [[ $BACKUP_TYPE != 'obnam' ]]; then
4689
+          RESTORE_SUBDIR='remoterestore/backup/gogsrepos'
4690
+      fi
4691
+      echo "  cp -r /root/tempgogsrepos/${RESTORE_SUBDIR}/git/gogs-repositories/* /home/git/gogs-repositories/" >> /usr/bin/$RESTORE_FROM_FRIEND_SCRIPT_NAME
4496
       echo '  if [ ! "$?" = "0" ]; then' >> /usr/bin/$RESTORE_FROM_FRIEND_SCRIPT_NAME
4692
       echo '  if [ ! "$?" = "0" ]; then' >> /usr/bin/$RESTORE_FROM_FRIEND_SCRIPT_NAME
4497
       echo '    exit 7649' >> /usr/bin/$RESTORE_FROM_FRIEND_SCRIPT_NAME
4693
       echo '    exit 7649' >> /usr/bin/$RESTORE_FROM_FRIEND_SCRIPT_NAME
4498
       echo '  fi' >> /usr/bin/$RESTORE_FROM_FRIEND_SCRIPT_NAME
4694
       echo '  fi' >> /usr/bin/$RESTORE_FROM_FRIEND_SCRIPT_NAME
4501
       echo '  if [ ! -d /home/git/.ssh ]; then' >> /usr/bin/$RESTORE_FROM_FRIEND_SCRIPT_NAME
4697
       echo '  if [ ! -d /home/git/.ssh ]; then' >> /usr/bin/$RESTORE_FROM_FRIEND_SCRIPT_NAME
4502
       echo '    mkdir /home/git/.ssh' >> /usr/bin/$RESTORE_FROM_FRIEND_SCRIPT_NAME
4698
       echo '    mkdir /home/git/.ssh' >> /usr/bin/$RESTORE_FROM_FRIEND_SCRIPT_NAME
4503
       echo '  fi' >> /usr/bin/$RESTORE_FROM_FRIEND_SCRIPT_NAME
4699
       echo '  fi' >> /usr/bin/$RESTORE_FROM_FRIEND_SCRIPT_NAME
4504
-      echo "  cp -r /root/tempgogsssh/remoterestore/backup/gogsssh/git/.ssh/* /home/git/.ssh/" >> /usr/bin/$RESTORE_FROM_FRIEND_SCRIPT_NAME
4700
+      if [[ $BACKUP_TYPE != 'obnam' ]]; then
4701
+          RESTORE_SUBDIR='remoterestore/backup/gogsssh'
4702
+      fi
4703
+      echo "  cp -r /root/tempgogsssh/${RESTORE_SUBDIR}/git/.ssh/* /home/git/.ssh/" >> /usr/bin/$RESTORE_FROM_FRIEND_SCRIPT_NAME
4505
       echo '  if [ ! "$?" = "0" ]; then' >> /usr/bin/$RESTORE_FROM_FRIEND_SCRIPT_NAME
4704
       echo '  if [ ! "$?" = "0" ]; then' >> /usr/bin/$RESTORE_FROM_FRIEND_SCRIPT_NAME
4506
       echo '    exit 74239' >> /usr/bin/$RESTORE_FROM_FRIEND_SCRIPT_NAME
4705
       echo '    exit 74239' >> /usr/bin/$RESTORE_FROM_FRIEND_SCRIPT_NAME
4507
       echo '  fi' >> /usr/bin/$RESTORE_FROM_FRIEND_SCRIPT_NAME
4706
       echo '  fi' >> /usr/bin/$RESTORE_FROM_FRIEND_SCRIPT_NAME
4513
       echo '' >> /usr/bin/$RESTORE_FROM_FRIEND_SCRIPT_NAME
4712
       echo '' >> /usr/bin/$RESTORE_FROM_FRIEND_SCRIPT_NAME
4514
   fi
4713
   fi
4515
 
4714
 
4715
+  RESTORE_SUBDIR='root'
4716
+  if [[ $BACKUP_TYPE != 'obnam' ]]; then
4717
+      RESTORE_SUBDIR='remoterestore/backup/wiki'
4718
+  fi
4516
   echo 'if [ -d $SERVER_DIRECTORY/backup/wiki ]; then' >> /usr/bin/$RESTORE_FROM_FRIEND_SCRIPT_NAME
4719
   echo 'if [ -d $SERVER_DIRECTORY/backup/wiki ]; then' >> /usr/bin/$RESTORE_FROM_FRIEND_SCRIPT_NAME
4517
   echo '  echo "Restoring Wiki installation"' >> /usr/bin/$RESTORE_FROM_FRIEND_SCRIPT_NAME
4720
   echo '  echo "Restoring Wiki installation"' >> /usr/bin/$RESTORE_FROM_FRIEND_SCRIPT_NAME
4518
   restore_directory_from_friend /root/tempwiki wiki
4721
   restore_directory_from_friend /root/tempwiki wiki
4519
-  echo "  cp -r /root/tempwiki/remoterestore/backup/wiki/lib/dokuwiki/* /var/lib/dokuwiki/" >> /usr/bin/$RESTORE_FROM_FRIEND_SCRIPT_NAME
4722
+  echo "  cp -r /root/tempwiki/${RESTORE_SUBDIR}/lib/dokuwiki/* /var/lib/dokuwiki/" >> /usr/bin/$RESTORE_FROM_FRIEND_SCRIPT_NAME
4520
   echo '  if [ ! "$?" = "0" ]; then' >> /usr/bin/$RESTORE_FROM_FRIEND_SCRIPT_NAME
4723
   echo '  if [ ! "$?" = "0" ]; then' >> /usr/bin/$RESTORE_FROM_FRIEND_SCRIPT_NAME
4521
   echo '    exit 868' >> /usr/bin/$RESTORE_FROM_FRIEND_SCRIPT_NAME
4724
   echo '    exit 868' >> /usr/bin/$RESTORE_FROM_FRIEND_SCRIPT_NAME
4522
   echo '  fi' >> /usr/bin/$RESTORE_FROM_FRIEND_SCRIPT_NAME
4725
   echo '  fi' >> /usr/bin/$RESTORE_FROM_FRIEND_SCRIPT_NAME
4523
   restore_directory_from_friend /root/tempwiki2 wiki2
4726
   restore_directory_from_friend /root/tempwiki2 wiki2
4524
-  echo "  cp -r /root/tempwiki2/remoterestore/backup/wiki2/dokuwiki/* /etc/dokuwiki/" >> /usr/bin/$RESTORE_FROM_FRIEND_SCRIPT_NAME
4727
+  if [[ $BACKUP_TYPE != 'obnam' ]]; then
4728
+      RESTORE_SUBDIR='remoterestore/backup/wiki2'
4729
+  fi
4730
+  echo "  cp -r /root/tempwiki2/${RESTORE_SUBDIR}/dokuwiki/* /etc/dokuwiki/" >> /usr/bin/$RESTORE_FROM_FRIEND_SCRIPT_NAME
4525
   echo '  if [ ! "$?" = "0" ]; then' >> /usr/bin/$RESTORE_FROM_FRIEND_SCRIPT_NAME
4731
   echo '  if [ ! "$?" = "0" ]; then' >> /usr/bin/$RESTORE_FROM_FRIEND_SCRIPT_NAME
4526
   echo '    exit 869' >> /usr/bin/$RESTORE_FROM_FRIEND_SCRIPT_NAME
4732
   echo '    exit 869' >> /usr/bin/$RESTORE_FROM_FRIEND_SCRIPT_NAME
4527
   echo '  fi' >> /usr/bin/$RESTORE_FROM_FRIEND_SCRIPT_NAME
4733
   echo '  fi' >> /usr/bin/$RESTORE_FROM_FRIEND_SCRIPT_NAME
4535
   echo 'fi' >> /usr/bin/$RESTORE_FROM_FRIEND_SCRIPT_NAME
4741
   echo 'fi' >> /usr/bin/$RESTORE_FROM_FRIEND_SCRIPT_NAME
4536
   echo '' >> /usr/bin/$RESTORE_FROM_FRIEND_SCRIPT_NAME
4742
   echo '' >> /usr/bin/$RESTORE_FROM_FRIEND_SCRIPT_NAME
4537
 
4743
 
4744
+  RESTORE_SUBDIR='root'
4745
+  if [[ $BACKUP_TYPE != 'obnam' ]]; then
4746
+      RESTORE_SUBDIR='remoterestore/backup/blog'
4747
+  fi
4538
   echo 'if [ -d $SERVER_DIRECTORY/backup/blog ]; then' >> /usr/bin/$RESTORE_FROM_FRIEND_SCRIPT_NAME
4748
   echo 'if [ -d $SERVER_DIRECTORY/backup/blog ]; then' >> /usr/bin/$RESTORE_FROM_FRIEND_SCRIPT_NAME
4539
   echo '  echo "Restoring blog installation"' >> /usr/bin/$RESTORE_FROM_FRIEND_SCRIPT_NAME
4749
   echo '  echo "Restoring blog installation"' >> /usr/bin/$RESTORE_FROM_FRIEND_SCRIPT_NAME
4540
   echo '  mkdir /root/tempblog' >> /usr/bin/$RESTORE_FROM_FRIEND_SCRIPT_NAME
4750
   echo '  mkdir /root/tempblog' >> /usr/bin/$RESTORE_FROM_FRIEND_SCRIPT_NAME
4541
   restore_directory_from_friend /root/tempblog blog
4751
   restore_directory_from_friend /root/tempblog blog
4542
   echo "  rm -rf /var/www/$FULLBLOG_DOMAIN_NAME/htdocs" >> /usr/bin/$RESTORE_FROM_FRIEND_SCRIPT_NAME
4752
   echo "  rm -rf /var/www/$FULLBLOG_DOMAIN_NAME/htdocs" >> /usr/bin/$RESTORE_FROM_FRIEND_SCRIPT_NAME
4543
-  echo "  cp -r /root/tempblog/remoterestore/backup/blog/www/$FULLBLOG_DOMAIN_NAME/htdocs /var/www/$FULLBLOG_DOMAIN_NAME/" >> /usr/bin/$RESTORE_FROM_FRIEND_SCRIPT_NAME
4753
+  echo "  cp -r /root/tempblog/${RESTORE_SUBDIR}/www/$FULLBLOG_DOMAIN_NAME/htdocs /var/www/$FULLBLOG_DOMAIN_NAME/" >> /usr/bin/$RESTORE_FROM_FRIEND_SCRIPT_NAME
4544
   echo '  if [ ! "$?" = "0" ]; then' >> /usr/bin/$RESTORE_FROM_FRIEND_SCRIPT_NAME
4754
   echo '  if [ ! "$?" = "0" ]; then' >> /usr/bin/$RESTORE_FROM_FRIEND_SCRIPT_NAME
4545
   echo '    exit 593' >> /usr/bin/$RESTORE_FROM_FRIEND_SCRIPT_NAME
4755
   echo '    exit 593' >> /usr/bin/$RESTORE_FROM_FRIEND_SCRIPT_NAME
4546
   echo '  fi' >> /usr/bin/$RESTORE_FROM_FRIEND_SCRIPT_NAME
4756
   echo '  fi' >> /usr/bin/$RESTORE_FROM_FRIEND_SCRIPT_NAME
4556
   echo 'fi' >> /usr/bin/$RESTORE_FROM_FRIEND_SCRIPT_NAME
4766
   echo 'fi' >> /usr/bin/$RESTORE_FROM_FRIEND_SCRIPT_NAME
4557
   echo '' >> /usr/bin/$RESTORE_FROM_FRIEND_SCRIPT_NAME
4767
   echo '' >> /usr/bin/$RESTORE_FROM_FRIEND_SCRIPT_NAME
4558
 
4768
 
4769
+  RESTORE_SUBDIR='root'
4770
+  if [[ $BACKUP_TYPE != 'obnam' ]]; then
4771
+      RESTORE_SUBDIR='remoterestore/backup/cjdns'
4772
+  fi
4559
   echo 'if [ -d $SERVER_DIRECTORY/backup/cjdns ]; then' >> /usr/bin/$RESTORE_FROM_FRIEND_SCRIPT_NAME
4773
   echo 'if [ -d $SERVER_DIRECTORY/backup/cjdns ]; then' >> /usr/bin/$RESTORE_FROM_FRIEND_SCRIPT_NAME
4560
   echo '  echo "Restoring cjdns installation"' >> /usr/bin/$RESTORE_FROM_FRIEND_SCRIPT_NAME
4774
   echo '  echo "Restoring cjdns installation"' >> /usr/bin/$RESTORE_FROM_FRIEND_SCRIPT_NAME
4561
   restore_directory_from_friend /root/tempcjdns cjdns
4775
   restore_directory_from_friend /root/tempcjdns cjdns
4562
   echo "  rm -rf /etc/cjdns" >> /usr/bin/$RESTORE_FROM_FRIEND_SCRIPT_NAME
4776
   echo "  rm -rf /etc/cjdns" >> /usr/bin/$RESTORE_FROM_FRIEND_SCRIPT_NAME
4563
-  echo "  cp -r /root/tempcjdns/remoterestore/backup/cjdns/cjdns /etc/" >> /usr/bin/$RESTORE_FROM_FRIEND_SCRIPT_NAME
4777
+  echo "  cp -r /root/tempcjdns/${RESTORE_SUBDIR}/cjdns /etc/" >> /usr/bin/$RESTORE_FROM_FRIEND_SCRIPT_NAME
4564
   echo '  if [ ! "$?" = "0" ]; then' >> /usr/bin/$RESTORE_FROM_FRIEND_SCRIPT_NAME
4778
   echo '  if [ ! "$?" = "0" ]; then' >> /usr/bin/$RESTORE_FROM_FRIEND_SCRIPT_NAME
4565
   echo '    exit 7438' >> /usr/bin/$RESTORE_FROM_FRIEND_SCRIPT_NAME
4779
   echo '    exit 7438' >> /usr/bin/$RESTORE_FROM_FRIEND_SCRIPT_NAME
4566
   echo '  fi' >> /usr/bin/$RESTORE_FROM_FRIEND_SCRIPT_NAME
4780
   echo '  fi' >> /usr/bin/$RESTORE_FROM_FRIEND_SCRIPT_NAME
4568
   echo 'fi' >> /usr/bin/$RESTORE_FROM_FRIEND_SCRIPT_NAME
4782
   echo 'fi' >> /usr/bin/$RESTORE_FROM_FRIEND_SCRIPT_NAME
4569
   echo '' >> /usr/bin/$RESTORE_FROM_FRIEND_SCRIPT_NAME
4783
   echo '' >> /usr/bin/$RESTORE_FROM_FRIEND_SCRIPT_NAME
4570
 
4784
 
4785
+  RESTORE_SUBDIR='root'
4786
+  if [[ $BACKUP_TYPE != 'obnam' ]]; then
4787
+      RESTORE_SUBDIR='remoterestore/backup/voip'
4788
+  fi
4571
   echo 'if [ -d $SERVER_DIRECTORY/backup/voip ]; then' >> /usr/bin/$RESTORE_FROM_FRIEND_SCRIPT_NAME
4789
   echo 'if [ -d $SERVER_DIRECTORY/backup/voip ]; then' >> /usr/bin/$RESTORE_FROM_FRIEND_SCRIPT_NAME
4572
   echo '  echo "Restoring VoIP settings"' >> /usr/bin/$RESTORE_FROM_FRIEND_SCRIPT_NAME
4790
   echo '  echo "Restoring VoIP settings"' >> /usr/bin/$RESTORE_FROM_FRIEND_SCRIPT_NAME
4573
   restore_directory_from_friend /root/tempvoip voip
4791
   restore_directory_from_friend /root/tempvoip voip
4574
-  echo -n '  cp -f /root/tempvoip/remoterestore/backup/voip/$MY_USERNAME/tempbackup/' >> /usr/bin/$RESTORE_FROM_FRIEND_SCRIPT_NAME
4792
+  echo -n "  cp -f /root/tempvoip/${RESTORE_SUBDIR}" >> /usr/bin/$RESTORE_FROM_FRIEND_SCRIPT_NAME
4793
+  echo -n '/$MY_USERNAME/tempbackup/' >> /usr/bin/$RESTORE_FROM_FRIEND_SCRIPT_NAME
4575
   echo "$VOIP_CONFIG_FILE /etc/" >> /usr/bin/$RESTORE_FROM_FRIEND_SCRIPT_NAME
4794
   echo "$VOIP_CONFIG_FILE /etc/" >> /usr/bin/$RESTORE_FROM_FRIEND_SCRIPT_NAME
4576
-  echo -n '  cp -f /root/tempvoip/remoterestore/backup/voip/$MY_USERNAME/tempbackup/' >> /usr/bin/$RESTORE_FROM_FRIEND_SCRIPT_NAME
4795
+  echo -n "  cp -f /root/tempvoip/${RESTORE_SUBDIR}/" >> /usr/bin/$RESTORE_FROM_FRIEND_SCRIPT_NAME
4796
+  echo -n '$MY_USERNAME/tempbackup/' >> /usr/bin/$RESTORE_FROM_FRIEND_SCRIPT_NAME
4577
   echo "$VOIP_DATABASE /var/lib/mumble-server/" >> /usr/bin/$RESTORE_FROM_FRIEND_SCRIPT_NAME
4797
   echo "$VOIP_DATABASE /var/lib/mumble-server/" >> /usr/bin/$RESTORE_FROM_FRIEND_SCRIPT_NAME
4578
   echo '  if [ ! "$?" = "0" ]; then' >> /usr/bin/$RESTORE_FROM_FRIEND_SCRIPT_NAME
4798
   echo '  if [ ! "$?" = "0" ]; then' >> /usr/bin/$RESTORE_FROM_FRIEND_SCRIPT_NAME
4579
   echo '    rm -rf /root/tempvoip' >> /usr/bin/$RESTORE_FROM_FRIEND_SCRIPT_NAME
4799
   echo '    rm -rf /root/tempvoip' >> /usr/bin/$RESTORE_FROM_FRIEND_SCRIPT_NAME
4601
   echo 'fi' >> /usr/bin/$RESTORE_FROM_FRIEND_SCRIPT_NAME
4821
   echo 'fi' >> /usr/bin/$RESTORE_FROM_FRIEND_SCRIPT_NAME
4602
   echo '' >> /usr/bin/$RESTORE_FROM_FRIEND_SCRIPT_NAME
4822
   echo '' >> /usr/bin/$RESTORE_FROM_FRIEND_SCRIPT_NAME
4603
 
4823
 
4824
+  RESTORE_SUBDIR='root'
4825
+  if [[ $BACKUP_TYPE != 'obnam' ]]; then
4826
+      RESTORE_SUBDIR='remoterestore/backup/mail'
4827
+  fi
4604
   echo 'if [ -d $SERVER_DIRECTORY/backup/mail ]; then' >> /usr/bin/$RESTORE_FROM_FRIEND_SCRIPT_NAME
4828
   echo 'if [ -d $SERVER_DIRECTORY/backup/mail ]; then' >> /usr/bin/$RESTORE_FROM_FRIEND_SCRIPT_NAME
4605
   echo '  echo "Restoring emails"' >> /usr/bin/$RESTORE_FROM_FRIEND_SCRIPT_NAME
4829
   echo '  echo "Restoring emails"' >> /usr/bin/$RESTORE_FROM_FRIEND_SCRIPT_NAME
4606
   restore_directory_from_friend /root/tempmail mail
4830
   restore_directory_from_friend /root/tempmail mail
4607
   echo '  if [ ! -d /home/$MY_USERNAME/Maildir ]; then' >> /usr/bin/$RESTORE_FROM_FRIEND_SCRIPT_NAME
4831
   echo '  if [ ! -d /home/$MY_USERNAME/Maildir ]; then' >> /usr/bin/$RESTORE_FROM_FRIEND_SCRIPT_NAME
4608
   echo '    mkdir /home/$MY_USERNAME/Maildir' >> /usr/bin/$RESTORE_FROM_FRIEND_SCRIPT_NAME
4832
   echo '    mkdir /home/$MY_USERNAME/Maildir' >> /usr/bin/$RESTORE_FROM_FRIEND_SCRIPT_NAME
4609
   echo '  fi' >> /usr/bin/$RESTORE_FROM_FRIEND_SCRIPT_NAME
4833
   echo '  fi' >> /usr/bin/$RESTORE_FROM_FRIEND_SCRIPT_NAME
4610
-  echo '  tar -xzvf /root/tempmail/usb/backup/mail/backupemail/maildir.tar.gz -C /' >> /usr/bin/$RESTORE_FROM_FRIEND_SCRIPT_NAME
4834
+  echo "  tar -xzvf /root/tempmail/${RESTORE_SUBDIR}/backupemail/maildir.tar.gz -C /" >> /usr/bin/$RESTORE_FROM_FRIEND_SCRIPT_NAME
4611
   echo '  if [ ! "$?" = "0" ]; then' >> /usr/bin/$RESTORE_FROM_FRIEND_SCRIPT_NAME
4835
   echo '  if [ ! "$?" = "0" ]; then' >> /usr/bin/$RESTORE_FROM_FRIEND_SCRIPT_NAME
4612
   echo '    exit 927' >> /usr/bin/$RESTORE_FROM_FRIEND_SCRIPT_NAME
4836
   echo '    exit 927' >> /usr/bin/$RESTORE_FROM_FRIEND_SCRIPT_NAME
4613
   echo '  fi' >> /usr/bin/$RESTORE_FROM_FRIEND_SCRIPT_NAME
4837
   echo '  fi' >> /usr/bin/$RESTORE_FROM_FRIEND_SCRIPT_NAME
4615
   echo 'fi' >> /usr/bin/$RESTORE_FROM_FRIEND_SCRIPT_NAME
4839
   echo 'fi' >> /usr/bin/$RESTORE_FROM_FRIEND_SCRIPT_NAME
4616
   echo '' >> /usr/bin/$RESTORE_FROM_FRIEND_SCRIPT_NAME
4840
   echo '' >> /usr/bin/$RESTORE_FROM_FRIEND_SCRIPT_NAME
4617
 
4841
 
4842
+  RESTORE_SUBDIR='root'
4843
+  if [[ $BACKUP_TYPE != 'obnam' ]]; then
4844
+      RESTORE_SUBDIR='remoterestore/backup/dlna'
4845
+  fi
4618
   echo "if [ -d /var/cache/minidlna ]; then" >> /usr/bin/$RESTORE_FROM_FRIEND_SCRIPT_NAME
4846
   echo "if [ -d /var/cache/minidlna ]; then" >> /usr/bin/$RESTORE_FROM_FRIEND_SCRIPT_NAME
4619
   echo '  if [ -d $SERVER_DIRECTORY/backup/dlna ]; then' >> /usr/bin/$RESTORE_FROM_FRIEND_SCRIPT_NAME
4847
   echo '  if [ -d $SERVER_DIRECTORY/backup/dlna ]; then' >> /usr/bin/$RESTORE_FROM_FRIEND_SCRIPT_NAME
4620
   echo '    echo "Restoring DLNA cache"' >> /usr/bin/$RESTORE_FROM_FRIEND_SCRIPT_NAME
4848
   echo '    echo "Restoring DLNA cache"' >> /usr/bin/$RESTORE_FROM_FRIEND_SCRIPT_NAME
4621
   restore_directory_from_friend /root/tempdlna dlna
4849
   restore_directory_from_friend /root/tempdlna dlna
4622
-  echo "    cp -r /root/tempdlna/remoterestore/backup/dlna/cache/minidlna/* /var/cache/minidlna/" >> /usr/bin/$RESTORE_FROM_FRIEND_SCRIPT_NAME
4850
+  echo "    cp -r /root/tempdlna/${RESTORE_SUBDIR}/cache/minidlna/* /var/cache/minidlna/" >> /usr/bin/$RESTORE_FROM_FRIEND_SCRIPT_NAME
4623
   echo '    if [ ! "$?" = "0" ]; then' >> /usr/bin/$RESTORE_FROM_FRIEND_SCRIPT_NAME
4851
   echo '    if [ ! "$?" = "0" ]; then' >> /usr/bin/$RESTORE_FROM_FRIEND_SCRIPT_NAME
4624
   echo '      exit 982' >> /usr/bin/$RESTORE_FROM_FRIEND_SCRIPT_NAME
4852
   echo '      exit 982' >> /usr/bin/$RESTORE_FROM_FRIEND_SCRIPT_NAME
4625
   echo '    fi' >> /usr/bin/$RESTORE_FROM_FRIEND_SCRIPT_NAME
4853
   echo '    fi' >> /usr/bin/$RESTORE_FROM_FRIEND_SCRIPT_NAME