usb back and restore for multiple users

This commit is contained in:
Bob Mottram 2015-10-25 16:19:16 +00:00
parent 5a3503a080
commit 138db8e90f
1 changed files with 274 additions and 179 deletions

View File

@ -2668,23 +2668,33 @@ function create_backup_script {
echo '' >> /usr/bin/$BACKUP_SCRIPT_NAME
echo '# Backup projects' >> /usr/bin/$BACKUP_SCRIPT_NAME
echo 'if [ -d /home/$MY_USERNAME/projects ]; then' >> /usr/bin/$BACKUP_SCRIPT_NAME
echo ' echo "Backing up projects"' >> /usr/bin/$BACKUP_SCRIPT_NAME
echo ' if [ ! -d $USB_MOUNT/backup/projects ]; then' >> /usr/bin/$BACKUP_SCRIPT_NAME
echo ' mkdir -p $USB_MOUNT/backup/projects' >> /usr/bin/$BACKUP_SCRIPT_NAME
echo 'for d in /home/*/ ; do' >> /usr/bin/$BACKUP_SCRIPT_NAME
echo ' USERNAME=$(echo "$d" | awk -F "/" "{print $3}")' >> /usr/bin/$BACKUP_SCRIPT_NAME
echo ' if [[ $USERNAME != "git" ]]; then' >> /usr/bin/$BACKUP_SCRIPT_NAME
echo ' if [ -d /home/$USERNAME/projects ]; then' >> /usr/bin/$BACKUP_SCRIPT_NAME
echo ' echo "Backing up projects for $USERNAME"' >> /usr/bin/$BACKUP_SCRIPT_NAME
echo ' if [ ! -d $USB_MOUNT/backup/projects/$USERNAME ]; then' >> /usr/bin/$BACKUP_SCRIPT_NAME
echo ' mkdir -p $USB_MOUNT/backup/projects/$USERNAME' >> /usr/bin/$BACKUP_SCRIPT_NAME
echo ' fi' >> /usr/bin/$BACKUP_SCRIPT_NAME
echo ' backup_directory_to_usb /home/$MY_USERNAME/projects projects' >> /usr/bin/$BACKUP_SCRIPT_NAME
echo ' backup_directory_to_usb /home/$USERNAME/projects projects/$USERNAME' >> /usr/bin/$BACKUP_SCRIPT_NAME
echo ' fi' >> /usr/bin/$BACKUP_SCRIPT_NAME
echo ' fi' >> /usr/bin/$BACKUP_SCRIPT_NAME
echo 'done' >> /usr/bin/$BACKUP_SCRIPT_NAME
echo '' >> /usr/bin/$BACKUP_SCRIPT_NAME
echo '# Backup personal settings' >> /usr/bin/$BACKUP_SCRIPT_NAME
echo 'if [ -d /home/$MY_USERNAME/personal ]; then' >> /usr/bin/$BACKUP_SCRIPT_NAME
echo ' echo "Backing up personal settings"' >> /usr/bin/$BACKUP_SCRIPT_NAME
echo ' if [ ! -d $USB_MOUNT/backup/personal ]; then' >> /usr/bin/$BACKUP_SCRIPT_NAME
echo ' mkdir -p $USB_MOUNT/backup/personal' >> /usr/bin/$BACKUP_SCRIPT_NAME
echo 'for d in /home/*/ ; do' >> /usr/bin/$BACKUP_SCRIPT_NAME
echo ' USERNAME=$(echo "$d" | awk -F "/" "{print $3}")' >> /usr/bin/$BACKUP_SCRIPT_NAME
echo ' if [[ $USERNAME != "git" ]]; then' >> /usr/bin/$BACKUP_SCRIPT_NAME
echo ' if [ -d /home/$USERNAME/personal ]; then' >> /usr/bin/$BACKUP_SCRIPT_NAME
echo ' echo "Backing up personal settings for $USERNAME"' >> /usr/bin/$BACKUP_SCRIPT_NAME
echo ' if [ ! -d $USB_MOUNT/backup/personal/$USERNAME ]; then' >> /usr/bin/$BACKUP_SCRIPT_NAME
echo ' mkdir -p $USB_MOUNT/backup/personal/$USERNAME' >> /usr/bin/$BACKUP_SCRIPT_NAME
echo ' fi' >> /usr/bin/$BACKUP_SCRIPT_NAME
echo ' backup_directory_to_usb /home/$MY_USERNAME/personal personal' >> /usr/bin/$BACKUP_SCRIPT_NAME
echo ' backup_directory_to_usb /home/$USERNAME/personal personal/$USERNAME' >> /usr/bin/$BACKUP_SCRIPT_NAME
echo ' fi' >> /usr/bin/$BACKUP_SCRIPT_NAME
echo ' fi' >> /usr/bin/$BACKUP_SCRIPT_NAME
echo 'done' >> /usr/bin/$BACKUP_SCRIPT_NAME
echo '' >> /usr/bin/$BACKUP_SCRIPT_NAME
echo '# Backup the public mailing list' >> /usr/bin/$BACKUP_SCRIPT_NAME
@ -2708,23 +2718,33 @@ function create_backup_script {
echo '' >> /usr/bin/$BACKUP_SCRIPT_NAME
echo '# Backup gpg keys' >> /usr/bin/$BACKUP_SCRIPT_NAME
echo 'if [ -d /home/$MY_USERNAME/.gnupg ]; then' >> /usr/bin/$BACKUP_SCRIPT_NAME
echo ' echo "Backing up gpg keys"' >> /usr/bin/$BACKUP_SCRIPT_NAME
echo ' if [ ! -d $USB_MOUNT/backup/gnupg ]; then' >> /usr/bin/$BACKUP_SCRIPT_NAME
echo ' mkdir -p $USB_MOUNT/backup/gnupg' >> /usr/bin/$BACKUP_SCRIPT_NAME
echo 'for d in /home/*/ ; do' >> /usr/bin/$BACKUP_SCRIPT_NAME
echo ' USERNAME=$(echo "$d" | awk -F "/" "{print $3}")' >> /usr/bin/$BACKUP_SCRIPT_NAME
echo ' if [[ $USERNAME != "git" ]]; then' >> /usr/bin/$BACKUP_SCRIPT_NAME
echo ' if [ -d /home/$USERNAME/.gnupg ]; then' >> /usr/bin/$BACKUP_SCRIPT_NAME
echo ' echo "Backing up gpg keys for $USERNAME"' >> /usr/bin/$BACKUP_SCRIPT_NAME
echo ' if [ ! -d $USB_MOUNT/backup/gnupg/$USERNAME ]; then' >> /usr/bin/$BACKUP_SCRIPT_NAME
echo ' mkdir -p $USB_MOUNT/backup/gnupg/$USERNAME' >> /usr/bin/$BACKUP_SCRIPT_NAME
echo ' fi' >> /usr/bin/$BACKUP_SCRIPT_NAME
echo ' backup_directory_to_usb /home/$MY_USERNAME/.gnupg gnupg' >> /usr/bin/$BACKUP_SCRIPT_NAME
echo ' backup_directory_to_usb /home/$USERNAME/.gnupg gnupg/$USERNAME' >> /usr/bin/$BACKUP_SCRIPT_NAME
echo ' fi' >> /usr/bin/$BACKUP_SCRIPT_NAME
echo ' fi' >> /usr/bin/$BACKUP_SCRIPT_NAME
echo 'done' >> /usr/bin/$BACKUP_SCRIPT_NAME
echo '' >> /usr/bin/$BACKUP_SCRIPT_NAME
echo '# Backup ssh keys' >> /usr/bin/$BACKUP_SCRIPT_NAME
echo 'if [ -d /home/$MY_USERNAME/.ssh ]; then' >> /usr/bin/$BACKUP_SCRIPT_NAME
echo ' echo "Backing up ssh keys"' >> /usr/bin/$BACKUP_SCRIPT_NAME
echo ' if [ ! -d $USB_MOUNT/backup/ssh ]; then' >> /usr/bin/$BACKUP_SCRIPT_NAME
echo ' mkdir -p $USB_MOUNT/backup/ssh' >> /usr/bin/$BACKUP_SCRIPT_NAME
echo 'for d in /home/*/ ; do' >> /usr/bin/$BACKUP_SCRIPT_NAME
echo ' USERNAME=$(echo "$d" | awk -F "/" "{print $3}")' >> /usr/bin/$BACKUP_SCRIPT_NAME
echo ' if [[ $USERNAME != "git" ]]; then' >> /usr/bin/$BACKUP_SCRIPT_NAME
echo ' if [ -d /home/$USERNAME/.ssh ]; then' >> /usr/bin/$BACKUP_SCRIPT_NAME
echo ' echo "Backing up ssh keys for $USERNAME"' >> /usr/bin/$BACKUP_SCRIPT_NAME
echo ' if [ ! -d $USB_MOUNT/backup/ssh/$USERNAME ]; then' >> /usr/bin/$BACKUP_SCRIPT_NAME
echo ' mkdir -p $USB_MOUNT/backup/ssh/$USERNAME' >> /usr/bin/$BACKUP_SCRIPT_NAME
echo ' fi' >> /usr/bin/$BACKUP_SCRIPT_NAME
echo ' backup_directory_to_usb /home/$MY_USERNAME/.ssh ssh' >> /usr/bin/$BACKUP_SCRIPT_NAME
echo ' backup_directory_to_usb /home/$USERNAME/.ssh ssh/$USERNAME' >> /usr/bin/$BACKUP_SCRIPT_NAME
echo ' fi' >> /usr/bin/$BACKUP_SCRIPT_NAME
echo ' fi' >> /usr/bin/$BACKUP_SCRIPT_NAME
echo 'done' >> /usr/bin/$BACKUP_SCRIPT_NAME
echo '' >> /usr/bin/$BACKUP_SCRIPT_NAME
echo '# Backup web sites' >> /usr/bin/$BACKUP_SCRIPT_NAME
@ -2762,59 +2782,79 @@ function create_backup_script {
echo '' >> /usr/bin/$BACKUP_SCRIPT_NAME
echo '# Backup Mutt settings' >> /usr/bin/$BACKUP_SCRIPT_NAME
echo 'if [ -f /home/$MY_USERNAME/.muttrc ]; then' >> /usr/bin/$BACKUP_SCRIPT_NAME
echo ' echo "Backing up Mutt 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 'for d in /home/*/ ; do' >> /usr/bin/$BACKUP_SCRIPT_NAME
echo ' USERNAME=$(echo "$d" | awk -F "/" "{print $3}")' >> /usr/bin/$BACKUP_SCRIPT_NAME
echo ' if [[ $USERNAME != "git" ]]; then' >> /usr/bin/$BACKUP_SCRIPT_NAME
echo ' if [ -f /home/$USERNAME/.muttrc ]; then' >> /usr/bin/$BACKUP_SCRIPT_NAME
echo ' echo "Backing up Mutt settings for $USERNAME"' >> /usr/bin/$BACKUP_SCRIPT_NAME
echo ' if [ ! -d /home/$USERNAME/tempbackup ]; then' >> /usr/bin/$BACKUP_SCRIPT_NAME
echo ' mkdir -p /home/$USERNAME/tempbackup' >> /usr/bin/$BACKUP_SCRIPT_NAME
echo ' fi' >> /usr/bin/$BACKUP_SCRIPT_NAME
echo ' cp /home/$MY_USERNAME/.muttrc /home/$MY_USERNAME/tempbackup' >> /usr/bin/$BACKUP_SCRIPT_NAME
echo ' cp /home/$USERNAME/.muttrc /home/$USERNAME/tempbackup' >> /usr/bin/$BACKUP_SCRIPT_NAME
echo ' if [ -f /etc/Muttrc ]; then' >> /usr/bin/$BACKUP_SCRIPT_NAME
echo ' cp /etc/Muttrc /home/$MY_USERNAME/tempbackup' >> /usr/bin/$BACKUP_SCRIPT_NAME
echo ' cp /etc/Muttrc /home/$USERNAME/tempbackup' >> /usr/bin/$BACKUP_SCRIPT_NAME
echo ' fi' >> /usr/bin/$BACKUP_SCRIPT_NAME
echo ' if [ ! -d $USB_MOUNT/backup/mutt ]; then' >> /usr/bin/$BACKUP_SCRIPT_NAME
echo ' mkdir -p $USB_MOUNT/backup/mutt' >> /usr/bin/$BACKUP_SCRIPT_NAME
echo ' if [ ! -d $USB_MOUNT/backup/mutt/$USERNAME ]; then' >> /usr/bin/$BACKUP_SCRIPT_NAME
echo ' mkdir -p $USB_MOUNT/backup/mutt/$USERNAME' >> /usr/bin/$BACKUP_SCRIPT_NAME
echo ' fi' >> /usr/bin/$BACKUP_SCRIPT_NAME
echo ' backup_directory_to_usb /home/$MY_USERNAME/tempbackup mutt' >> /usr/bin/$BACKUP_SCRIPT_NAME
echo ' backup_directory_to_usb /home/$USERNAME/tempbackup mutt/$USERNAME' >> /usr/bin/$BACKUP_SCRIPT_NAME
echo ' fi' >> /usr/bin/$BACKUP_SCRIPT_NAME
echo ' fi' >> /usr/bin/$BACKUP_SCRIPT_NAME
echo 'done' >> /usr/bin/$BACKUP_SCRIPT_NAME
echo '' >> /usr/bin/$BACKUP_SCRIPT_NAME
echo '# Backup procmail settings' >> /usr/bin/$BACKUP_SCRIPT_NAME
echo 'if [ -f /home/$MY_USERNAME/.procmailrc ]; then' >> /usr/bin/$BACKUP_SCRIPT_NAME
echo ' echo "Backing up procmail 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 'for d in /home/*/ ; do' >> /usr/bin/$BACKUP_SCRIPT_NAME
echo ' USERNAME=$(echo "$d" | awk -F "/" "{print $3}")' >> /usr/bin/$BACKUP_SCRIPT_NAME
echo ' if [[ $USERNAME != "git" ]]; then' >> /usr/bin/$BACKUP_SCRIPT_NAME
echo ' if [ -f /home/$USERNAME/.procmailrc ]; then' >> /usr/bin/$BACKUP_SCRIPT_NAME
echo ' echo "Backing up procmail settings for $USERNAME"' >> /usr/bin/$BACKUP_SCRIPT_NAME
echo ' if [ ! -d /home/$USERNAME/tempbackup ]; then' >> /usr/bin/$BACKUP_SCRIPT_NAME
echo ' mkdir -p /home/$USERNAME/tempbackup' >> /usr/bin/$BACKUP_SCRIPT_NAME
echo ' fi' >> /usr/bin/$BACKUP_SCRIPT_NAME
echo ' cp /home/$MY_USERNAME/.procmailrc /home/$MY_USERNAME/tempbackup' >> /usr/bin/$BACKUP_SCRIPT_NAME
echo ' if [ ! -d $USB_MOUNT/backup/procmail ]; then' >> /usr/bin/$BACKUP_SCRIPT_NAME
echo ' mkdir -p $USB_MOUNT/backup/procmail' >> /usr/bin/$BACKUP_SCRIPT_NAME
echo ' cp /home/$USERNAME/.procmailrc /home/$USERNAME/tempbackup' >> /usr/bin/$BACKUP_SCRIPT_NAME
echo ' if [ ! -d $USB_MOUNT/backup/procmail/$USERNAME ]; then' >> /usr/bin/$BACKUP_SCRIPT_NAME
echo ' mkdir -p $USB_MOUNT/backup/procmail/$USERNAME' >> /usr/bin/$BACKUP_SCRIPT_NAME
echo ' fi' >> /usr/bin/$BACKUP_SCRIPT_NAME
echo ' backup_directory_to_usb /home/$MY_USERNAME/tempbackup procmail' >> /usr/bin/$BACKUP_SCRIPT_NAME
echo ' backup_directory_to_usb /home/$USERNAME/tempbackup procmail/$USERNAME' >> /usr/bin/$BACKUP_SCRIPT_NAME
echo ' fi' >> /usr/bin/$BACKUP_SCRIPT_NAME
echo ' fi' >> /usr/bin/$BACKUP_SCRIPT_NAME
echo 'done' >> /usr/bin/$BACKUP_SCRIPT_NAME
echo '' >> /usr/bin/$BACKUP_SCRIPT_NAME
echo '# Backup spamassassin settings' >> /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 $USB_MOUNT/backup/spamassassin ]; then' >> /usr/bin/$BACKUP_SCRIPT_NAME
echo ' mkdir -p $USB_MOUNT/backup/spamassassin' >> /usr/bin/$BACKUP_SCRIPT_NAME
echo 'for d in /home/*/ ; do' >> /usr/bin/$BACKUP_SCRIPT_NAME
echo ' USERNAME=$(echo "$d" | awk -F "/" "{print $3}")' >> /usr/bin/$BACKUP_SCRIPT_NAME
echo ' if [[ $USERNAME != "git" ]]; then' >> /usr/bin/$BACKUP_SCRIPT_NAME
echo ' if [ -d /home/$USERNAME/.spamassassin ]; then' >> /usr/bin/$BACKUP_SCRIPT_NAME
echo ' echo "Backing up spamassassin settings for $USERNAME"' >> /usr/bin/$BACKUP_SCRIPT_NAME
echo ' if [ ! -d $USB_MOUNT/backup/spamassassin/$USERNAME ]; then' >> /usr/bin/$BACKUP_SCRIPT_NAME
echo ' mkdir -p $USB_MOUNT/backup/spamassassin/$USERNAME' >> /usr/bin/$BACKUP_SCRIPT_NAME
echo ' fi' >> /usr/bin/$BACKUP_SCRIPT_NAME
echo ' backup_directory_to_usb /home/$MY_USERNAME/.spamassassin spamassassin' >> /usr/bin/$BACKUP_SCRIPT_NAME
echo ' backup_directory_to_usb /home/$USERNAME/.spamassassin spamassassin/$USERNAME' >> /usr/bin/$BACKUP_SCRIPT_NAME
echo ' fi' >> /usr/bin/$BACKUP_SCRIPT_NAME
echo ' fi' >> /usr/bin/$BACKUP_SCRIPT_NAME
echo 'done' >> /usr/bin/$BACKUP_SCRIPT_NAME
echo '' >> /usr/bin/$BACKUP_SCRIPT_NAME
echo '# Backup email' >> /usr/bin/$BACKUP_SCRIPT_NAME
echo 'if [ -d /home/$MY_USERNAME/Maildir ]; then' >> /usr/bin/$BACKUP_SCRIPT_NAME
echo ' echo "Creating an email archive"' >> /usr/bin/$BACKUP_SCRIPT_NAME
echo ' if [ ! -d /root/tempbackupemail ]; then' >> /usr/bin/$BACKUP_SCRIPT_NAME
echo " mkdir -p /root/tempbackupemail" >> /usr/bin/$BACKUP_SCRIPT_NAME
echo 'for d in /home/*/ ; do' >> /usr/bin/$BACKUP_SCRIPT_NAME
echo ' USERNAME=$(echo "$d" | awk -F "/" "{print $3}")' >> /usr/bin/$BACKUP_SCRIPT_NAME
echo ' if [[ $USERNAME != "git" ]]; then' >> /usr/bin/$BACKUP_SCRIPT_NAME
echo ' if [ -d /home/$USERNAME/Maildir ]; then' >> /usr/bin/$BACKUP_SCRIPT_NAME
echo ' echo "Creating an email archive for $USERNAME"' >> /usr/bin/$BACKUP_SCRIPT_NAME
echo ' if [ ! -d /root/tempbackupemail/$USERNAME ]; then' >> /usr/bin/$BACKUP_SCRIPT_NAME
echo " mkdir -p /root/tempbackupemail/$USERNAME" >> /usr/bin/$BACKUP_SCRIPT_NAME
echo ' fi' >> /usr/bin/$BACKUP_SCRIPT_NAME
echo ' tar -czvf /root/tempbackupemail/maildir.tar.gz /home/$MY_USERNAME/Maildir' >> /usr/bin/$BACKUP_SCRIPT_NAME
echo ' echo "Backing up emails"' >> /usr/bin/$BACKUP_SCRIPT_NAME
echo ' if [ ! -d $USB_MOUNT/backup/mail ]; then' >> /usr/bin/$BACKUP_SCRIPT_NAME
echo ' mkdir -p $USB_MOUNT/backup/mail' >> /usr/bin/$BACKUP_SCRIPT_NAME
echo ' tar -czvf /root/tempbackupemail/$USERNAME/maildir.tar.gz /home/$USERNAME/Maildir' >> /usr/bin/$BACKUP_SCRIPT_NAME
echo ' echo "Backing up emails for $USERNAME"' >> /usr/bin/$BACKUP_SCRIPT_NAME
echo ' if [ ! -d $USB_MOUNT/backup/mail/$USERNAME ]; then' >> /usr/bin/$BACKUP_SCRIPT_NAME
echo ' mkdir -p $USB_MOUNT/backup/mail/$USERNAME' >> /usr/bin/$BACKUP_SCRIPT_NAME
echo ' fi' >> /usr/bin/$BACKUP_SCRIPT_NAME
echo ' backup_directory_to_usb /root/tempbackupemail mail' >> /usr/bin/$BACKUP_SCRIPT_NAME
echo ' backup_directory_to_usb /root/tempbackupemail/$USERNAME mail/$USERNAME' >> /usr/bin/$BACKUP_SCRIPT_NAME
echo ' fi' >> /usr/bin/$BACKUP_SCRIPT_NAME
echo ' fi' >> /usr/bin/$BACKUP_SCRIPT_NAME
echo 'done' >> /usr/bin/$BACKUP_SCRIPT_NAME
echo '' >> /usr/bin/$BACKUP_SCRIPT_NAME
echo '# Backup DLNA cache' >> /usr/bin/$BACKUP_SCRIPT_NAME
@ -3140,17 +3180,20 @@ function create_restore_script {
RESTORE_SUBDIR='usb/backup/mutt/'
fi
echo 'if [ -d $USB_MOUNT/backup/mutt ]; then' >> /usr/bin/$RESTORE_SCRIPT_NAME
echo ' echo "Restoring Mutt settings"' >> /usr/bin/$RESTORE_SCRIPT_NAME
echo ' restore_directory_from_usb /root/tempmutt mutt' >> /usr/bin/$RESTORE_SCRIPT_NAME
echo ' for d in /home/*/ ; do' >> /usr/bin/$RESTORE_SCRIPT_NAME
echo ' USERNAME=$(echo "$d" | awk -F "/" "{print $3}")' >> /usr/bin/$RESTORE_SCRIPT_NAME
echo ' if [[ $USERNAME != "git" ]]; then' >> /usr/bin/$RESTORE_SCRIPT_NAME
echo ' echo "Restoring Mutt settings for $USERNAME"' >> /usr/bin/$RESTORE_SCRIPT_NAME
echo ' restore_directory_from_usb /root/tempmutt mutt/$USERNAME' >> /usr/bin/$RESTORE_SCRIPT_NAME
echo -n " if [ -f /root/tempmutt/${RESTORE_SUBDIR}" >> /usr/bin/$RESTORE_SCRIPT_NAME
echo '$MY_USERNAME/tempbackup/.muttrc ]; then' >> /usr/bin/$RESTORE_SCRIPT_NAME
echo '$USERNAME/tempbackup/.muttrc ]; then' >> /usr/bin/$RESTORE_SCRIPT_NAME
echo -n " cp -f /root/tempmutt/${RESTORE_SUBDIR}" >> /usr/bin/$RESTORE_SCRIPT_NAME
echo '$MY_USERNAME/tempbackup/.muttrc /home/$MY_USERNAME/.muttrc' >> /usr/bin/$RESTORE_SCRIPT_NAME
echo '$USERNAME/tempbackup/.muttrc /home/$USERNAME/.muttrc' >> /usr/bin/$RESTORE_SCRIPT_NAME
echo ' fi' >> /usr/bin/$RESTORE_SCRIPT_NAME
echo -n " if [ -f /root/tempmutt/${RESTORE_SUBDIR}" >> /usr/bin/$RESTORE_SCRIPT_NAME
echo '$MY_USERNAME/tempbackup/Muttrc ]; then' >> /usr/bin/$RESTORE_SCRIPT_NAME
echo '$USERNAME/tempbackup/Muttrc ]; then' >> /usr/bin/$RESTORE_SCRIPT_NAME
echo -n " cp -f /root/tempmutt/${RESTORE_SUBDIR}" >> /usr/bin/$RESTORE_SCRIPT_NAME
echo '$MY_USERNAME/tempbackup/Muttrc /etc/Muttrc' >> /usr/bin/$RESTORE_SCRIPT_NAME
echo '$USERNAME/tempbackup/Muttrc /etc/Muttrc' >> /usr/bin/$RESTORE_SCRIPT_NAME
echo ' fi' >> /usr/bin/$RESTORE_SCRIPT_NAME
echo ' if [ ! "$?" = "0" ]; then' >> /usr/bin/$RESTORE_SCRIPT_NAME
echo ' umount $USB_MOUNT' >> /usr/bin/$RESTORE_SCRIPT_NAME
@ -3160,6 +3203,8 @@ function create_restore_script {
echo ' fi' >> /usr/bin/$RESTORE_SCRIPT_NAME
echo ' rm -rf /root/tempmutt' >> /usr/bin/$RESTORE_SCRIPT_NAME
echo ' fi' >> /usr/bin/$RESTORE_SCRIPT_NAME
echo ' done' >> /usr/bin/$RESTORE_SCRIPT_NAME
echo 'fi' >> /usr/bin/$RESTORE_SCRIPT_NAME
echo '' >> /usr/bin/$RESTORE_SCRIPT_NAME
RESTORE_SUBDIR='home/'
@ -3167,10 +3212,13 @@ function create_restore_script {
RESTORE_SUBDIR='usb/backup/gnupg/'
fi
echo 'if [ -d $USB_MOUNT/backup/gnupg ]; then' >> /usr/bin/$RESTORE_SCRIPT_NAME
echo ' echo "Restoring gnupg settings"' >> /usr/bin/$RESTORE_SCRIPT_NAME
echo ' restore_directory_from_usb /root/tempgnupg gnupg' >> /usr/bin/$RESTORE_SCRIPT_NAME
echo ' for d in /home/*/ ; do' >> /usr/bin/$RESTORE_SCRIPT_NAME
echo ' USERNAME=$(echo "$d" | awk -F "/" "{print $3}")' >> /usr/bin/$RESTORE_SCRIPT_NAME
echo ' if [[ $USERNAME != "git" ]]; then' >> /usr/bin/$RESTORE_SCRIPT_NAME
echo ' echo "Restoring gnupg settings for $USERNAME"' >> /usr/bin/$RESTORE_SCRIPT_NAME
echo ' restore_directory_from_usb /root/tempgnupg gnupg/$USERNAME' >> /usr/bin/$RESTORE_SCRIPT_NAME
echo -n " cp -r /root/tempgnupg/${RESTORE_SUBDIR}" >> /usr/bin/$RESTORE_SCRIPT_NAME
echo '$MY_USERNAME/.gnupg /home/$MY_USERNAME/' >> /usr/bin/$RESTORE_SCRIPT_NAME
echo '$USERNAME/.gnupg /home/$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
@ -3178,13 +3226,15 @@ function create_restore_script {
echo ' exit 276' >> /usr/bin/$RESTORE_SCRIPT_NAME
echo ' fi' >> /usr/bin/$RESTORE_SCRIPT_NAME
echo ' rm -rf /root/tempgnupg' >> /usr/bin/$RESTORE_SCRIPT_NAME
echo ' cp -r /home/$MY_USERNAME/.gnupg /root' >> /usr/bin/$RESTORE_SCRIPT_NAME
echo ' cp -r /home/$USERNAME/.gnupg /root' >> /usr/bin/$RESTORE_SCRIPT_NAME
echo ' if [ ! "$?" = "0" ]; then' >> /usr/bin/$RESTORE_SCRIPT_NAME
echo ' umount $USB_MOUNT' >> /usr/bin/$RESTORE_SCRIPT_NAME
echo ' rm -rf $USB_MOUNT' >> /usr/bin/$RESTORE_SCRIPT_NAME
echo ' exit 283' >> /usr/bin/$RESTORE_SCRIPT_NAME
echo ' fi' >> /usr/bin/$RESTORE_SCRIPT_NAME
echo ' fi' >> /usr/bin/$RESTORE_SCRIPT_NAME
echo ' done' >> /usr/bin/$RESTORE_SCRIPT_NAME
echo 'fi' >> /usr/bin/$RESTORE_SCRIPT_NAME
echo '' >> /usr/bin/$RESTORE_SCRIPT_NAME
RESTORE_SUBDIR='home/'
@ -3192,10 +3242,13 @@ function create_restore_script {
RESTORE_SUBDIR='usb/backup/procmail/'
fi
echo 'if [ -d $USB_MOUNT/backup/procmail ]; then' >> /usr/bin/$RESTORE_SCRIPT_NAME
echo ' echo "Restoring procmail settings"' >> /usr/bin/$RESTORE_SCRIPT_NAME
echo ' restore_directory_from_usb /root/tempprocmail procmail' >> /usr/bin/$RESTORE_SCRIPT_NAME
echo ' for d in /home/*/ ; do' >> /usr/bin/$RESTORE_SCRIPT_NAME
echo ' USERNAME=$(echo "$d" | awk -F "/" "{print $3}")' >> /usr/bin/$RESTORE_SCRIPT_NAME
echo ' if [[ $USERNAME != "git" ]]; then' >> /usr/bin/$RESTORE_SCRIPT_NAME
echo ' echo "Restoring procmail settings for $USERNAME"' >> /usr/bin/$RESTORE_SCRIPT_NAME
echo ' restore_directory_from_usb /root/tempprocmail procmail/$USERNAME' >> /usr/bin/$RESTORE_SCRIPT_NAME
echo -n " cp -f /root/tempprocmail/${RESTORE_SUBDIR}" >> /usr/bin/$RESTORE_SCRIPT_NAME
echo '$MY_USERNAME/tempbackup/.procmailrc /home/$MY_USERNAME/' >> /usr/bin/$RESTORE_SCRIPT_NAME
echo '$USERNAME/tempbackup/.procmailrc /home/$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
@ -3204,6 +3257,8 @@ function create_restore_script {
echo ' fi' >> /usr/bin/$RESTORE_SCRIPT_NAME
echo ' rm -rf /root/tempprocmail' >> /usr/bin/$RESTORE_SCRIPT_NAME
echo ' fi' >> /usr/bin/$RESTORE_SCRIPT_NAME
echo ' done' >> /usr/bin/$RESTORE_SCRIPT_NAME
echo 'fi' >> /usr/bin/$RESTORE_SCRIPT_NAME
echo '' >> /usr/bin/$RESTORE_SCRIPT_NAME
RESTORE_SUBDIR='home/'
@ -3211,10 +3266,13 @@ function create_restore_script {
RESTORE_SUBDIR='usb/backup/spamassassin/'
fi
echo 'if [ -d $USB_MOUNT/backup/spamassassin ]; then' >> /usr/bin/$RESTORE_SCRIPT_NAME
echo ' echo "Restoring spamassassin settings"' >> /usr/bin/$RESTORE_SCRIPT_NAME
echo 'restore_directory_from_usb /root/tempspamassassin spamassassin' >> /usr/bin/$RESTORE_SCRIPT_NAME
echo ' for d in /home/*/ ; do' >> /usr/bin/$RESTORE_SCRIPT_NAME
echo ' USERNAME=$(echo "$d" | awk -F "/" "{print $3}")' >> /usr/bin/$RESTORE_SCRIPT_NAME
echo ' if [[ $USERNAME != "git" ]]; then' >> /usr/bin/$RESTORE_SCRIPT_NAME
echo ' echo "Restoring spamassassin settings for $USERNAME"' >> /usr/bin/$RESTORE_SCRIPT_NAME
echo ' restore_directory_from_usb /root/tempspamassassin spamassassin/$USERNAME' >> /usr/bin/$RESTORE_SCRIPT_NAME
echo -n " cp -rf /root/tempspamassassin/${RESTORE_SUBDIR}" >> /usr/bin/$RESTORE_SCRIPT_NAME
echo '$MY_USERNAME/.spamassassin /home/$MY_USERNAME/' >> /usr/bin/$RESTORE_SCRIPT_NAME
echo '$USERNAME/.spamassassin /home/$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
@ -3223,6 +3281,8 @@ function create_restore_script {
echo ' fi' >> /usr/bin/$RESTORE_SCRIPT_NAME
echo ' rm -rf /root/tempspamassassin' >> /usr/bin/$RESTORE_SCRIPT_NAME
echo ' fi' >> /usr/bin/$RESTORE_SCRIPT_NAME
echo ' done' >> /usr/bin/$RESTORE_SCRIPT_NAME
echo 'fi' >> /usr/bin/$RESTORE_SCRIPT_NAME
echo '' >> /usr/bin/$RESTORE_SCRIPT_NAME
RESTORE_SUBDIR='home/'
@ -3268,10 +3328,13 @@ function create_restore_script {
RESTORE_SUBDIR='usb/backup/ssh/'
fi
echo 'if [ -d $USB_MOUNT/backup/ssh ]; then' >> /usr/bin/$RESTORE_SCRIPT_NAME
echo ' echo "Restoring ssh keys"' >> /usr/bin/$RESTORE_SCRIPT_NAME
echo ' restore_directory_from_usb /root/tempssh ssh' >> /usr/bin/$RESTORE_SCRIPT_NAME
echo ' for d in /home/*/ ; do' >> /usr/bin/$RESTORE_SCRIPT_NAME
echo ' USERNAME=$(echo "$d" | awk -F "/" "{print $3}")' >> /usr/bin/$RESTORE_SCRIPT_NAME
echo ' if [[ $USERNAME != "git" ]]; then' >> /usr/bin/$RESTORE_SCRIPT_NAME
echo ' echo "Restoring ssh keys for $USERNAME"' >> /usr/bin/$RESTORE_SCRIPT_NAME
echo ' restore_directory_from_usb /root/tempssh ssh/$USERNAME' >> /usr/bin/$RESTORE_SCRIPT_NAME
echo -n " cp -r /root/tempssh/${RESTORE_SUBDIR}" >> /usr/bin/$RESTORE_SCRIPT_NAME
echo '$MY_USERNAME/.ssh /home/$MY_USERNAME/' >> /usr/bin/$RESTORE_SCRIPT_NAME
echo '$USERNAME/.ssh /home/$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
@ -3280,6 +3343,8 @@ function create_restore_script {
echo ' fi' >> /usr/bin/$RESTORE_SCRIPT_NAME
echo ' rm -rf /root/tempssh' >> /usr/bin/$RESTORE_SCRIPT_NAME
echo ' fi' >> /usr/bin/$RESTORE_SCRIPT_NAME
echo ' done' >> /usr/bin/$RESTORE_SCRIPT_NAME
echo 'fi' >> /usr/bin/$RESTORE_SCRIPT_NAME
echo '' >> /usr/bin/$RESTORE_SCRIPT_NAME
RESTORE_SUBDIR='etc/'
@ -3305,13 +3370,16 @@ function create_restore_script {
RESTORE_SUBDIR='usb/backup/projects/'
fi
echo 'if [ -d $USB_MOUNT/backup/projects ]; then' >> /usr/bin/$RESTORE_SCRIPT_NAME
echo ' echo "Restoring projects"' >> /usr/bin/$RESTORE_SCRIPT_NAME
echo ' restore_directory_from_usb /root/tempprojects projects' >> /usr/bin/$RESTORE_SCRIPT_NAME
echo ' if [ -d /home/$MY_USERNAME/projects ]; then' >> /usr/bin/$RESTORE_SCRIPT_NAME
echo ' rm -rf /home/$MY_USERNAME/projects' >> /usr/bin/$RESTORE_SCRIPT_NAME
echo ' for d in /home/*/ ; do' >> /usr/bin/$RESTORE_SCRIPT_NAME
echo ' USERNAME=$(echo "$d" | awk -F "/" "{print $3}")' >> /usr/bin/$RESTORE_SCRIPT_NAME
echo ' if [[ $USERNAME != "git" ]]; then' >> /usr/bin/$RESTORE_SCRIPT_NAME
echo ' echo "Restoring projects for $USERNAME"' >> /usr/bin/$RESTORE_SCRIPT_NAME
echo ' restore_directory_from_usb /root/tempprojects projects/$USERNAME' >> /usr/bin/$RESTORE_SCRIPT_NAME
echo ' if [ -d /home/$USERNAME/projects ]; then' >> /usr/bin/$RESTORE_SCRIPT_NAME
echo ' rm -rf /home/$USERNAME/projects' >> /usr/bin/$RESTORE_SCRIPT_NAME
echo ' fi' >> /usr/bin/$RESTORE_SCRIPT_NAME
echo -n " mv /root/tempprojects/${RESTORE_SUBDIR}" >> /usr/bin/$RESTORE_SCRIPT_NAME
echo '$MY_USERNAME/projects /home/$MY_USERNAME' >> /usr/bin/$RESTORE_SCRIPT_NAME
echo '$USERNAME/projects /home/$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
@ -3319,6 +3387,8 @@ function create_restore_script {
echo ' fi' >> /usr/bin/$RESTORE_SCRIPT_NAME
echo ' rm -rf /root/tempprojects' >> /usr/bin/$RESTORE_SCRIPT_NAME
echo ' fi' >> /usr/bin/$RESTORE_SCRIPT_NAME
echo ' done' >> /usr/bin/$RESTORE_SCRIPT_NAME
echo 'fi' >> /usr/bin/$RESTORE_SCRIPT_NAME
echo '' >> /usr/bin/$RESTORE_SCRIPT_NAME
RESTORE_SUBDIR='home/'
@ -3326,13 +3396,16 @@ function create_restore_script {
RESTORE_SUBDIR='usb/backup/personal/'
fi
echo 'if [ -d $USB_MOUNT/backup/personal ]; then' >> /usr/bin/$RESTORE_SCRIPT_NAME
echo ' echo "Restoring personal settings"' >> /usr/bin/$RESTORE_SCRIPT_NAME
echo ' restore_directory_from_usb /root/temppersonal personal' >> /usr/bin/$RESTORE_SCRIPT_NAME
echo ' if [ -d /home/$MY_USERNAME/personal ]; then' >> /usr/bin/$RESTORE_SCRIPT_NAME
echo ' rm -rf /home/$MY_USERNAME/personal' >> /usr/bin/$RESTORE_SCRIPT_NAME
echo ' for d in /home/*/ ; do' >> /usr/bin/$RESTORE_SCRIPT_NAME
echo ' USERNAME=$(echo "$d" | awk -F "/" "{print $3}")' >> /usr/bin/$RESTORE_SCRIPT_NAME
echo ' if [[ $USERNAME != "git" ]]; then' >> /usr/bin/$RESTORE_SCRIPT_NAME
echo ' echo "Restoring personal settings for $USERNAME"' >> /usr/bin/$RESTORE_SCRIPT_NAME
echo ' restore_directory_from_usb /root/temppersonal personal/$USERNAME' >> /usr/bin/$RESTORE_SCRIPT_NAME
echo ' if [ -d /home/$USERNAME/personal ]; then' >> /usr/bin/$RESTORE_SCRIPT_NAME
echo ' rm -rf /home/$USERNAME/personal' >> /usr/bin/$RESTORE_SCRIPT_NAME
echo ' fi' >> /usr/bin/$RESTORE_SCRIPT_NAME
echo -n " mv /root/temppersonal/${RESTORE_SUBDIR}" >> /usr/bin/$RESTORE_SCRIPT_NAME
echo '$MY_USERNAME/personal /home/$MY_USERNAME' >> /usr/bin/$RESTORE_SCRIPT_NAME
echo '$USERNAME/personal /home/$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
@ -3340,6 +3413,8 @@ function create_restore_script {
echo ' fi' >> /usr/bin/$RESTORE_SCRIPT_NAME
echo ' rm -rf /root/temppersonal' >> /usr/bin/$RESTORE_SCRIPT_NAME
echo ' fi' >> /usr/bin/$RESTORE_SCRIPT_NAME
echo ' done' >> /usr/bin/$RESTORE_SCRIPT_NAME
echo 'fi' >> /usr/bin/$RESTORE_SCRIPT_NAME
echo '' >> /usr/bin/$RESTORE_SCRIPT_NAME
RESTORE_SUBDIR='root/'
@ -3424,7 +3499,12 @@ function create_restore_script {
echo ' chown -R www-data:www-data /var/lib/owncloud/data' >> /usr/bin/$RESTORE_SCRIPT_NAME
echo ' chown -R www-data:www-data /var/lib/owncloud/backup' >> /usr/bin/$RESTORE_SCRIPT_NAME
echo ' chown -R www-data:www-data /var/lib/owncloud/assets' >> /usr/bin/$RESTORE_SCRIPT_NAME
echo ' occ files:scan $MY_USERNAME' >> /usr/bin/$RESTORE_SCRIPT_NAME
echo ' for d in /home/*/ ; do' >> /usr/bin/$RESTORE_SCRIPT_NAME
echo ' USERNAME=$(echo "$d" | awk -F "/" "{print $3}")' >> /usr/bin/$RESTORE_SCRIPT_NAME
echo ' if [[ $USERNAME != "git" ]]; then' >> /usr/bin/$RESTORE_SCRIPT_NAME
echo ' occ files:scan $USERNAME' >> /usr/bin/$RESTORE_SCRIPT_NAME
echo ' fi' >> /usr/bin/$RESTORE_SCRIPT_NAME
echo ' done' >> /usr/bin/$RESTORE_SCRIPT_NAME
echo " ln -s /usr/share/owncloud /var/www/$OWNCLOUD_DOMAIN_NAME/htdocs" >> /usr/bin/$RESTORE_SCRIPT_NAME
echo 'fi' >> /usr/bin/$RESTORE_SCRIPT_NAME
echo '' >> /usr/bin/$RESTORE_SCRIPT_NAME
@ -3541,13 +3621,18 @@ function create_restore_script {
echo " if [ -f /etc/ssl/certs/$FULLBLOG_DOMAIN_NAME.bundle.crt ]; then" >> /usr/bin/$RESTORE_SCRIPT_NAME
echo " sed -i 's|$FULLBLOG_DOMAIN_NAME.crt|$FULLBLOG_DOMAIN_NAME.bundle.crt|g' /etc/nginx/sites-available/$FULLBLOG_DOMAIN_NAME" >> /usr/bin/$RESTORE_SCRIPT_NAME
echo ' fi' >> /usr/bin/$RESTORE_SCRIPT_NAME
echo ' for d in /home/*/ ; do' >> /usr/bin/$RESTORE_SCRIPT_NAME
echo ' USERNAME=$(echo "$d" | awk -F "/" "{print $3}")' >> /usr/bin/$RESTORE_SCRIPT_NAME
echo ' if [[ $USERNAME != "git" ]]; then' >> /usr/bin/$RESTORE_SCRIPT_NAME
echo -n " if [ -d /var/www/$FULLBLOG_DOMAIN_NAME/htdocs/content" >> /usr/bin/$RESTORE_SCRIPT_NAME
echo '/$MY_USERNAME/blog/uncategorized/post ]; then' >> /usr/bin/$RESTORE_SCRIPT_NAME
echo '/$USERNAME/blog/uncategorized/post ]; then' >> /usr/bin/$RESTORE_SCRIPT_NAME
echo -n " mv /var/www/$FULLBLOG_DOMAIN_NAME/htdocs/content" >> /usr/bin/$RESTORE_SCRIPT_NAME
echo -n '/$MY_USERNAME/blog/*.md ' >> /usr/bin/$RESTORE_SCRIPT_NAME
echo -n '/$USERNAME/blog/*.md ' >> /usr/bin/$RESTORE_SCRIPT_NAME
echo -n "/var/www/$FULLBLOG_DOMAIN_NAME/htdocs/content" >> /usr/bin/$RESTORE_SCRIPT_NAME
echo '/$MY_USERNAME/blog/uncategorized/post ' >> /usr/bin/$RESTORE_SCRIPT_NAME
echo '/$USERNAME/blog/uncategorized/post ' >> /usr/bin/$RESTORE_SCRIPT_NAME
echo ' fi' >> /usr/bin/$RESTORE_SCRIPT_NAME
echo ' fi' >> /usr/bin/$RESTORE_SCRIPT_NAME
echo ' done' >> /usr/bin/$RESTORE_SCRIPT_NAME
echo 'fi' >> /usr/bin/$RESTORE_SCRIPT_NAME
echo '' >> /usr/bin/$RESTORE_SCRIPT_NAME
@ -3575,10 +3660,13 @@ function create_restore_script {
RESTORE_SUBDIR='usb/backup/mail'
fi
echo 'if [ -d $USB_MOUNT/backup/mail ]; then' >> /usr/bin/$RESTORE_SCRIPT_NAME
echo ' echo "Restoring emails"' >> /usr/bin/$RESTORE_SCRIPT_NAME
echo ' restore_directory_from_usb /root/tempmail mail' >> /usr/bin/$RESTORE_SCRIPT_NAME
echo ' if [ ! -d /home/$MY_USERNAME/Maildir ]; then' >> /usr/bin/$RESTORE_SCRIPT_NAME
echo ' mkdir /home/$MY_USERNAME/Maildir' >> /usr/bin/$RESTORE_SCRIPT_NAME
echo ' for d in /home/*/ ; do' >> /usr/bin/$RESTORE_SCRIPT_NAME
echo ' USERNAME=$(echo "$d" | awk -F "/" "{print $3}")' >> /usr/bin/$RESTORE_SCRIPT_NAME
echo ' if [[ $USERNAME != "git" ]]; then' >> /usr/bin/$RESTORE_SCRIPT_NAME
echo ' echo "Restoring emails for $USERNAME"' >> /usr/bin/$RESTORE_SCRIPT_NAME
echo ' restore_directory_from_usb /root/tempmail mail/$USERNAME' >> /usr/bin/$RESTORE_SCRIPT_NAME
echo ' if [ ! -d /home/$USERNAME/Maildir ]; then' >> /usr/bin/$RESTORE_SCRIPT_NAME
echo ' mkdir /home/$USERNAME/Maildir' >> /usr/bin/$RESTORE_SCRIPT_NAME
echo ' fi' >> /usr/bin/$RESTORE_SCRIPT_NAME
echo " tar -xzvf /root/tempmail/${RESTORE_SUBDIR}/tempbackupemail/maildir.tar.gz -C /" >> /usr/bin/$RESTORE_SCRIPT_NAME
echo ' if [ ! "$?" = "0" ]; then' >> /usr/bin/$RESTORE_SCRIPT_NAME
@ -3588,6 +3676,8 @@ function create_restore_script {
echo ' fi' >> /usr/bin/$RESTORE_SCRIPT_NAME
echo ' rm -rf /root/tempmail' >> /usr/bin/$RESTORE_SCRIPT_NAME
echo ' fi' >> /usr/bin/$RESTORE_SCRIPT_NAME
echo ' done' >> /usr/bin/$RESTORE_SCRIPT_NAME
echo 'fi' >> /usr/bin/$RESTORE_SCRIPT_NAME
echo '' >> /usr/bin/$RESTORE_SCRIPT_NAME
RESTORE_SUBDIR='var'
@ -3673,7 +3763,12 @@ function create_restore_script {
fi
echo '' >> /usr/bin/$RESTORE_SCRIPT_NAME
echo 'echo "Setting permissions"' >> /usr/bin/$RESTORE_SCRIPT_NAME
echo 'chown -R $MY_USERNAME:$MY_USERNAME /home/$MY_USERNAME' >> /usr/bin/$RESTORE_SCRIPT_NAME
echo 'for d in /home/*/ ; do' >> /usr/bin/$RESTORE_SCRIPT_NAME
echo ' USERNAME=$(echo "$d" | awk -F "/" "{print $3}")' >> /usr/bin/$RESTORE_SCRIPT_NAME
echo ' if [[ $USERNAME != "git" ]]; then' >> /usr/bin/$RESTORE_SCRIPT_NAME
echo ' chown -R $USERNAME:$USERNAME /home/$USERNAME' >> /usr/bin/$RESTORE_SCRIPT_NAME
echo ' fi' >> /usr/bin/$RESTORE_SCRIPT_NAME
echo 'done' >> /usr/bin/$RESTORE_SCRIPT_NAME
echo '' >> /usr/bin/$RESTORE_SCRIPT_NAME
echo 'if [[ $USB_DRIVE == /dev/mapper/encrypted_usb ]]; then' >> /usr/bin/$RESTORE_SCRIPT_NAME