浏览代码

Backup and restore prosody

Bob Mottram 10 年前
父节点
当前提交
9eb1335a90
共有 1 个文件被更改,包括 31 次插入5 次删除
  1. 31
    5
      install-freedombone.sh

+ 31
- 5
install-freedombone.sh 查看文件

@@ -97,6 +97,8 @@ INSTALLED_WITHIN_DOCKER="no"
97 97
 PUBLIC_MAILING_LIST=
98 98
 # Optional different domain name for the public mailing list
99 99
 PUBLIC_MAILING_LIST_DOMAIN_NAME=
100
+# Directory where the public mailing list data is stored
101
+PUBLIC_MAILING_LIST_DIRECTORY="/var/spool/mlmmj"
100 102
 
101 103
 # If you want to run an encrypted mailing list specify its name here.
102 104
 # There should be no spaces in the name
@@ -202,6 +204,9 @@ MAX_PHP_MEMORY=32
202 204
 # default MariaDB password
203 205
 MARIADB_PASSWORD=
204 206
 
207
+# Directory where XMPP settings are stored
208
+XMPP_DIRECTORY="/var/lib/prosody"
209
+
205 210
 # file containing a list of remote locations to backup to
206 211
 FRIENDS_SERVERS_LIST=/home/$MY_USERNAME/backup.list
207 212
 
@@ -429,6 +434,13 @@ function search_for_attached_usb_drive {
429 434
               MY_GPG_PUBLIC_KEY=$USB_MOUNT/public_key.gpg
430 435
           fi
431 436
       fi
437
+      if [ -d $USB_MOUNT/prosody ]; then
438
+          if [ ! -d $XMPP_DIRECTORY ]; then
439
+              mkdir $XMPP_DIRECTORY
440
+          fi
441
+          cp -r $USB_MOUNT/prosody/* $XMPP_DIRECTORY
442
+          chown -R prosody:prosody $XMPP_DIRECTORY
443
+      fi
432 444
       if [ -d $USB_MOUNT/.ssh ]; then
433 445
           echo 'Importing ssh keys'
434 446
           cp -r $USB_MOUNT/.ssh /home/$MY_USERNAME
@@ -3657,13 +3669,27 @@ function backup_to_friends_servers {
3657 3669
   echo '    exit 2' >> /usr/bin/backup2friends
3658 3670
   echo 'fi' >> /usr/bin/backup2friends
3659 3671
   echo '' >> /usr/bin/backup2friends
3672
+  echo "if [ ! -d /home/$MY_USERNAME/backups ]; then" >> /usr/bin/backup2friends
3673
+  echo "  mkdir /home/$MY_USERNAME/backups" >> /usr/bin/backup2friends
3674
+  echo 'fi' >> /usr/bin/backup2friends
3675
+  echo '' >> /usr/bin/backup2friends
3676
+  echo '# Backup the public mailing list' >> /usr/bin/backup2friends
3677
+  echo "if [ -d $PUBLIC_MAILING_LIST_DIRECTORY ]; then" >> /usr/bin/backup2friends
3678
+  echo "  tar -czvf /home/$MY_USERNAME/backups/mailinglist.tar.gz $PUBLIC_MAILING_LIST_DIRECTORY" >> /usr/bin/backup2friends
3679
+  echo 'fi' >> /usr/bin/backup2friends
3680
+  echo '' >> /usr/bin/backup2friends
3681
+  echo '# Backup XMPP settings' >> /usr/bin/backup2friends
3682
+  echo "if [ -d $XMPP_DIRECTORY ]; then" >> /usr/bin/backup2friends
3683
+  echo "  tar -czvf /home/$MY_USERNAME/backups/xmpp.tar.gz $XMPP_DIRECTORY" >> /usr/bin/backup2friends
3684
+  echo 'fi' >> /usr/bin/backup2friends
3685
+  echo '' >> /usr/bin/backup2friends
3660 3686
   echo 'while read remote_server' >> /usr/bin/backup2friends
3661 3687
   echo 'do' >> /usr/bin/backup2friends
3662
-  echo '    SERVER="${* %%remote_server}"' >> /usr/bin/backup2friends
3663
-  echo '    FTP_PASSWORD="${remote_server%% *}"' >> /usr/bin/backup2friends
3664
-  echo "    duplicity incr --ssh-askpass --encrypt-key $GPG_KEY --full-if-older-than 4W --exclude-other-filesystems /home/$MY_USERNAME $SERVER" >> /usr/bin/backup2friends
3665
-  echo '    duplicity --ssh-askpass --force cleanup $SERVER' >> /usr/bin/backup2friends
3666
-  echo '    duplicity --ssh-askpass --force remove-all-but-n-full 2 $SERVER' >> /usr/bin/backup2friends
3688
+  echo '  SERVER="${* %%remote_server}"' >> /usr/bin/backup2friends
3689
+  echo '  FTP_PASSWORD="${remote_server%% *}"' >> /usr/bin/backup2friends
3690
+  echo "  duplicity incr --ssh-askpass --encrypt-key $GPG_KEY --full-if-older-than 4W --exclude-other-filesystems /home/$MY_USERNAME $SERVER" >> /usr/bin/backup2friends
3691
+  echo '  duplicity --ssh-askpass --force cleanup $SERVER' >> /usr/bin/backup2friends
3692
+  echo '  duplicity --ssh-askpass --force remove-all-but-n-full 2 $SERVER' >> /usr/bin/backup2friends
3667 3693
   echo "done < $FRIENDS_SERVERS_LIST" >> /usr/bin/backup2friends
3668 3694
   echo 'exit 0' >> /usr/bin/backup2friends
3669 3695
   chmod +x /usr/bin/backup2friends