Remote restore of specific applications

This commit is contained in:
Bob Mottram 2015-12-18 17:42:27 +00:00
parent b3df2bdf45
commit 0467fb24f8
3 changed files with 137 additions and 0 deletions

Binary file not shown.

Binary file not shown.

View File

@ -38,6 +38,13 @@ export TEXTDOMAINDIR="/usr/share/locale"
SERVER_NAME=$1
# whether to restore everything or just a specific application
RESTORE_APP='all'
if [ ${2} ]; then
RESTORE_APP=${2}
fi
ADMIN_USERNAME=$(cat $COMPLETION_FILE | grep "Admin user" | -nawk -F ':' '{print $2}')
ADMIN_EMAIL_ADDRESS=${ADMIN_USERNAME}@${HOSTNAME}
@ -139,6 +146,11 @@ function restore_database_from_friend {
}
function restore_configuration {
if [[ $RESTORE_APP != 'all' ]]; then
if [[ $RESTORE_APP != 'configuration' ]]; then
return
fi
fi
if [ -d $SERVER_DIRECTORY/backup/config ]; then
echo $"Restoring configuration files"
restore_directory_from_friend /root/tempconfig config
@ -175,6 +187,11 @@ function restore_configuration {
}
function restore_mariadb {
if [[ $RESTORE_APP != 'all' ]]; then
if [[ $RESTORE_APP != 'mariadb' ]]; then
return
fi
fi
if [ -d $SERVER_DIRECTORY/backup/mariadb ]; then
echo $"Restoring MariaDB settings"
restore_directory_from_friend /root/tempmariadb mariadb
@ -210,6 +227,11 @@ function restore_mariadb {
}
function restore_letsencrypt {
if [[ $RESTORE_APP != 'all' ]]; then
if [[ $RESTORE_APP != 'letsencrypt' ]]; then
return
fi
fi
if [ -d $SERVER_DIRECTORY/backup/letsencrypt ]; then
echo $"Restoring Lets Encrypt settings"
restore_directory_from_friend / letsencrypt
@ -217,6 +239,11 @@ function restore_letsencrypt {
}
function restore_mutt_settings {
if [[ $RESTORE_APP != 'all' ]]; then
if [[ $RESTORE_APP != 'mutt' ]]; then
return
fi
fi
for d in $SERVER_DIRECTORY/backup/mutt/*/ ; do
USERNAME=$(echo "$d" | awk -F '/' '{print $6}')
if [[ $USERNAME != "git" ]]; then
@ -243,6 +270,11 @@ function restore_mutt_settings {
}
function restore_gpg {
if [[ $RESTORE_APP != 'all' ]]; then
if [[ $RESTORE_APP != 'gpg' ]]; then
return
fi
fi
for d in $SERVER_DIRECTORY/backup/gnupg/*/ ; do
USERNAME=$(echo "$d" | awk -F '/' '{print $6}')
if [[ $USERNAME != "git" ]]; then
@ -270,6 +302,11 @@ function restore_gpg {
}
function restore_procmail {
if [[ $RESTORE_APP != 'all' ]]; then
if [[ $RESTORE_APP != 'procmail' ]]; then
return
fi
fi
for d in $SERVER_DIRECTORY/backup/procmail/*/ ; do
USERNAME=$(echo "$d" | awk -F '/' '{print $6}')
if [[ $USERNAME != "git" ]]; then
@ -291,6 +328,11 @@ function restore_procmail {
}
function restore_spamassassin {
if [[ $RESTORE_APP != 'all' ]]; then
if [[ $RESTORE_APP != 'spamassassin' ]]; then
return
fi
fi
for d in $SERVER_DIRECTORY/backup/spamassassin/*/ ; do
USERNAME=$(echo "$d" | awk -F '/' '{print $6}')
if [[ $USERNAME != "git" ]]; then
@ -312,6 +354,11 @@ function restore_spamassassin {
}
function restore_admin_readme {
if [[ $RESTORE_APP != 'all' ]]; then
if [[ $RESTORE_APP != 'readme' ]]; then
return
fi
fi
if [ -d $SERVER_DIRECTORY/backup/readme ]; then
echo $"Restoring README"
restore_directory_from_friend /root/tempreadme readme
@ -325,6 +372,11 @@ function restore_admin_readme {
}
function restore_ipfs {
if [[ $RESTORE_APP != 'all' ]]; then
if [[ $RESTORE_APP != 'ipfs' ]]; then
return
fi
fi
if [ -d $SERVER_DIRECTORY/backup/ipfs ]; then
echo $"Restoring IPFS"
restore_directory_from_friend /root/tempipfs ipfs
@ -338,6 +390,11 @@ function restore_ipfs {
}
function restore_ssh_keys {
if [[ $RESTORE_APP != 'all' ]]; then
if [[ $RESTORE_APP != 'ssh' ]]; then
return
fi
fi
for d in $SERVER_DIRECTORY/backup/ssh/*/ ; do
USERNAME=$(echo "$d" | awk -F '/' '{print $6}')
if [[ $USERNAME != "git" ]]; then
@ -359,6 +416,11 @@ function restore_ssh_keys {
}
function restore_user_config {
if [[ $RESTORE_APP != 'all' ]]; then
if [[ $RESTORE_APP != 'userconfig' ]]; then
return
fi
fi
for d in $SERVER_DIRECTORY/backup/config/*/ ; do
USERNAME=$(echo "$d" | awk -F '/' '{print $6}')
if [[ $USERNAME != "git" ]]; then
@ -380,6 +442,11 @@ function restore_user_config {
}
function restore_certs {
if [[ $RESTORE_APP != 'all' ]]; then
if [[ $RESTORE_APP != 'certs' ]]; then
return
fi
fi
if [ -d $SERVER_DIRECTORY/backup/ssl ]; then
echo $"Restoring certificates"
restore_directory_from_friend /root/tempssl ssl
@ -392,6 +459,11 @@ function restore_certs {
}
function restore_personal_settings {
if [[ $RESTORE_APP != 'all' ]]; then
if [[ $RESTORE_APP != 'personal' ]]; then
return
fi
fi
for d in $SERVER_DIRECTORY/backup/personal/*/ ; do
USERNAME=$(echo "$d" | awk -F '/' '{print $6}')
if [[ $USERNAME != "git" ]]; then
@ -415,6 +487,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_friend /root/tempmailinglist mailinglist
@ -427,6 +504,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_friend /root/tempxmpp xmpp
@ -441,6 +523,11 @@ function restore_xmpp {
}
function restore_gnu_social {
if [[ $RESTORE_APP != 'all' ]]; then
if [[ $RESTORE_APP != 'gnusocial' ]]; then
return
fi
fi
if grep -q "GNU Social domain" $COMPLETION_FILE; then
MICROBLOG_DOMAIN_NAME=$(cat $COMPLETION_FILE | grep "GNU Social domain" | awk -F ':' '{print $2}')
restore_database_from_friend gnusocial ${MICROBLOG_DOMAIN_NAME}
@ -451,6 +538,11 @@ function restore_gnu_social {
}
function restore_hubzilla {
if [[ $RESTORE_APP != 'all' ]]; then
if [[ $RESTORE_APP != 'hubzilla' ]]; then
return
fi
fi
if grep -q "Hubzilla domain" $COMPLETION_FILE; then
HUBZILLA_DOMAIN_NAME=$(cat $COMPLETION_FILE | grep "Hubzilla domain" | awk -F ':' '{print $2}')
restore_database_from_friend hubzilla ${HUBZILLA_DOMAIN_NAME}
@ -468,6 +560,11 @@ function restore_hubzilla {
}
function restore_owncloud {
if [[ $RESTORE_APP != 'all' ]]; then
if [[ $RESTORE_APP != 'owncloud' ]]; then
return
fi
fi
if grep -q "Owncloud domain" $COMPLETION_FILE; then
OWNCLOUD_DOMAIN_NAME=$(cat $COMPLETION_FILE | grep "Owncloud domain" | awk -F ':' '{print $2}')
restore_database_from_friend owncloud $OWNCLOUD_DOMAIN_NAME
@ -499,6 +596,11 @@ function restore_owncloud {
}
function restore_gogs {
if [[ $RESTORE_APP != 'all' ]]; then
if [[ $RESTORE_APP != 'gogs' ]]; then
return
fi
fi
if grep -q "Gogs domain" $COMPLETION_FILE; then
GIT_DOMAIN_NAME=$(cat $COMPLETION_FILE | grep "Gogs domain" | awk -F ':' '{print $2}')
restore_database_from_friend gogs $GIT_DOMAIN_NAME
@ -534,6 +636,11 @@ function restore_gogs {
}
function restore_wiki {
if [[ $RESTORE_APP != 'all' ]]; then
if [[ $RESTORE_APP != 'wiki' ]]; then
return
fi
fi
if [ -d $SERVER_DIRECTORY/backup/wiki ]; then
WIKI_DOMAIN_NAME=$(cat $COMPLETION_FILE | grep "Wiki domain" | awk -F ':' '{print $2}')
echo $"Restoring Wiki installation $WIKI_DOMAIN_NAME"
@ -562,6 +669,11 @@ function restore_wiki {
}
function restore_blog {
if [[ $RESTORE_APP != 'all' ]]; then
if [[ $RESTORE_APP != 'blog' ]]; then
return
fi
fi
if [ -d $SERVER_DIRECTORY/backup/blog ]; then
FULLBLOG_DOMAIN_NAME=$(cat $COMPLETION_FILE | grep "Blog domain" | awk -F ':' '{print $2}')
echo $"Restoring blog installation $FULLBLOG_DOMAIN_NAME"
@ -596,6 +708,11 @@ function restore_blog {
}
function restore_cjdns {
if [[ $RESTORE_APP != 'all' ]]; then
if [[ $RESTORE_APP != 'cjdns' ]]; then
return
fi
fi
if [ -d $SERVER_DIRECTORY/backup/cjdns ]; then
echo $"Restoring cjdns installation"
restore_directory_from_friend /root/tempcjdns cjdns
@ -609,6 +726,11 @@ function restore_cjdns {
}
function restore_voip {
if [[ $RESTORE_APP != 'all' ]]; then
if [[ $RESTORE_APP != 'voip' ]]; then
return
fi
fi
if [ -d $SERVER_DIRECTORY/backup/voip ]; then
echo $"Restoring VoIP settings"
restore_directory_from_friend /root/tempvoip voip
@ -637,6 +759,11 @@ function restore_voip {
}
function restore_tox {
if [[ $RESTORE_APP != 'all' ]]; then
if [[ $RESTORE_APP != 'tox' ]]; then
return
fi
fi
if [ -d $SERVER_DIRECTORY/backup/tox ]; then
echo $"Restoring Tox node settings"
restore_directory_from_friend / tox
@ -653,6 +780,11 @@ function restore_tox {
}
function restore_email {
if [[ $RESTORE_APP != 'all' ]]; then
if [[ $RESTORE_APP != 'email' ]]; then
return
fi
fi
for d in $SERVER_DIRECTORY/backup/mail/*/ ; do
USERNAME=$(echo "$d" | awk -F '/' '{print $6}')
if [[ $USERNAME != "git" ]]; then
@ -676,6 +808,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 $SERVER_DIRECTORY/backup/dlna ]; then
echo $"Restoring DLNA cache"