From da8e8eca550605fee38e511acecc7eb15ca86eb9 Mon Sep 17 00:00:00 2001 From: Bob Mottram Date: Tue, 27 Jan 2015 19:54:10 +0000 Subject: [PATCH] Backup voip data --- src/freedombone | 83 +++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 83 insertions(+) diff --git a/src/freedombone b/src/freedombone index b44701da..18e4be85 100755 --- a/src/freedombone +++ b/src/freedombone @@ -286,6 +286,10 @@ VOIP_SERVER_PASSWORD= # Port on which VoIP server listens VOIP_PORT=64738 +# Location of VoIP database and configuration +VOIP_DATABASE="mumble-server.sqlite" +VOIP_CONFIG_FILE="mumble-server.ini" + # other possible services to obtain the external IP address EXTERNAL_IP_SERVICES=( \ 'https://check.torproject.org/' \ @@ -2127,6 +2131,28 @@ function create_backup_script { echo 'fi' >> /usr/bin/$BACKUP_SCRIPT_NAME echo '' >> /usr/bin/$BACKUP_SCRIPT_NAME + echo '# Backup VoIP settings' >> /usr/bin/$BACKUP_SCRIPT_NAME + echo "if [ -f /etc/$VOIP_CONFIG_FILE ]; then" >> /usr/bin/$BACKUP_SCRIPT_NAME + echo ' echo "Backing up VoIP 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 -f /etc/$VOIP_CONFIG_FILE /home/$MY_USERNAME/tempbackup" >> /usr/bin/$BACKUP_SCRIPT_NAME + echo " cp -f /var/lib/mumble-server/$VOIP_DATABASE /home/$MY_USERNAME/tempbackup" >> /usr/bin/$BACKUP_SCRIPT_NAME + echo " if [ ! -d $USB_MOUNT/backup/voip ]; then" >> /usr/bin/$BACKUP_SCRIPT_NAME + echo " mkdir -p $USB_MOUNT/backup/voip" >> /usr/bin/$BACKUP_SCRIPT_NAME + echo ' fi' >> /usr/bin/$BACKUP_SCRIPT_NAME + echo " rsyncrypto -v -r /home/$MY_USERNAME/tempbackup $USB_MOUNT/backup/voip $USB_MOUNT/backup/voip.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 2492' >> /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 + if [[ $BACKUP_INCLUDES_DATABASES == "yes" ]]; then echo '# Mysql settings' >> /usr/bin/$BACKUP_SCRIPT_NAME echo "if [ ! -d $USB_MOUNT/backup/mariadb ]; then" >> /usr/bin/$BACKUP_SCRIPT_NAME @@ -2695,6 +2721,22 @@ function create_restore_script { echo 'fi' >> /usr/bin/$RESTORE_SCRIPT_NAME echo '' >> /usr/bin/$RESTORE_SCRIPT_NAME + echo "if [ -d $USB_MOUNT/backup/voip ]; then" >> /usr/bin/$RESTORE_SCRIPT_NAME + echo ' echo "Restoring VoIP settings"' >> /usr/bin/$RESTORE_SCRIPT_NAME + echo ' mkdir /root/tempvoip' >> /usr/bin/$RESTORE_SCRIPT_NAME + echo " rsyncrypto -v -d -r $USB_MOUNT/backup/voip /root/tempvoip $USB_MOUNT/backup/voip.keys $BACKUP_CERTIFICATE" >> /usr/bin/$RESTORE_SCRIPT_NAME + echo " cp -f /root/tempvoip/usb/backup/voip/$MY_USERNAME/tempbackup/$VOIP_CONFIG_FILE /etc/" >> /usr/bin/$RESTORE_SCRIPT_NAME + echo " cp -f /root/tempvoip/usb/backup/voip/$MY_USERNAME/tempbackup/$VOIP_DATABASE /var/lib/mumble-server/" >> /usr/bin/$RESTORE_SCRIPT_NAME + echo ' if [ ! "$?" = "0" ]; then' >> /usr/bin/$RESTORE_SCRIPT_NAME + echo " umount $USB_MOUNT" >> /usr/bin/$RESTORE_SCRIPT_NAME + echo " rm -rf $USB_MOUNT" >> /usr/bin/$RESTORE_SCRIPT_NAME + echo ' rm -rf /root/tempvoip' >> /usr/bin/$RESTORE_SCRIPT_NAME + echo ' exit 276' >> /usr/bin/$RESTORE_SCRIPT_NAME + echo ' fi' >> /usr/bin/$RESTORE_SCRIPT_NAME + echo ' rm -rf /root/tempvoip' >> /usr/bin/$RESTORE_SCRIPT_NAME + echo 'fi' >> /usr/bin/$RESTORE_SCRIPT_NAME + echo '' >> /usr/bin/$RESTORE_SCRIPT_NAME + echo 'sync' >> /usr/bin/$RESTORE_SCRIPT_NAME echo '' >> /usr/bin/$RESTORE_SCRIPT_NAME echo "# Unmount the USB drive" >> /usr/bin/$RESTORE_SCRIPT_NAME @@ -3245,6 +3287,32 @@ function backup_to_friends_servers { echo 'fi' >> /usr/bin/$BACKUP_TO_FRIENDS_SCRIPT_NAME echo '' >> /usr/bin/$BACKUP_TO_FRIENDS_SCRIPT_NAME + echo '# Backup VoIP settings' >> /usr/bin/$BACKUP_TO_FRIENDS_SCRIPT_NAME + echo "if [ -f /etc/$VOIP_CONFIG_FILE ]; then" >> /usr/bin/$BACKUP_TO_FRIENDS_SCRIPT_NAME + echo ' echo "Backing up VoIP 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 -f /etc/$VOIP_CONFIG_FILE /home/$MY_USERNAME/tempbackup" >> /usr/bin/$BACKUP_TO_FRIENDS_SCRIPT_NAME + echo " cp -f /var/lib/mumble-server/$VOIP_DATABASE /home/$MY_USERNAME/tempbackup" >> /usr/bin/$BACKUP_TO_FRIENDS_SCRIPT_NAME + echo ' if [ ! -d $SERVER_DIRECTORY/backup/voip ]; then' >> /usr/bin/$BACKUP_TO_FRIENDS_SCRIPT_NAME + echo ' mkdir -p $SERVER_DIRECTORY/backup/voip' >> /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 '$SERVER_DIRECTORY/backup/voip $SERVER_DIRECTORY/backup/voip.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 VoIP 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 4923' >> /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 + + if [[ $BACKUP_INCLUDES_DATABASES == "yes" ]]; then echo '# Mysql settings' >> /usr/bin/$BACKUP_TO_FRIENDS_SCRIPT_NAME echo 'if [ ! -d $SERVER_DIRECTORY/backup/mariadb ]; then' >> /usr/bin/$BACKUP_TO_FRIENDS_SCRIPT_NAME @@ -3808,6 +3876,21 @@ function restore_from_friend { echo 'fi' >> /usr/bin/$RESTORE_FROM_FRIEND_SCRIPT_NAME echo '' >> /usr/bin/$RESTORE_FROM_FRIEND_SCRIPT_NAME + echo 'if [ -d $SERVER_DIRECTORY/backup/voip ]; then' >> /usr/bin/$RESTORE_FROM_FRIEND_SCRIPT_NAME + echo ' echo "Restoring VoIP settings"' >> /usr/bin/$RESTORE_FROM_FRIEND_SCRIPT_NAME + echo ' mkdir /root/tempvoip' >> /usr/bin/$RESTORE_FROM_FRIEND_SCRIPT_NAME + echo -n ' rsyncrypto -v -d -r $SERVER_DIRECTORY/backup/voip /root/tempvoip $SERVER_DIRECTORY/backup/voip.keys ' >> /usr/bin/$RESTORE_FROM_FRIEND_SCRIPT_NAME + echo "$BACKUP_CERTIFICATE" >> /usr/bin/$RESTORE_FROM_FRIEND_SCRIPT_NAME + echo " cp -f /root/tempvoip/remoterestore/backup/voip/$MY_USERNAME/tempbackup/$VOIP_CONFIG_FILE /etc/" >> /usr/bin/$RESTORE_FROM_FRIEND_SCRIPT_NAME + echo " cp -f /root/tempvoip/remoterestore/backup/voip/$MY_USERNAME/tempbackup/$VOIP_DATABASE /var/lib/mumble-server/" >> /usr/bin/$RESTORE_FROM_FRIEND_SCRIPT_NAME + echo ' if [ ! "$?" = "0" ]; then' >> /usr/bin/$RESTORE_FROM_FRIEND_SCRIPT_NAME + echo ' rm -rf /root/tempvoip' >> /usr/bin/$RESTORE_FROM_FRIEND_SCRIPT_NAME + echo ' exit 276' >> /usr/bin/$RESTORE_FROM_FRIEND_SCRIPT_NAME + echo ' fi' >> /usr/bin/$RESTORE_FROM_FRIEND_SCRIPT_NAME + echo ' rm -rf /root/tempvoip' >> /usr/bin/$RESTORE_FROM_FRIEND_SCRIPT_NAME + echo 'fi' >> /usr/bin/$RESTORE_FROM_FRIEND_SCRIPT_NAME + echo '' >> /usr/bin/$RESTORE_FROM_FRIEND_SCRIPT_NAME + echo 'if [ -d $SERVER_DIRECTORY/backup/mail ]; then' >> /usr/bin/$RESTORE_FROM_FRIEND_SCRIPT_NAME echo ' echo "Restoring emails"' >> /usr/bin/$RESTORE_FROM_FRIEND_SCRIPT_NAME echo ' mkdir /root/tempmail' >> /usr/bin/$RESTORE_FROM_FRIEND_SCRIPT_NAME