Ability to restore specific apps

This commit is contained in:
Bob Mottram 2015-12-18 12:15:02 +00:00
parent 7038d49d85
commit 178b0029fd
2 changed files with 145 additions and 1 deletions

Binary file not shown.

View File

@ -32,6 +32,9 @@ PROJECT_NAME='freedombone'
COMPLETION_FILE=$HOME/${PROJECT_NAME}-completed.txt
BACKUP_EXTRA_DIRECTORIES=/root/backup-extra-dirs.csv
# whether to restore everything or just a specific application
RESTORE_APP='all'
export TEXTDOMAIN=${PROJECT_NAME}-restore-local
export TEXTDOMAINDIR="/usr/share/locale"
@ -228,6 +231,12 @@ function update_domains {
}
function restore_configuration {
if [[ $RESTORE_APP != 'all' ]]; then
if [[ $RESTORE_APP != 'configuration' ]]; then
return
fi
fi
# this restores *.cfg and COMPLETION_FILE
if [ -d $USB_MOUNT/backup/config ]; then
echo $"Restoring configuration files"
@ -274,6 +283,11 @@ function same_admin_user {
}
function restore_mariadb {
if [[ $RESTORE_APP != 'all' ]]; then
if [[ $RESTORE_APP != 'mariadb' ]]; then
return
fi
fi
if [ -d $USB_MOUNT/backup/mariadb ]; then
echo $"Restoring mysql settings"
restore_directory_from_usb /root/tempmariadb mariadb
@ -310,6 +324,11 @@ function restore_mariadb {
}
function restore_letsencrypt {
if [[ $RESTORE_APP != 'all' ]]; then
if [[ $RESTORE_APP != 'letsencrypt' ]]; then
return
fi
fi
if [ -d $USB_MOUNT/backup/letsencrypt ]; then
echo $"Restoring Lets Encrypt settings"
restore_directory_from_usb / letsencrypt
@ -317,6 +336,11 @@ function restore_letsencrypt {
}
function restore_mutt_settings {
if [[ $RESTORE_APP != 'all' ]]; then
if [[ $RESTORE_APP != 'mutt' ]]; then
return
fi
fi
if [ -d $USB_MOUNT/backup/mutt ]; then
for d in $USB_MOUNT/backup/mutt/*/ ; do
USERNAME=$(echo "$d" | awk -F '/' '{print $6}')
@ -344,6 +368,11 @@ function restore_mutt_settings {
}
function restore_gpg {
if [[ $RESTORE_APP != 'all' ]]; then
if [[ $RESTORE_APP != 'gpg' ]]; then
return
fi
fi
if [ -d $USB_MOUNT/backup/gnupg ]; then
for d in $USB_MOUNT/backup/gnupg/*/ ; do
USERNAME=$(echo "$d" | awk -F '/' '{print $6}')
@ -373,6 +402,11 @@ function restore_gpg {
}
function restore_procmail {
if [[ $RESTORE_APP != 'all' ]]; then
if [[ $RESTORE_APP != 'procmail' ]]; then
return
fi
fi
if [ -d $USB_MOUNT/backup/procmail ]; then
for d in $USB_MOUNT/backup/procmail/*/ ; do
USERNAME=$(echo "$d" | awk -F '/' '{print $6}')
@ -395,6 +429,11 @@ function restore_procmail {
}
function restore_spamassassin {
if [[ $RESTORE_APP != 'all' ]]; then
if [[ $RESTORE_APP != 'spamassassin' ]]; then
return
fi
fi
if [ -d $USB_MOUNT/backup/spamassassin ]; then
for d in $USB_MOUNT/backup/spamassassin/*/ ; do
USERNAME=$(echo "$d" | awk -F '/' '{print $6}')
@ -419,6 +458,11 @@ function restore_spamassassin {
}
function restore_admin_readme {
if [[ $RESTORE_APP != 'all' ]]; then
if [[ $RESTORE_APP != 'readme' ]]; then
return
fi
fi
if [ -d $USB_MOUNT/backup/readme ]; then
echo $"Restoring admin user README"
@ -442,6 +486,11 @@ function restore_admin_readme {
}
function restore_ipfs {
if [[ $RESTORE_APP != 'all' ]]; then
if [[ $RESTORE_APP != 'ipfs' ]]; then
return
fi
fi
if [ -d $USB_MOUNT/backup/ipfs ]; then
echo $"Restoring IPFS"
restore_directory_from_usb /root/tempipfs ipfs
@ -456,6 +505,11 @@ function restore_ipfs {
}
function restore_user_ssh_keys {
if [[ $RESTORE_APP != 'all' ]]; then
if [[ $RESTORE_APP != 'ssh' ]]; then
return
fi
fi
if [ -d $USB_MOUNT/backup/ssh ]; then
for d in $USB_MOUNT/backup/ssh/*/ ; do
USERNAME=$(echo "$d" | awk -F '/' '{print $6}')
@ -478,6 +532,11 @@ function restore_user_ssh_keys {
}
function restore_user_config {
if [[ $RESTORE_APP != 'all' ]]; then
if [[ $RESTORE_APP != 'userconfig' ]]; then
return
fi
fi
if [ -d $USB_MOUNT/backup/config ]; then
for d in $USB_MOUNT/backup/config/*/ ; do
USERNAME=$(echo "$d" | awk -F '/' '{print $6}')
@ -500,6 +559,11 @@ function restore_user_config {
}
function restore_certs {
if [[ $RESTORE_APP != 'all' ]]; then
if [[ $RESTORE_APP != 'certs' ]]; then
return
fi
fi
if [ -d $USB_MOUNT/backup/ssl ]; then
echo $"Restoring certificates"
mkdir /root/tempssl
@ -514,6 +578,11 @@ function restore_certs {
}
function restore_personal_settings {
if [[ $RESTORE_APP != 'all' ]]; then
if [[ $RESTORE_APP != 'personal' ]]; then
return
fi
fi
if [ -d $USB_MOUNT/backup/personal ]; then
for d in $USB_MOUNT/backup/personal/*/ ; do
USERNAME=$(echo "$d" | awk -F '/' '{print $6}')
@ -540,6 +609,11 @@ function restore_personal_settings {
}
function restore_mailing_list {
if [[ $RESTORE_APP != 'all' ]]; then
if [[ $RESTORE_APP != 'mailinglist' ]]; then
return
fi
fi
if [ -d /var/spool/mlmmj ]; then
echo $"Restoring public mailing list"
restore_directory_from_usb /root/tempmailinglist mailinglist
@ -553,6 +627,11 @@ function restore_mailing_list {
}
function restore_xmpp {
if [[ $RESTORE_APP != 'all' ]]; then
if [[ $RESTORE_APP != 'xmpp' ]]; then
return
fi
fi
if [ -d /var/lib/prosody ]; then
echo $"Restoring XMPP settings"
restore_directory_from_usb /root/tempxmpp xmpp
@ -568,6 +647,11 @@ function restore_xmpp {
}
function restore_gnu_social {
if [[ $RESTORE_APP != 'all' ]]; then
if [[ $RESTORE_APP != 'gnusocial' ]]; then
return
fi
fi
if [ $MICROBLOG_DOMAIN_NAME ]; then
restore_database gnusocial ${MICROBLOG_DOMAIN_NAME}
if [ -d /root/tempgnusocial ]; then
@ -577,6 +661,11 @@ function restore_gnu_social {
}
function restore_hubzilla {
if [[ $RESTORE_APP != 'all' ]]; then
if [[ $RESTORE_APP != 'hubzilla' ]]; then
return
fi
fi
if [ $HUBZILLA_DOMAIN_NAME ]; then
restore_database hubzilla ${HUBZILLA_DOMAIN_NAME}
if [ -d $USB_MOUNT/backup/hubzilla ]; then
@ -593,6 +682,11 @@ function restore_hubzilla {
}
function restore_owncloud {
if [[ $RESTORE_APP != 'all' ]]; then
if [[ $RESTORE_APP != 'owncloud' ]]; then
return
fi
fi
if [ $OWNCLOUD_DOMAIN_NAME ]; then
restore_database owncloud $OWNCLOUD_DOMAIN_NAME
if [ -d $USB_MOUNT/backup/owncloud2 ]; then
@ -619,6 +713,11 @@ function restore_owncloud {
}
function restore_gogs {
if [[ $RESTORE_APP != 'all' ]]; then
if [[ $RESTORE_APP != 'gogs' ]]; then
return
fi
fi
if [ $GIT_DOMAIN_NAME ]; then
restore_database gogs ${GIT_DOMAIN_NAME}
if [ -d $USB_MOUNT/backup/gogs ]; then
@ -657,6 +756,11 @@ function restore_gogs {
}
function restore_wiki {
if [[ $RESTORE_APP != 'all' ]]; then
if [[ $RESTORE_APP != 'wiki' ]]; then
return
fi
fi
if [ $WIKI_DOMAIN_NAME ]; then
echo $"Restoring Wiki installation ${WIKI_DOMAIN_NAME}"
restore_directory_from_usb /root/tempwiki wiki
@ -686,6 +790,11 @@ function restore_wiki {
}
function restore_blog {
if [[ $RESTORE_APP != 'all' ]]; then
if [[ $RESTORE_APP != 'blog' ]]; then
return
fi
fi
if [ $FULLBLOG_DOMAIN_NAME ]; then
echo $"Restoring blog installation"
restore_directory_from_usb /root/tempblog blog
@ -722,6 +831,11 @@ function restore_blog {
}
function restore_cjdns {
if [[ $RESTORE_APP != 'all' ]]; then
if [[ $RESTORE_APP != 'cjdns' ]]; then
return
fi
fi
if [ -d $USB_MOUNT/backup/cjdns ]; then
echo $"Restoring cjdns installation"
restore_directory_from_usb /root/tempcjdns cjdns
@ -736,6 +850,11 @@ function restore_cjdns {
}
function restore_email {
if [[ $RESTORE_APP != 'all' ]]; then
if [[ $RESTORE_APP != 'email' ]]; then
return
fi
fi
if [ -d $USB_MOUNT/backup/mail ]; then
for d in $USB_MOUNT/backup/mail/*/ ; do
USERNAME=$(echo "$d" | awk -F '/' '{print $6}')
@ -760,6 +879,11 @@ function restore_email {
}
function restore_dlna {
if [[ $RESTORE_APP != 'all' ]]; then
if [[ $RESTORE_APP != 'dlna' ]]; then
return
fi
fi
if [ -d /var/cache/minidlna ]; then
if [ -d $USB_MOUNT/backup/dlna ]; then
echo $"Restoring DLNA cache"
@ -776,6 +900,11 @@ function restore_dlna {
}
function restore_voip {
if [[ $RESTORE_APP != 'all' ]]; then
if [[ $RESTORE_APP != 'voip' ]]; then
return
fi
fi
if [ -d $USB_MOUNT/backup/voip ]; then
echo $"Restoring VoIP settings"
restore_directory_from_usb /root/tempvoip voip
@ -807,6 +936,11 @@ function restore_voip {
}
function restore_tox {
if [[ $RESTORE_APP != 'all' ]]; then
if [[ $RESTORE_APP != 'tox' ]]; then
return
fi
fi
if [ -d $USB_MOUNT/backup/tox ]; then
echo $"Restoring Tox node settings"
restore_directory_from_usb / tox
@ -824,7 +958,17 @@ function restore_tox {
fi
}
mount_drive $1 $2
function get_restore_app {
if [ ${1} ]; then
if [ ! -d /home/${1} ]; then
RESTORE_APP=${1}
echo $"Restore $RESTORE_APP"
fi
fi
}
get_restore_app ${2}
mount_drive ${1} ${2}
check_backup_exists
check_admin_user
copy_gpg_keys