From c3a57e75ba8cff3cf41ccdd05c7e6452b90f4dd8 Mon Sep 17 00:00:00 2001 From: Bob Mottram Date: Sun, 26 Apr 2015 21:16:35 +0100 Subject: [PATCH] Backup and restore learned spamassassin settings --- src/freedombone | 24 ++++++------------------ 1 file changed, 6 insertions(+), 18 deletions(-) diff --git a/src/freedombone b/src/freedombone index 9e8aa7a6..e38c3ea3 100755 --- a/src/freedombone +++ b/src/freedombone @@ -2036,23 +2036,17 @@ function create_backup_script { echo '' >> /usr/bin/$BACKUP_SCRIPT_NAME echo '# Backup spamassassin settings' >> /usr/bin/$BACKUP_SCRIPT_NAME - echo "if [ -f /home/$MY_USERNAME/.spamassassin ]; then" >> /usr/bin/$BACKUP_SCRIPT_NAME + echo "if [ -d /home/$MY_USERNAME/.spamassassin ]; then" >> /usr/bin/$BACKUP_SCRIPT_NAME echo ' echo "Backing up spamassassin settings"' >> /usr/bin/$BACKUP_SCRIPT_NAME - echo " if [ ! -d /home/$MY_USERNAME/tempbackup ]; then" >> /usr/bin/$BACKUP_SCRIPT_NAME - echo " mkdir -p /home/$MY_USERNAME/tempbackup" >> /usr/bin/$BACKUP_SCRIPT_NAME - echo ' fi' >> /usr/bin/$BACKUP_SCRIPT_NAME - echo " cp /home/$MY_USERNAME/.spamassassin /home/$MY_USERNAME/tempbackup" >> /usr/bin/$BACKUP_SCRIPT_NAME echo " if [ ! -d $USB_MOUNT/backup/spamassassin ]; then" >> /usr/bin/$BACKUP_SCRIPT_NAME echo " mkdir -p $USB_MOUNT/backup/spamassassin" >> /usr/bin/$BACKUP_SCRIPT_NAME echo ' fi' >> /usr/bin/$BACKUP_SCRIPT_NAME - echo " rsyncrypto -v -r /home/$MY_USERNAME/tempbackup $USB_MOUNT/backup/spamassassin $USB_MOUNT/backup/spamassassin.keys $BACKUP_CERTIFICATE" >> /usr/bin/$BACKUP_SCRIPT_NAME + echo " rsyncrypto -v -r /home/$MY_USERNAME/.spamassassin $USB_MOUNT/backup/spamassassin $USB_MOUNT/backup/spamassassin.keys $BACKUP_CERTIFICATE" >> /usr/bin/$BACKUP_SCRIPT_NAME echo ' if [ ! "$?" = "0" ]; then' >> /usr/bin/$BACKUP_SCRIPT_NAME echo " umount $USB_MOUNT" >> /usr/bin/$BACKUP_SCRIPT_NAME echo " rm -rf $USB_MOUNT" >> /usr/bin/$BACKUP_SCRIPT_NAME - echo " rm -rf /home/$MY_USERNAME/tempbackup" >> /usr/bin/$BACKUP_SCRIPT_NAME echo ' exit 492' >> /usr/bin/$BACKUP_SCRIPT_NAME echo ' fi' >> /usr/bin/$BACKUP_SCRIPT_NAME - echo " rm -rf /home/$MY_USERNAME/tempbackup" >> /usr/bin/$BACKUP_SCRIPT_NAME echo 'fi' >> /usr/bin/$BACKUP_SCRIPT_NAME echo '' >> /usr/bin/$BACKUP_SCRIPT_NAME @@ -2355,7 +2349,7 @@ function create_restore_script { echo ' echo "Restoring spamassassin settings"' >> /usr/bin/$RESTORE_SCRIPT_NAME echo ' mkdir /root/tempspamassassin' >> /usr/bin/$RESTORE_SCRIPT_NAME echo " rsyncrypto -v -d -r $USB_MOUNT/backup/spamassassin /root/tempspamassassin $USB_MOUNT/backup/spamassassin.keys $BACKUP_CERTIFICATE" >> /usr/bin/$RESTORE_SCRIPT_NAME - echo " cp -f /root/tempspamassassin/usb/backup/spamassassin/$MY_USERNAME/tempbackup/.spamassassin /home/$MY_USERNAME/" >> /usr/bin/$RESTORE_SCRIPT_NAME + echo " cp -rf /root/tempspamassassin/usb/backup/spamassassin/$MY_USERNAME/.spamassassin /home/$MY_USERNAME/" >> /usr/bin/$RESTORE_SCRIPT_NAME echo ' if [ ! "$?" = "0" ]; then' >> /usr/bin/$RESTORE_SCRIPT_NAME echo " umount $USB_MOUNT" >> /usr/bin/$RESTORE_SCRIPT_NAME echo " rm -rf $USB_MOUNT" >> /usr/bin/$RESTORE_SCRIPT_NAME @@ -3483,26 +3477,20 @@ function backup_to_friends_servers { echo '' >> /usr/bin/$BACKUP_TO_FRIENDS_SCRIPT_NAME echo '# Backup spamassassin settings' >> /usr/bin/$BACKUP_TO_FRIENDS_SCRIPT_NAME - echo "if [ -f /home/$MY_USERNAME/.spamassassinrc ]; then" >> /usr/bin/$BACKUP_TO_FRIENDS_SCRIPT_NAME + echo "if [ -d /home/$MY_USERNAME/.spamassassin ]; then" >> /usr/bin/$BACKUP_TO_FRIENDS_SCRIPT_NAME echo ' echo "Backing up spamassassin settings"' >> /usr/bin/$BACKUP_TO_FRIENDS_SCRIPT_NAME - echo " if [ ! -d /home/$MY_USERNAME/tempbackup ]; then" >> /usr/bin/$BACKUP_TO_FRIENDS_SCRIPT_NAME - echo " mkdir -p /home/$MY_USERNAME/tempbackup" >> /usr/bin/$BACKUP_TO_FRIENDS_SCRIPT_NAME - echo ' fi' >> /usr/bin/$BACKUP_TO_FRIENDS_SCRIPT_NAME - echo " cp /home/$MY_USERNAME/.spamassassinrc /home/$MY_USERNAME/tempbackup" >> /usr/bin/$BACKUP_TO_FRIENDS_SCRIPT_NAME echo ' if [ ! -d $SERVER_DIRECTORY/backup/spamassassin ]; then' >> /usr/bin/$BACKUP_TO_FRIENDS_SCRIPT_NAME echo ' mkdir -p $SERVER_DIRECTORY/backup/spamassassin' >> /usr/bin/$BACKUP_TO_FRIENDS_SCRIPT_NAME echo ' fi' >> /usr/bin/$BACKUP_TO_FRIENDS_SCRIPT_NAME - echo -n " rsyncrypto -v -r /home/$MY_USERNAME/tempbackup " >> /usr/bin/$BACKUP_TO_FRIENDS_SCRIPT_NAME + echo -n " rsyncrypto -v -r /home/$MY_USERNAME/.spamassassin " >> /usr/bin/$BACKUP_TO_FRIENDS_SCRIPT_NAME echo -n '$SERVER_DIRECTORY/backup/spamassassin $SERVER_DIRECTORY/backup/spamassassin.keys ' >> /usr/bin/$BACKUP_TO_FRIENDS_SCRIPT_NAME echo "$BACKUP_CERTIFICATE" >> /usr/bin/$BACKUP_TO_FRIENDS_SCRIPT_NAME echo ' if [ ! "$?" = "0" ]; then' >> /usr/bin/$BACKUP_TO_FRIENDS_SCRIPT_NAME - echo ' rm -rf /home/$MY_USERNAME/tempbackup' >> /usr/bin/$BACKUP_TO_FRIENDS_SCRIPT_NAME echo ' # Send a warning email' >> /usr/bin/$BACKUP_TO_FRIENDS_SCRIPT_NAME echo -n ' echo "Unable to encrypt spamassassin settings" | mail -s "Freedombone backup to friends" ' >> /usr/bin/$BACKUP_TO_FRIENDS_SCRIPT_NAME echo "$MY_EMAIL_ADDRESS" >> /usr/bin/$BACKUP_TO_FRIENDS_SCRIPT_NAME echo ' exit 492' >> /usr/bin/$BACKUP_TO_FRIENDS_SCRIPT_NAME echo ' fi' >> /usr/bin/$BACKUP_TO_FRIENDS_SCRIPT_NAME - echo ' rm -rf /home/$MY_USERNAME/tempbackup' >> /usr/bin/$BACKUP_TO_FRIENDS_SCRIPT_NAME echo 'fi' >> /usr/bin/$BACKUP_TO_FRIENDS_SCRIPT_NAME echo '' >> /usr/bin/$BACKUP_TO_FRIENDS_SCRIPT_NAME @@ -3855,7 +3843,7 @@ function restore_from_friend { echo ' mkdir /root/tempspamassassin' >> /usr/bin/$RESTORE_FROM_FRIEND_SCRIPT_NAME echo -n ' rsyncrypto -v -d -r $SERVER_DIRECTORY/backup/spamassassin /root/tempspamassassin $SERVER_DIRECTORY/backup/spamassassin.keys ' >> /usr/bin/$RESTORE_FROM_FRIEND_SCRIPT_NAME echo "$BACKUP_CERTIFICATE" >> /usr/bin/$RESTORE_FROM_FRIEND_SCRIPT_NAME - echo " cp -f /root/tempspamassassin/remoterestore/backup/spamassassin/$MY_USERNAME/tempbackup/.spamassassinrc /home/$MY_USERNAME/" >> /usr/bin/$RESTORE_FROM_FRIEND_SCRIPT_NAME + echo " cp -rf /root/tempspamassassin/remoterestore/backup/spamassassin/$MY_USERNAME/.spamassassin /home/$MY_USERNAME/" >> /usr/bin/$RESTORE_FROM_FRIEND_SCRIPT_NAME echo ' if [ ! "$?" = "0" ]; then' >> /usr/bin/$RESTORE_FROM_FRIEND_SCRIPT_NAME echo ' rm -rf /root/tempspamassassin' >> /usr/bin/$RESTORE_FROM_FRIEND_SCRIPT_NAME echo ' exit 276' >> /usr/bin/$RESTORE_FROM_FRIEND_SCRIPT_NAME