Restore using absolute or relative path

Obnam restores with the full path. duplicity restores with the relative path
This commit is contained in:
Bob Mottram 2017-08-25 17:35:33 +01:00
parent 4fc1ad9543
commit 52bf32cb28
31 changed files with 890 additions and 290 deletions

View File

@ -169,7 +169,20 @@ function restore_remote_cryptpad {
temp_restore_dir=/root/tempcryptpad temp_restore_dir=/root/tempcryptpad
function_check restore_directory_from_usb function_check restore_directory_from_usb
restore_directory_from_friend $temp_restore_dir cryptpad restore_directory_from_friend $temp_restore_dir cryptpad
if [ ! -d $temp_restore_dir$CRYPTPAD_DIR/datastore ]; then
if [ -d $temp_restore_dir ]; then
cp -r $temp_restore_dir/* $CRYPTPAD_DIR/datastore/
else
systemctl start cryptpad
echo 'Failed to restore cryptpad'
rm -rf $temp_restore_dir
return
fi
else
cp -r $temp_restore_dir$CRYPTPAD_DIR/datastore/* $CRYPTPAD_DIR/datastore/ cp -r $temp_restore_dir$CRYPTPAD_DIR/datastore/* $CRYPTPAD_DIR/datastore/
fi
rm -rf $temp_restore_dir
systemctl start cryptpad systemctl start cryptpad
fi fi
} }

View File

@ -113,7 +113,11 @@ function restore_local_dlna {
temp_restore_dir=/root/tempdlna temp_restore_dir=/root/tempdlna
function_check restore_directory_from_usb function_check restore_directory_from_usb
restore_directory_from_usb $temp_restore_dir dlna restore_directory_from_usb $temp_restore_dir dlna
if [ -d $temp_restore_dir/var/cache/minidlna ]; then
cp -r $temp_restore_dir/var/cache/minidlna/* /var/cache/minidlna/ cp -r $temp_restore_dir/var/cache/minidlna/* /var/cache/minidlna/
else
cp -r $temp_restore_dir/* /var/cache/minidlna/
fi
if [ ! "$?" = "0" ]; then if [ ! "$?" = "0" ]; then
rm -rf $temp_restore_dir rm -rf $temp_restore_dir
function_check set_user_permissions function_check set_user_permissions
@ -139,7 +143,11 @@ function restore_remote_dlna {
temp_restore_dir=/root/tempdlna temp_restore_dir=/root/tempdlna
function_check restore_directory_from_friend function_check restore_directory_from_friend
restore_directory_from_friend $temp_restore_dir dlna restore_directory_from_friend $temp_restore_dir dlna
if [ -d $temp_restore_dir/var/cache/minidlna ]; then
cp -r $temp_restore_dir/var/cache/minidlna/* /var/cache/minidlna/ cp -r $temp_restore_dir/var/cache/minidlna/* /var/cache/minidlna/
else
cp -r $temp_restore_dir/* /var/cache/minidlna/
fi
if [ ! "$?" = "0" ]; then if [ ! "$?" = "0" ]; then
exit 982 exit 982
fi fi

View File

@ -13,7 +13,7 @@
# License # License
# ======= # =======
# #
# Copyright (C) 2014-2016 Bob Mottram <bob@freedombone.net> # Copyright (C) 2014-2017 Bob Mottram <bob@freedombone.net>
# #
# This program is free software: you can redistribute it and/or modify # This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as published by # it under the terms of the GNU Affero General Public License as published by
@ -144,59 +144,7 @@ function backup_local_dokuwiki {
fi fi
} }
function restore_local_dokuwiki_legacy {
if [ -d /var/lib/dokuwiki ]; then
echo $"Restoring Legacy Dokuwiki installation"
function_check get_completion_param
DOKUWIKI_DOMAIN_NAME=$(get_completion_param "dokuwiki domain")
temp_restore_dir=/root/tempdokuwiki
function_check restore_directory_from_usb
if [ -d ${USB_MOUNT}/backup/dokuwiki ]; then
restore_directory_from_usb ${temp_restore_dir} dokuwiki
else
restore_directory_from_usb ${temp_restore_dir} wiki
fi
# restore the data
cp -r ${temp_restore_dir}/var/lib/dokuwiki/data/* /var/www/$DOKUWIKI_DOMAIN_NAME/htdocs/data
if [ ! "$?" = "0" ]; then
function_check restore_directory_from_usb
set_user_permissions
function_check backup_unmount_drive
backup_unmount_drive
rm -rf ${temp_restore_dir}
exit 73562
fi
# restore the users
cp -r ${temp_restore_dir}/var/lib/dokuwiki/acl/users.auth.php /var/www/$DOKUWIKI_DOMAIN_NAME/htdocs/lib/plugins/acl
cp -r ${temp_restore_dir}/var/lib/dokuwiki/acl/users.auth.php /var/www/$DOKUWIKI_DOMAIN_NAME/htdocs/conf
if [ ! "$?" = "0" ]; then
function_check restore_directory_from_usb
set_user_permissions
function_check backup_unmount_drive
backup_unmount_drive
rm -rf ${temp_restore_dir}
exit 23985
fi
rm -rf ${temp_restore_dir}
chmod -R 755 /var/www/$DOKUWIKI_DOMAIN_NAME/htdocs/data
chmod -R 755 /var/www/$DOKUWIKI_DOMAIN_NAME/htdocs/lib
chmod 640 /var/www/$DOKUWIKI_DOMAIN_NAME/htdocs/lib/plugins/acl/users.auth.php
chmod 640 /var/www/$DOKUWIKI_DOMAIN_NAME/htdocs/conf/users.auth.php
chown -R www-data:www-data /var/www/$DOKUWIKI_DOMAIN_NAME/htdocs
echo $"Restore of Legacy Dokuwiki complete"
fi
}
function restore_local_dokuwiki { function restore_local_dokuwiki {
if [ -d ${USB_MOUNT}/backup/dokuwiki ]; then
restore_local_dokuwiki_legacy
return
fi
echo $"Restoring Dokuwiki installation" echo $"Restoring Dokuwiki installation"
function_check get_completion_param function_check get_completion_param
DOKUWIKI_DOMAIN_NAME=$(get_completion_param "dokuwiki domain") DOKUWIKI_DOMAIN_NAME=$(get_completion_param "dokuwiki domain")
@ -205,7 +153,11 @@ function restore_local_dokuwiki {
temp_restore_dir=/root/tempdokuwikidat temp_restore_dir=/root/tempdokuwikidat
function_check restore_directory_from_usb function_check restore_directory_from_usb
restore_directory_from_usb ${temp_restore_dir} dokuwikidat restore_directory_from_usb ${temp_restore_dir} dokuwikidat
if [ -d ${temp_restore_dir}/var/www/${DOKUWIKI_DOMAIN_NAME}/htdocs/data ]; then
cp -r ${temp_restore_dir}/var/www/${DOKUWIKI_DOMAIN_NAME}/htdocs/data/* /var/www/$DOKUWIKI_DOMAIN_NAME/htdocs/data cp -r ${temp_restore_dir}/var/www/${DOKUWIKI_DOMAIN_NAME}/htdocs/data/* /var/www/$DOKUWIKI_DOMAIN_NAME/htdocs/data
else
cp -r ${temp_restore_dir}/* /var/www/$DOKUWIKI_DOMAIN_NAME/htdocs/data
fi
if [ ! "$?" = "0" ]; then if [ ! "$?" = "0" ]; then
function_check restore_directory_from_usb function_check restore_directory_from_usb
set_user_permissions set_user_permissions
@ -220,8 +172,13 @@ function restore_local_dokuwiki {
temp_restore_dir=/root/tempdokuwikiacl temp_restore_dir=/root/tempdokuwikiacl
function_check restore_directory_from_usb function_check restore_directory_from_usb
restore_directory_from_usb ${temp_restore_dir} dokuwikiacl restore_directory_from_usb ${temp_restore_dir} dokuwikiacl
if [ -d ${temp_restore_dir}/var/www/${DOKUWIKI_DOMAIN_NAME}/htdocs/lib/plugins/acl ]; then
cp ${temp_restore_dir}/var/www/${DOKUWIKI_DOMAIN_NAME}/htdocs/lib/plugins/acl/users.auth.php /var/www/$DOKUWIKI_DOMAIN_NAME/htdocs/lib/plugins/acl/ cp ${temp_restore_dir}/var/www/${DOKUWIKI_DOMAIN_NAME}/htdocs/lib/plugins/acl/users.auth.php /var/www/$DOKUWIKI_DOMAIN_NAME/htdocs/lib/plugins/acl/
cp ${temp_restore_dir}/var/www/${DOKUWIKI_DOMAIN_NAME}/htdocs/lib/plugins/acl/users.auth.php /var/www/$DOKUWIKI_DOMAIN_NAME/htdocs/conf/ cp ${temp_restore_dir}/var/www/${DOKUWIKI_DOMAIN_NAME}/htdocs/lib/plugins/acl/users.auth.php /var/www/$DOKUWIKI_DOMAIN_NAME/htdocs/conf/
else
cp ${temp_restore_dir}/users.auth.php /var/www/$DOKUWIKI_DOMAIN_NAME/htdocs/lib/plugins/acl/
cp ${temp_restore_dir}/users.auth.php /var/www/$DOKUWIKI_DOMAIN_NAME/htdocs/conf/
fi
if [ ! "$?" = "0" ]; then if [ ! "$?" = "0" ]; then
function_check restore_directory_from_usb function_check restore_directory_from_usb
set_user_permissions set_user_permissions
@ -257,24 +214,34 @@ function restore_remote_dokuwiki {
if [ -d $SERVER_DIRECTORY/backup/dokuwikidat ]; then if [ -d $SERVER_DIRECTORY/backup/dokuwikidat ]; then
echo $"Restoring Dokuwiki data for $DOKUWIKI_DOMAIN_NAME" echo $"Restoring Dokuwiki data for $DOKUWIKI_DOMAIN_NAME"
restore_directory_from_friend /root/tempdokuwikidat dokuwikidat temp_restore_dir=/root/tempdokuwikidat
cp -r /root/tempdokuwikidat/var/www/$DOKUWIKI_DOMAIN_NAME/htdocs/data/* /var/www/$DOKUWIKI_DOMAIN_NAME/htdocs/data/ restore_directory_from_friend $temp_restore_dir dokuwikidat
if [ -d $temp_restore_dir/var/www/$DOKUWIKI_DOMAIN_NAME/htdocs/data ]; then
cp -r $temp_restore_dir/var/www/$DOKUWIKI_DOMAIN_NAME/htdocs/data/* /var/www/$DOKUWIKI_DOMAIN_NAME/htdocs/data/
else
cp -r $temp_restore_dir/* /var/www/$DOKUWIKI_DOMAIN_NAME/htdocs/data/
fi
if [ ! "$?" = "0" ]; then if [ ! "$?" = "0" ]; then
exit 92634 exit 92634
fi fi
rm -rf /root/tempdokuwikidat rm -rf $temp_restore_dir
echo $"Restore of Dokuwiki data complete" echo $"Restore of Dokuwiki data complete"
fi fi
if [ -d $SERVER_DIRECTORY/backup/dokuwikiacl ]; then if [ -d $SERVER_DIRECTORY/backup/dokuwikiacl ]; then
echo $"Restoring Dokuwiki users for $DOKUWIKI_DOMAIN_NAME" echo $"Restoring Dokuwiki users for $DOKUWIKI_DOMAIN_NAME"
restore_directory_from_friend /root/tempdokuwikiacl dokuwikiacl temp_restore_dir=/root/tempdokuwikiacl
cp -r /root/tempdokuwikidat/var/www/$DOKUWIKI_DOMAIN_NAME/htdocs/lib/plugins/acl/* /var/www/$DOKUWIKI_DOMAIN_NAME/htdocs/lib/plugins/acl/ restore_directory_from_friend $temp_restore_dir dokuwikiacl
if [ -d $temp_restore_dir/var/www/$DOKUWIKI_DOMAIN_NAME/htdocs/lib/plugins/acl ]; then
cp -r $temp_restore_dir/var/www/$DOKUWIKI_DOMAIN_NAME/htdocs/lib/plugins/acl/* /var/www/$DOKUWIKI_DOMAIN_NAME/htdocs/lib/plugins/acl/
else
cp -r $temp_restore_dir/* /var/www/$DOKUWIKI_DOMAIN_NAME/htdocs/lib/plugins/acl/
fi
if [ ! "$?" = "0" ]; then if [ ! "$?" = "0" ]; then
exit 735287 exit 735287
fi fi
rm -rf /root/tempdokuwikiacl rm -rf $temp_restore_dir
echo $"Restore of Dokuwiki users complete" echo $"Restore of Dokuwiki users complete"
fi fi

View File

@ -81,7 +81,14 @@ function restore_local_emacs {
echo $"Restoring Emacs config for $USERNAME" echo $"Restoring Emacs config for $USERNAME"
function_check restore_directory_from_usb function_check restore_directory_from_usb
restore_directory_from_usb $temp_restore_dir emacs/$USERNAME restore_directory_from_usb $temp_restore_dir emacs/$USERNAME
if [ -d $temp_restore_dir/home/$USERNAME/.emacs.d ]; then
cp -r $temp_restore_dir/home/$USERNAME/.emacs.d /home/$USERNAME/ cp -r $temp_restore_dir/home/$USERNAME/.emacs.d /home/$USERNAME/
else
if [ ! -d /home/$USERNAME/.emacs.d ]; then
mkdir /home/$USERNAME/.emacs.d
fi
cp -r $temp_restore_dir/* /home/$USERNAME/.emacs.d
fi
if [ ! "$?" = "0" ]; then if [ ! "$?" = "0" ]; then
rm -rf $temp_restore_dir rm -rf $temp_restore_dir
function_check set_user_permissions function_check set_user_permissions
@ -90,7 +97,11 @@ function restore_local_emacs {
backup_unmount_drive backup_unmount_drive
exit 664 exit 664
fi fi
if [ -d $temp_restore_dir/home/$USERNAME/.emacs.d ]; then
cp -f $temp_restore_dir/home/$USERNAME/.emacs.d/dotemacs /home/$USERNAME/.emacs cp -f $temp_restore_dir/home/$USERNAME/.emacs.d/dotemacs /home/$USERNAME/.emacs
else
cp -f $temp_restore_dir/dotemacs /home/$USERNAME/.emacs
fi
rm -rf $temp_restore_dir rm -rf $temp_restore_dir
fi fi
done done
@ -125,7 +136,14 @@ function restore_remote_emacs {
echo $"Restoring Emacs config for $USERNAME" echo $"Restoring Emacs config for $USERNAME"
function_check restore_directory_from_friend function_check restore_directory_from_friend
restore_directory_from_friend $temp_restore_dir emacs/$USERNAME restore_directory_from_friend $temp_restore_dir emacs/$USERNAME
if [ -d $temp_restore_dir/home/$USERNAME/.emacs.d ]; then
cp -r $temp_restore_dir/home/$USERNAME/.emacs.d /home/$USERNAME/ cp -r $temp_restore_dir/home/$USERNAME/.emacs.d /home/$USERNAME/
else
if [ ! -d /home/$USERNAME/.emacs.d ]; then
mkdir /home/$USERNAME/.emacs.d
fi
cp -r $temp_restore_dir/* /home/$USERNAME/.emacs.d/*
fi
if [ ! "$?" = "0" ]; then if [ ! "$?" = "0" ]; then
rm -rf $temp_restore_dir rm -rf $temp_restore_dir
function_check set_user_permissions function_check set_user_permissions
@ -134,7 +152,11 @@ function restore_remote_emacs {
backup_unmount_drive backup_unmount_drive
exit 664 exit 664
fi fi
if [ -d $temp_restore_dir/home/$USERNAME/.emacs.d ]; then
cp -f $temp_restore_dir/home/$USERNAME/.emacs.d/dotemacs /home/$USERNAME/.emacs cp -f $temp_restore_dir/home/$USERNAME/.emacs.d/dotemacs /home/$USERNAME/.emacs
else
cp -f $temp_restore_dir/dotemacs /home/$USERNAME/.emacs
fi
rm -rf $temp_restore_dir rm -rf $temp_restore_dir
fi fi
done done

View File

@ -251,7 +251,11 @@ function restore_local_ghost {
function_check restore_directory_from_usb function_check restore_directory_from_usb
restore_directory_from_usb $temp_restore_dir ghostcontent restore_directory_from_usb $temp_restore_dir ghostcontent
if [ -d $temp_restore_dir ]; then if [ -d $temp_restore_dir ]; then
if [ -d $temp_restore_dir/var/www/$GHOST_DOMAIN_NAME/htdocs/content ]; then
cp -r $temp_restore_dir/var/www/$GHOST_DOMAIN_NAME/htdocs/content/* /var/www/$GHOST_DOMAIN_NAME/htdocs/content/ cp -r $temp_restore_dir/var/www/$GHOST_DOMAIN_NAME/htdocs/content/* /var/www/$GHOST_DOMAIN_NAME/htdocs/content/
else
cp -r $temp_restore_dir/* /var/www/$GHOST_DOMAIN_NAME/htdocs/content/
fi
chown -R ghost:ghost /var/www/$GHOST_DOMAIN_NAME/htdocs/content chown -R ghost:ghost /var/www/$GHOST_DOMAIN_NAME/htdocs/content
rm -rf $temp_restore_dir rm -rf $temp_restore_dir
fi fi
@ -291,7 +295,11 @@ function restore_remote_ghost {
function_check restore_directory_from_friend function_check restore_directory_from_friend
restore_directory_from_friend $temp_restore_dir ghostcontent restore_directory_from_friend $temp_restore_dir ghostcontent
if [ -d $temp_restore_dir ]; then if [ -d $temp_restore_dir ]; then
if [ -d $temp_restore_dir/var/www/$GHOST_DOMAIN_NAME/htdocs/content ]; then
cp -r $temp_restore_dir/var/www/$GHOST_DOMAIN_NAME/htdocs/content/* /var/www/$GHOST_DOMAIN_NAME/htdocs/content/ cp -r $temp_restore_dir/var/www/$GHOST_DOMAIN_NAME/htdocs/content/* /var/www/$GHOST_DOMAIN_NAME/htdocs/content/
else
cp -r $temp_restore_dir/* /var/www/$GHOST_DOMAIN_NAME/htdocs/content/
fi
chown -R ghost: /var/www/$GHOST_DOMAIN_NAME/htdocs chown -R ghost: /var/www/$GHOST_DOMAIN_NAME/htdocs
rm -rf $temp_restore_dir rm -rf $temp_restore_dir
fi fi

View File

@ -430,16 +430,31 @@ function restore_local_gnusocial {
function_check restore_directory_from_usb function_check restore_directory_from_usb
restore_directory_from_usb $temp_restore_dir gnusocialconfig restore_directory_from_usb $temp_restore_dir gnusocialconfig
if [ -d $temp_restore_dir ]; then if [ -d $temp_restore_dir ]; then
if [ -d cp $temp_restore_dir$gnusocial_dir ]; then
cp $temp_restore_dir$gnusocial_dir/backup/config.php $gnusocial_dir/ cp $temp_restore_dir$gnusocial_dir/backup/config.php $gnusocial_dir/
chown www-data:www-data $gnusocial_dir/config.php
cp -rp $temp_restore_dir$gnusocial_dir/static $gnusocial_dir/ cp -rp $temp_restore_dir$gnusocial_dir/static $gnusocial_dir/
else
cp $temp_restore_dir/backup/config.php $gnusocial_dir/
if [ ! -d $gnusocial_dir/static ]; then
mkdir $gnusocial_dir/static
fi
cp -rp $temp_restore_dir/static/* $gnusocial_dir/static/
fi
chown www-data:www-data $gnusocial_dir/config.php
chown -R www-data:www-data $gnusocial_dir/static chown -R www-data:www-data $gnusocial_dir/static
rm -rf $temp_restore_dir rm -rf $temp_restore_dir
fi fi
restore_directory_from_usb $temp_restore_dir gnusocialfile restore_directory_from_usb $temp_restore_dir gnusocialfile
if [ -d $temp_restore_dir ]; then if [ -d $temp_restore_dir ]; then
if [ -d cp $temp_restore_dir$gnusocial_dir/file ]; then
cp -rp $temp_restore_dir$gnusocial_dir/file $gnusocial_dir/ cp -rp $temp_restore_dir$gnusocial_dir/file $gnusocial_dir/
else
if [ ! -d $gnusocial_dir/file ]; then
mkdir $gnusocial_dir/file
fi
cp -rp $temp_restore_dir/* $gnusocial_dir/file
fi
chown -R www-data:www-data $gnusocial_dir/file chown -R www-data:www-data $gnusocial_dir/file
rm -rf $temp_restore_dir rm -rf $temp_restore_dir
fi fi
@ -511,16 +526,31 @@ function restore_remote_gnusocial {
function_check restore_directory_from_friend function_check restore_directory_from_friend
restore_directory_from_friend $temp_restore_dir gnusocialconfig restore_directory_from_friend $temp_restore_dir gnusocialconfig
if [ -d $temp_restore_dir ]; then if [ -d $temp_restore_dir ]; then
if [ -d $temp_restore_dir$gnusocial_dir ]; then
cp $temp_restore_dir$gnusocial_dir/backup/config.php $gnusocial_dir/ cp $temp_restore_dir$gnusocial_dir/backup/config.php $gnusocial_dir/
chown www-data:www-data $gnusocial_dir/config.php
cp -rp $temp_restore_dir$gnusocial_dir/static $gnusocial_dir/ cp -rp $temp_restore_dir$gnusocial_dir/static $gnusocial_dir/
else
cp $temp_restore_dir/backup/config.php $gnusocial_dir/
if [ ! -d $gnusocial_dir/static ]; then
mkdir $gnusocial_dir/static
fi
cp -rp $temp_restore_dir/static/* $gnusocial_dir/static/
fi
chown www-data:www-data $gnusocial_dir/config.php
chown -R www-data:www-data $gnusocial_dir/static chown -R www-data:www-data $gnusocial_dir/static
rm -rf $temp_restore_dir rm -rf $temp_restore_dir
fi fi
restore_directory_from_friend $temp_restore_dir gnusocialfile restore_directory_from_friend $temp_restore_dir gnusocialfile
if [ -d $temp_restore_dir ]; then if [ -d $temp_restore_dir ]; then
if [ ! -d $temp_restore_dir$gnusocial_dir/file ]; then
cp -rp $temp_restore_dir$gnusocial_dir/file $gnusocial_dir/ cp -rp $temp_restore_dir$gnusocial_dir/file $gnusocial_dir/
else
if [ ! -d $gnusocial_dir/file ]; then
mkdir $gnusocial_dir/file
fi
cp -rp $temp_restore_dir/* $gnusocial_dir/file/
fi
chown -R www-data:www-data $gnusocial_dir/file chown -R www-data:www-data $gnusocial_dir/file
rm -rf $temp_restore_dir rm -rf $temp_restore_dir
fi fi

View File

@ -249,7 +249,11 @@ function restore_local_gogs {
if [ ! -d /home/${GOGS_USERNAME}/custom ]; then if [ ! -d /home/${GOGS_USERNAME}/custom ]; then
mkdir -p /home/${GOGS_USERNAME}/custom mkdir -p /home/${GOGS_USERNAME}/custom
fi fi
if [ ! -d ${temp_restore_dir}/home/${GOGS_USERNAME}/custom ]; then
cp -r ${temp_restore_dir}/home/${GOGS_USERNAME}/custom/* /home/${GOGS_USERNAME}/custom cp -r ${temp_restore_dir}/home/${GOGS_USERNAME}/custom/* /home/${GOGS_USERNAME}/custom
else
cp -r ${temp_restore_dir}/* /home/${GOGS_USERNAME}/custom/
fi
if [ ! "$?" = "0" ]; then if [ ! "$?" = "0" ]; then
function_check set_user_permissions function_check set_user_permissions
set_user_permissions set_user_permissions
@ -260,7 +264,11 @@ function restore_local_gogs {
echo $"Restoring Gogs repos" echo $"Restoring Gogs repos"
function_check restore_directory_from_usb function_check restore_directory_from_usb
restore_directory_from_usb ${temp_restore_dir}repos gogsrepos restore_directory_from_usb ${temp_restore_dir}repos gogsrepos
if [ ! -d ${temp_restore_dir}repos/home/${GOGS_USERNAME}/gogs-repositories ]; then
cp -r ${temp_restore_dir}repos/home/${GOGS_USERNAME}/gogs-repositories/* /home/${GOGS_USERNAME}/gogs-repositories/ cp -r ${temp_restore_dir}repos/home/${GOGS_USERNAME}/gogs-repositories/* /home/${GOGS_USERNAME}/gogs-repositories/
else
cp -r ${temp_restore_dir}/* /home/${GOGS_USERNAME}/gogs-repositories/
fi
if [ ! "$?" = "0" ]; then if [ ! "$?" = "0" ]; then
function_check set_user_permissions function_check set_user_permissions
set_user_permissions set_user_permissions
@ -274,7 +282,11 @@ function restore_local_gogs {
if [ ! -d /home/${GOGS_USERNAME}/.ssh ]; then if [ ! -d /home/${GOGS_USERNAME}/.ssh ]; then
mkdir /home/${GOGS_USERNAME}/.ssh mkdir /home/${GOGS_USERNAME}/.ssh
fi fi
if [ -d ${temp_restore_dir}ssh/home/${GOGS_USERNAME}/.ssh ]; then
cp -r ${temp_restore_dir}ssh/home/${GOGS_USERNAME}/.ssh/* /home/${GOGS_USERNAME}/.ssh/ cp -r ${temp_restore_dir}ssh/home/${GOGS_USERNAME}/.ssh/* /home/${GOGS_USERNAME}/.ssh/
else
cp -r ${temp_restore_dir}/* /home/${GOGS_USERNAME}/.ssh/
fi
if [ ! "$?" = "0" ]; then if [ ! "$?" = "0" ]; then
function_check set_user_permissions function_check set_user_permissions
set_user_permissions set_user_permissions
@ -338,13 +350,21 @@ function restore_remote_gogs {
if [ ! -d /home/${GOGS_USERNAME}/custom ]; then if [ ! -d /home/${GOGS_USERNAME}/custom ]; then
mkdir -p /home/${GOGS_USERNAME}/custom mkdir -p /home/${GOGS_USERNAME}/custom
fi fi
if [ -d /root/tempgogs/home/${GOGS_USERNAME}/custom ]; then
cp -r /root/tempgogs/home/${GOGS_USERNAME}/custom/* /home/${GOGS_USERNAME}/custom/ cp -r /root/tempgogs/home/${GOGS_USERNAME}/custom/* /home/${GOGS_USERNAME}/custom/
else
cp -r /root/tempgogs/* /home/${GOGS_USERNAME}/custom/
fi
if [ ! "$?" = "0" ]; then if [ ! "$?" = "0" ]; then
exit 58852 exit 58852
fi fi
echo $"Restoring Gogs repos" echo $"Restoring Gogs repos"
restore_directory_from_friend /root/tempgogsrepos gogsrepos restore_directory_from_friend /root/tempgogsrepos gogsrepos
if [ -d /root/tempgogsrepos/home/${GOGS_USERNAME}/gogs-repositories ]; then
cp -r /root/tempgogsrepos/home/${GOGS_USERNAME}/gogs-repositories/* /home/${GOGS_USERNAME}/gogs-repositories/ cp -r /root/tempgogsrepos/home/${GOGS_USERNAME}/gogs-repositories/* /home/${GOGS_USERNAME}/gogs-repositories/
else
cp -r /root/tempgogsrepos/* /home/${GOGS_USERNAME}/gogs-repositories/
fi
if [ ! "$?" = "0" ]; then if [ ! "$?" = "0" ]; then
exit 7649 exit 7649
fi fi
@ -353,7 +373,11 @@ function restore_remote_gogs {
if [ ! -d /home/${GOGS_USERNAME}/.ssh ]; then if [ ! -d /home/${GOGS_USERNAME}/.ssh ]; then
mkdir /home/${GOGS_USERNAME}/.ssh mkdir /home/${GOGS_USERNAME}/.ssh
fi fi
if [ -d /root/tempgogsssh/home/${GOGS_USERNAME}/.ssh ]; then
cp -r /root/tempgogsssh/home/${GOGS_USERNAME}/.ssh/* /home/${GOGS_USERNAME}/.ssh/ cp -r /root/tempgogsssh/home/${GOGS_USERNAME}/.ssh/* /home/${GOGS_USERNAME}/.ssh/
else
cp -r /root/tempgogsssh/* /home/${GOGS_USERNAME}/.ssh/
fi
if [ ! "$?" = "0" ]; then if [ ! "$?" = "0" ]; then
exit 74239 exit 74239
fi fi

View File

@ -249,8 +249,15 @@ function restore_local_htmly {
fi fi
mv /var/www/${HTMLY_DOMAIN_NAME}/htdocs /var/www/${HTMLY_DOMAIN_NAME}/previous mv /var/www/${HTMLY_DOMAIN_NAME}/htdocs /var/www/${HTMLY_DOMAIN_NAME}/previous
fi fi
if [ -d ${temp_restore_dir}/var/www/${HTMLY_DOMAIN_NAME}/htdocs ]; then
temp_source_dir=$(find ${temp_restore_dir} -name htdocs) temp_source_dir=$(find ${temp_restore_dir} -name htdocs)
cp -r ${temp_source_dir} /var/www/${HTMLY_DOMAIN_NAME}/ cp -r ${temp_source_dir} /var/www/${HTMLY_DOMAIN_NAME}/
else
if [ ! -d /var/www/${HTMLY_DOMAIN_NAME}/htdocs ]; then
mkdir /var/www/${HTMLY_DOMAIN_NAME}/htdocs
fi
cp -r ${temp_restore_dir}/* /var/www/${HTMLY_DOMAIN_NAME}/htdocs/
fi
if [ ! "$?" = "0" ]; then if [ ! "$?" = "0" ]; then
if [ -d /var/www/${HTMLY_DOMAIN_NAME}/previous ]; then if [ -d /var/www/${HTMLY_DOMAIN_NAME}/previous ]; then
mv /var/www/${HTMLY_DOMAIN_NAME}/previous /var/www/${HTMLY_DOMAIN_NAME}/htdocs mv /var/www/${HTMLY_DOMAIN_NAME}/previous /var/www/${HTMLY_DOMAIN_NAME}/htdocs
@ -315,8 +322,17 @@ function restore_remote_htmly {
fi fi
mv /var/www/${HTMLY_DOMAIN_NAME}/htdocs /var/www/${HTMLY_DOMAIN_NAME}/previous mv /var/www/${HTMLY_DOMAIN_NAME}/htdocs /var/www/${HTMLY_DOMAIN_NAME}/previous
fi fi
if [ -d ${temp_restore_dir}/var/www/${HTMLY_DOMAIN_NAME}/htdocs ]; then
temp_source_dir=$(find ${temp_restore_dir} -name htdocs) temp_source_dir=$(find ${temp_restore_dir} -name htdocs)
cp -r ${temp_source_dir} /var/www/${HTMLY_DOMAIN_NAME}/ cp -r ${temp_source_dir} /var/www/${HTMLY_DOMAIN_NAME}/
else
if [ ! -d /var/www/${HTMLY_DOMAIN_NAME}/htdocs ]; then
mkdir /var/www/${HTMLY_DOMAIN_NAME}/htdocs
fi
cp -r ${temp_restore_dir}/* /var/www/${HTMLY_DOMAIN_NAME}/htdocs/
fi
if [ ! "$?" = "0" ]; then if [ ! "$?" = "0" ]; then
if [ -d /var/www/${HTMLY_DOMAIN_NAME}/previous ]; then if [ -d /var/www/${HTMLY_DOMAIN_NAME}/previous ]; then
mv /var/www/${HTMLY_DOMAIN_NAME}/previous /var/www/${HTMLY_DOMAIN_NAME}/htdocs mv /var/www/${HTMLY_DOMAIN_NAME}/previous /var/www/${HTMLY_DOMAIN_NAME}/htdocs

View File

@ -119,7 +119,11 @@ function restore_local_ipfs {
function_check restore_directory_from_usb function_check restore_directory_from_usb
restore_directory_from_usb $temp_restore_dir ipfs restore_directory_from_usb $temp_restore_dir ipfs
ADMIN_USERNAME=$(get_completion_param "Admin user") ADMIN_USERNAME=$(get_completion_param "Admin user")
if [ -d $temp_restore_dir/home/$ADMIN_USERNAME/.ipfs ]; then
cp -rf $temp_restore_dir/home/$ADMIN_USERNAME/.ipfs/* /home/$ADMIN_USERNAME/.ipfs cp -rf $temp_restore_dir/home/$ADMIN_USERNAME/.ipfs/* /home/$ADMIN_USERNAME/.ipfs
else
cp -rf $temp_restore_dir/* /home/$ADMIN_USERNAME/.ipfs
fi
if [ ! "$?" = "0" ]; then if [ ! "$?" = "0" ]; then
rm -rf $temp_restore_dir rm -rf $temp_restore_dir
function_check set_user_permissions function_check set_user_permissions
@ -151,7 +155,11 @@ function restore_remote_ipfs {
temp_restore_dir=/root/tempipfs temp_restore_dir=/root/tempipfs
function_check restore_directory_from_friend function_check restore_directory_from_friend
restore_directory_from_friend $temp_restore_dir ipfs restore_directory_from_friend $temp_restore_dir ipfs
if [ -d $temp_restore_dir/home/$ADMIN_USERNAME/.ipfs ]; then
cp -rf $temp_restore_dir/home/$ADMIN_USERNAME/.ipfs/* /home/$ADMIN_USERNAME/.ipfs cp -rf $temp_restore_dir/home/$ADMIN_USERNAME/.ipfs/* /home/$ADMIN_USERNAME/.ipfs
else
cp -rf $temp_restore_dir/* /home/$ADMIN_USERNAME/.ipfs
fi
if [ ! "$?" = "0" ]; then if [ ! "$?" = "0" ]; then
function_check set_user_permissions function_check set_user_permissions
set_user_permissions set_user_permissions

View File

@ -243,14 +243,25 @@ function restore_local_kanboard {
function_check restore_directory_from_usb function_check restore_directory_from_usb
restore_directory_from_usb $temp_restore_dir kanboardconfig restore_directory_from_usb $temp_restore_dir kanboardconfig
if [ -d $temp_restore_dir ]; then if [ -d $temp_restore_dir ]; then
if [ -d $temp_restore_dir$kanboard_dir/backup ]; then
cp $temp_restore_dir$kanboard_dir/backup/config.php $kanboard_dir/ cp $temp_restore_dir$kanboard_dir/backup/config.php $kanboard_dir/
else
cp $temp_restore_dir/config.php $kanboard_dir/
fi
chown www-data:www-data $kanboard_dir/config.php chown www-data:www-data $kanboard_dir/config.php
rm -rf $temp_restore_dir rm -rf $temp_restore_dir
fi fi
restore_directory_from_usb $temp_restore_dir kanboardfile restore_directory_from_usb $temp_restore_dir kanboardfile
if [ -d $temp_restore_dir ]; then if [ -d $temp_restore_dir ]; then
if [ -d $temp_restore_dir$kanboard_dir/data ]; then
cp -rp $temp_restore_dir$kanboard_dir/data $kanboard_dir/ cp -rp $temp_restore_dir$kanboard_dir/data $kanboard_dir/
else
if [ ! -d $kanboard_dir/data ]; then
mkdir $kanboard_dir/data
fi
cp -rp $temp_restore_dir/* $kanboard_dir/data/
fi
chown -R www-data:www-data $kanboard_dir/data chown -R www-data:www-data $kanboard_dir/data
rm -rf $temp_restore_dir rm -rf $temp_restore_dir
fi fi
@ -313,14 +324,25 @@ function restore_remote_kanboard {
function_check restore_directory_from_friend function_check restore_directory_from_friend
restore_directory_from_friend $temp_restore_dir kanboardconfig restore_directory_from_friend $temp_restore_dir kanboardconfig
if [ -d $temp_restore_dir ]; then if [ -d $temp_restore_dir ]; then
if [ -d $temp_restore_dir$kanboard_dir/backup ]; then
cp $temp_restore_dir$kanboard_dir/backup/config.php $kanboard_dir/ cp $temp_restore_dir$kanboard_dir/backup/config.php $kanboard_dir/
else
cp $temp_restore_dir/config.php $kanboard_dir/
fi
chown www-data:www-data $kanboard_dir/config.php chown www-data:www-data $kanboard_dir/config.php
rm -rf $temp_restore_dir rm -rf $temp_restore_dir
fi fi
restore_directory_from_friend $temp_restore_dir kanboardfile restore_directory_from_friend $temp_restore_dir kanboardfile
if [ -d $temp_restore_dir ]; then if [ -d $temp_restore_dir ]; then
if [ -d $temp_restore_dir$kanboard_dir/data ]; then
cp -rp $temp_restore_dir$kanboard_dir/data $kanboard_dir/ cp -rp $temp_restore_dir$kanboard_dir/data $kanboard_dir/
else
if [ ! -d $kanboard_dir/data ]; then
mkdir $kanboard_dir/data
fi
cp -rp $temp_restore_dir/* $kanboard_dir/data/
fi
chown -R www-data:www-data $kanboard_dir/data chown -R www-data:www-data $kanboard_dir/data
rm -rf $temp_restore_dir rm -rf $temp_restore_dir
fi fi

View File

@ -202,7 +202,11 @@ function restore_local_keyserver {
temp_restore_dir=/root/tempkeyserverconfig temp_restore_dir=/root/tempkeyserverconfig
function_check restore_directory_from_usb function_check restore_directory_from_usb
restore_directory_from_usb $temp_restore_dir keyserverconfig restore_directory_from_usb $temp_restore_dir keyserverconfig
if [ -d $temp_restore_dir/etc/sks ]; then
cp -r $temp_restore_dir/etc/sks/* /etc/sks/ cp -r $temp_restore_dir/etc/sks/* /etc/sks/
else
cp -r $temp_restore_dir/* /etc/sks/
fi
rm -rf $temp_restore_dir rm -rf $temp_restore_dir
chown -Rc debian-sks: /etc/sks/sksconf chown -Rc debian-sks: /etc/sks/sksconf
chown -Rc debian-sks: /etc/sks/mailsync chown -Rc debian-sks: /etc/sks/mailsync
@ -211,7 +215,14 @@ function restore_local_keyserver {
function_check restore_directory_from_usb function_check restore_directory_from_usb
restore_directory_from_usb $temp_restore_dir keyserver restore_directory_from_usb $temp_restore_dir keyserver
mv /var/lib/sks/DB /var/lib/sks/DB_prev mv /var/lib/sks/DB /var/lib/sks/DB_prev
if [ -d $temp_restore_dir/var/lib/sks/DB ]; then
cp -r $temp_restore_dir/var/lib/sks/DB /var/lib/sks/DB cp -r $temp_restore_dir/var/lib/sks/DB /var/lib/sks/DB
else
if [ ! -d /var/lib/sks/DB ]; then
mkdir /var/lib/sks/DB
fi
cp -r $temp_restore_dir/* /var/lib/sks/DB
fi
if [ ! "$?" = "0" ]; then if [ ! "$?" = "0" ]; then
# restore the old database # restore the old database
rm -rf /var/lib/sks/DB rm -rf /var/lib/sks/DB
@ -272,7 +283,11 @@ function restore_remote_keyserver {
temp_restore_dir=/root/tempkeyserverconfig temp_restore_dir=/root/tempkeyserverconfig
function_check restore_directory_from_friend function_check restore_directory_from_friend
restore_directory_from_friend $temp_restore_dir keyserverconfig restore_directory_from_friend $temp_restore_dir keyserverconfig
if [ -d $temp_restore_dir/etc/sks ]; then
cp -r $temp_restore_dir/etc/sks/* /etc/sks/ cp -r $temp_restore_dir/etc/sks/* /etc/sks/
else
cp -r $temp_restore_dir/* /etc/sks/
fi
rm -rf $temp_restore_dir rm -rf $temp_restore_dir
chown -Rc debian-sks: /etc/sks/sksconf chown -Rc debian-sks: /etc/sks/sksconf
chown -Rc debian-sks: /etc/sks/mailsync chown -Rc debian-sks: /etc/sks/mailsync
@ -281,7 +296,14 @@ function restore_remote_keyserver {
function_check restore_directory_from_friend function_check restore_directory_from_friend
restore_directory_from_friend $temp_restore_dir keyserver restore_directory_from_friend $temp_restore_dir keyserver
mv /var/lib/sks/DB /var/lib/sks/DB_prev mv /var/lib/sks/DB /var/lib/sks/DB_prev
if [ -d $temp_restore_dir/var/lib/sks/DB ]; then
cp -r $temp_restore_dir/var/lib/sks/DB /var/lib/sks/DB cp -r $temp_restore_dir/var/lib/sks/DB /var/lib/sks/DB
else
if [ ! -d /var/lib/sks/DB ]; then
mkdir /var/lib/sks/DB
fi
cp -r $temp_restore_dir/* /var/lib/sks/DB
fi
if [ ! "$?" = "0" ]; then if [ ! "$?" = "0" ]; then
# restore the old database # restore the old database
rm -rf /var/lib/sks/DB rm -rf /var/lib/sks/DB

View File

@ -415,7 +415,11 @@ function restore_local_matrix {
temp_restore_dir=/root/tempmatrix temp_restore_dir=/root/tempmatrix
function_check restore_directory_from_usb function_check restore_directory_from_usb
restore_directory_from_usb $temp_restore_dir matrix restore_directory_from_usb $temp_restore_dir matrix
if [ -d $temp_restore_dir/etc/matrix ]; then
cp -r $temp_restore_dir/etc/matrix/* /etc/matrix cp -r $temp_restore_dir/etc/matrix/* /etc/matrix
else
cp -r $temp_restore_dir/* /etc/matrix/
fi
if [ ! "$?" = "0" ]; then if [ ! "$?" = "0" ]; then
function_check backup_unmount_drive function_check backup_unmount_drive
backup_unmount_drive backup_unmount_drive
@ -426,7 +430,11 @@ function restore_local_matrix {
temp_restore_dir=/root/tempmatrixdata temp_restore_dir=/root/tempmatrixdata
restore_directory_from_usb $temp_restore_dir matrixdata restore_directory_from_usb $temp_restore_dir matrixdata
if [ -d $temp_restore_dir$MATRIX_DATA_DIR ]; then
cp -r $temp_restore_dir$MATRIX_DATA_DIR/* $MATRIX_DATA_DIR cp -r $temp_restore_dir$MATRIX_DATA_DIR/* $MATRIX_DATA_DIR
else
cp -r $temp_restore_dir/* $MATRIX_DATA_DIR/
fi
if [ ! "$?" = "0" ]; then if [ ! "$?" = "0" ]; then
function_check backup_unmount_drive function_check backup_unmount_drive
backup_unmount_drive backup_unmount_drive
@ -472,7 +480,11 @@ function restore_remote_matrix {
temp_restore_dir=/root/tempmatrix temp_restore_dir=/root/tempmatrix
function_check restore_directory_from_friend function_check restore_directory_from_friend
restore_directory_from_friend $temp_restore_dir matrix restore_directory_from_friend $temp_restore_dir matrix
if [ -d $temp_restore_dir/etc/matrix ]; then
cp -r $temp_restore_dir/etc/matrix/* /etc/matrix cp -r $temp_restore_dir/etc/matrix/* /etc/matrix
else
cp -r $temp_restore_dir/* /etc/matrix/
fi
if [ ! "$?" = "0" ]; then if [ ! "$?" = "0" ]; then
exit 38935 exit 38935
fi fi
@ -481,7 +493,11 @@ function restore_remote_matrix {
temp_restore_dir=/root/tempmatrixdata temp_restore_dir=/root/tempmatrixdata
restore_directory_from_friend $temp_restore_dir matrixdata restore_directory_from_friend $temp_restore_dir matrixdata
if [ -d $temp_restore_dir$MATRIX_DATA_DIR ]; then
cp -r $temp_restore_dir$MATRIX_DATA_DIR/* $MATRIX_DATA_DIR cp -r $temp_restore_dir$MATRIX_DATA_DIR/* $MATRIX_DATA_DIR
else
cp -r $temp_restore_dir/* $MATRIX_DATA_DIR/
fi
if [ ! "$?" = "0" ]; then if [ ! "$?" = "0" ]; then
exit 60923 exit 60923
fi fi

View File

@ -177,7 +177,11 @@ function restore_local_mediagoblin {
temp_restore_dir=/root/tempmediagoblin temp_restore_dir=/root/tempmediagoblin
function_check restore_directory_from_usb function_check restore_directory_from_usb
restore_directory_from_usb ${temp_restore_dir} mediagoblin restore_directory_from_usb ${temp_restore_dir} mediagoblin
if [ -d ${temp_restore_dir}$MEDIAGOBLIN_BASE_DIR ]; then
cp -r ${temp_restore_dir}$MEDIAGOBLIN_BASE_DIR/* $MEDIAGOBLIN_BASE_DIR/ cp -r ${temp_restore_dir}$MEDIAGOBLIN_BASE_DIR/* $MEDIAGOBLIN_BASE_DIR/
else
cp -r ${temp_restore_dir}/* $MEDIAGOBLIN_BASE_DIR/
fi
if [ ! "$?" = "0" ]; then if [ ! "$?" = "0" ]; then
function_check restore_directory_from_usb function_check restore_directory_from_usb
set_user_permissions set_user_permissions
@ -186,7 +190,11 @@ function restore_local_mediagoblin {
exit 45327 exit 45327
fi fi
restore_directory_from_usb ${temp_restore_dir}2 mediagoblindata restore_directory_from_usb ${temp_restore_dir}2 mediagoblindata
if [ -d ${temp_restore_dir}2/var/lib/mediagoblin ]; then
cp -r ${temp_restore_dir}2/var/lib/mediagoblin/* /var/lib/mediagoblin/ cp -r ${temp_restore_dir}2/var/lib/mediagoblin/* /var/lib/mediagoblin/
else
cp -r ${temp_restore_dir}2/* /var/lib/mediagoblin/
fi
if [ ! "$?" = "0" ]; then if [ ! "$?" = "0" ]; then
function_check set_user_permissions function_check set_user_permissions
set_user_permissions set_user_permissions
@ -214,21 +222,30 @@ function backup_remote_mediagoblin {
function restore_remote_mediagoblin { function restore_remote_mediagoblin {
MEDIAGOBLIN_BASE_DIR=/var/www/$MEDIAGOBLIN_DOMAIN_NAME/htdocs MEDIAGOBLIN_BASE_DIR=/var/www/$MEDIAGOBLIN_DOMAIN_NAME/htdocs
if [ -d $SERVER_DIRECTORY/backup/mediagoblin ]; then if [ -d $SERVER_DIRECTORY/backup/mediagoblin ]; then
temp_restore_dir=/root/tempmediagoblin
function_check get_completion_param function_check get_completion_param
MEDIAGOBLIN_DOMAIN_NAME=$(get_completion_param "mediagoblin domain") MEDIAGOBLIN_DOMAIN_NAME=$(get_completion_param "mediagoblin domain")
function_check restore_directory_from_friend function_check restore_directory_from_friend
restore_directory_from_friend /root/tempmediagoblin mediagoblin restore_directory_from_friend $temp_restore_dir mediagoblin
cp -r /root/tempmediagoblin/var/lib/mediagoblin/* /var/lib/mediagoblin/ if [ -d ${temp_restore_dir}$MEDIAGOBLIN_BASE_DIR ]; then
cp -r ${temp_restore_dir}$MEDIAGOBLIN_BASE_DIR/* $MEDIAGOBLIN_BASE_DIR/
else
cp -r ${temp_restore_dir}/* $MEDIAGOBLIN_BASE_DIR/
fi
if [ ! "$?" = "0" ]; then if [ ! "$?" = "0" ]; then
exit 264824 exit 264824
fi fi
restore_directory_from_friend /root/tempmediagoblin2 mediagoblindata restore_directory_from_friend ${temp_restore_dir}2 mediagoblindata
cp -r /root/tempmediagoblin/var/lib/mediagoblin/* /var/lib/mediagoblin/ if [ -d ${temp_restore_dir}2/var/lib/mediagoblin ]; then
cp -r ${temp_restore_dir}2/var/lib/mediagoblin/* /var/lib/mediagoblin/
else
cp -r ${temp_restore_dir}2/* /var/lib/mediagoblin/
fi
if [ ! "$?" = "0" ]; then if [ ! "$?" = "0" ]; then
exit 268492 exit 268492
fi fi
rm -rf /root/tempmediagoblin rm -rf ${temp_restore_dir}
rm -rf /root/tempmediagoblin2 rm -rf ${temp_restore_dir}2
chown -hR mediagoblin:www-data $MEDIAGOBLIN_BASE_DIR chown -hR mediagoblin:www-data $MEDIAGOBLIN_BASE_DIR
chown -hR mediagoblin:www-data /var/lib/mediagoblin chown -hR mediagoblin:www-data /var/lib/mediagoblin
chmod -R g+wx /var/lib/mediagoblin chmod -R g+wx /var/lib/mediagoblin

View File

@ -107,7 +107,11 @@ function restore_local_mumble {
function_check restore_directory_from_usb function_check restore_directory_from_usb
restore_directory_from_usb $temp_restore_dir voip restore_directory_from_usb $temp_restore_dir voip
restore_directory_from_usb $temp_restore_dir mumble restore_directory_from_usb $temp_restore_dir mumble
if [ -d $temp_restore_dir/home/$ADMIN_USERNAME/tempbackup ]; then
cp -f $temp_restore_dir/home/$ADMIN_USERNAME/tempbackup/mumble-server.ini /etc/ cp -f $temp_restore_dir/home/$ADMIN_USERNAME/tempbackup/mumble-server.ini /etc/
else
cp -f $temp_restore_dir/mumble-server.ini /etc/
fi
if [ ! "$?" = "0" ]; then if [ ! "$?" = "0" ]; then
rm -rf $temp_restore_dir rm -rf $temp_restore_dir
function_check set_user_permissions function_check set_user_permissions
@ -116,7 +120,11 @@ function restore_local_mumble {
backup_unmount_drive backup_unmount_drive
exit 3679 exit 3679
fi fi
if [ -d $temp_restore_dir/home/$ADMIN_USERNAME/tempbackup ]; then
cp -f $temp_restore_dir/home/$ADMIN_USERNAME/tempbackup/mumble-server.sqlite /var/lib/mumble-server/ cp -f $temp_restore_dir/home/$ADMIN_USERNAME/tempbackup/mumble-server.sqlite /var/lib/mumble-server/
else
cp -f $temp_restore_dir/mumble-server.sqlite /var/lib/mumble-server/
fi
if [ ! "$?" = "0" ]; then if [ ! "$?" = "0" ]; then
rm -rf $temp_restore_dir rm -rf $temp_restore_dir
function_check set_user_permissions function_check set_user_permissions
@ -152,17 +160,29 @@ function restore_remote_mumble {
temp_restore_dir=/root/tempmumble temp_restore_dir=/root/tempmumble
function_check restore_directory_from_friend function_check restore_directory_from_friend
restore_directory_from_friend $temp_restore_dir mumble restore_directory_from_friend $temp_restore_dir mumble
if [ -d $temp_restore_dir/home/$ADMIN_USERNAME/tempbackup ]; then
cp -f $temp_restore_dir/home/$ADMIN_USERNAME/tempbackup/mumble-server.ini /etc/ cp -f $temp_restore_dir/home/$ADMIN_USERNAME/tempbackup/mumble-server.ini /etc/
else
cp -f $temp_restore_dir/mumble-server.ini /etc/
fi
if [ ! "$?" = "0" ]; then if [ ! "$?" = "0" ]; then
rm -rf $temp_restore_dir rm -rf $temp_restore_dir
exit 7823 exit 7823
fi fi
if [ -d $temp_restore_dir/home/$ADMIN_USERNAME/tempbackup ]; then
cp -f $temp_restore_dir/home/$ADMIN_USERNAME/tempbackup/sipwitch.conf /etc/sipwitch.conf cp -f $temp_restore_dir/home/$ADMIN_USERNAME/tempbackup/sipwitch.conf /etc/sipwitch.conf
else
cp -f $temp_restore_dir/sipwitch.conf /etc/sipwitch.conf
fi
if [ ! "$?" = "0" ]; then if [ ! "$?" = "0" ]; then
rm -rf $temp_restore_dir rm -rf $temp_restore_dir
exit 7823 exit 7823
fi fi
if [ $temp_restore_dir/home/$ADMIN_USERNAME/tempbackup ]; then
cp -f $temp_restore_dir/home/$ADMIN_USERNAME/tempbackup/mumble-server.sqlite /var/lib/mumble-server/ cp -f $temp_restore_dir/home/$ADMIN_USERNAME/tempbackup/mumble-server.sqlite /var/lib/mumble-server/
else
cp -f $temp_restore_dir/mumble-server.sqlite /var/lib/mumble-server/
fi
if [ ! "$?" = "0" ]; then if [ ! "$?" = "0" ]; then
rm -rf $temp_restore_dir rm -rf $temp_restore_dir
exit 276 exit 276

View File

@ -254,8 +254,13 @@ function restore_local_nextcloud {
temp_restore_dir=/root/tempnextcloudfiles temp_restore_dir=/root/tempnextcloudfiles
restore_directory_from_usb $temp_restore_dir nextcloudfiles restore_directory_from_usb $temp_restore_dir nextcloudfiles
temp_source_dir=$(find ${temp_restore_dir} -name data)
cp -r ${temp_source_dir} /var/www/${NEXTCLOUD_DOMAIN_NAME}/ if [ -d $temp_restore_dir/var/www/${NEXTCLOUD_DOMAIN_NAME}/data ]; then
cp -r $temp_restore_dir/var/www/${NEXTCLOUD_DOMAIN_NAME}/data /var/www/${NEXTCLOUD_DOMAIN_NAME}/
else
cp -r $temp_restore_dir/* /var/www/${NEXTCLOUD_DOMAIN_NAME}/
fi
if [ ! "$?" = "0" ]; then if [ ! "$?" = "0" ]; then
set_user_permissions set_user_permissions
backup_unmount_drive backup_unmount_drive
@ -265,8 +270,13 @@ function restore_local_nextcloud {
temp_restore_dir=/root/tempnextcloudconfig temp_restore_dir=/root/tempnextcloudconfig
restore_directory_from_usb $temp_restore_dir nextcloudconfig restore_directory_from_usb $temp_restore_dir nextcloudconfig
temp_source_dir=$(find ${temp_restore_dir} -name config)
cp -r ${temp_source_dir} /var/www/${NEXTCLOUD_DOMAIN_NAME}/htdocs/ if [ -d $temp_restore_dir/var/www/${NEXTCLOUD_DOMAIN_NAME}/htdocs/config ]; then
cp -r $temp_restore_dir/var/www/${NEXTCLOUD_DOMAIN_NAME}/htdocs/config /var/www/${NEXTCLOUD_DOMAIN_NAME}/htdocs
else
cp -r $temp_restore_dir/* /var/www/${NEXTCLOUD_DOMAIN_NAME}/htdocs/config/
fi
if [ ! "$?" = "0" ]; then if [ ! "$?" = "0" ]; then
set_user_permissions set_user_permissions
backup_unmount_drive backup_unmount_drive
@ -324,8 +334,13 @@ function restore_remote_nextcloud {
temp_restore_dir=/root/tempnextcloudfiles temp_restore_dir=/root/tempnextcloudfiles
restore_directory_from_friend $temp_restore_dir nextcloudfiles restore_directory_from_friend $temp_restore_dir nextcloudfiles
temp_source_dir=$(find ${temp_restore_dir} -name data)
cp -r ${temp_source_dir} /var/www/${NEXTCLOUD_DOMAIN_NAME}/ if [ -d $temp_restore_dir/var/www/${NEXTCLOUD_DOMAIN_NAME}/data ]; then
cp -r $temp_restore_dir/var/www/${NEXTCLOUD_DOMAIN_NAME}/data /var/www/${NEXTCLOUD_DOMAIN_NAME}/
else
cp -r $temp_restore_dir/* /var/www/${NEXTCLOUD_DOMAIN_NAME}/
fi
if [ ! "$?" = "0" ]; then if [ ! "$?" = "0" ]; then
exit 768254 exit 768254
fi fi
@ -333,8 +348,13 @@ function restore_remote_nextcloud {
temp_restore_dir=/root/tempnextcloudconfig temp_restore_dir=/root/tempnextcloudconfig
restore_directory_from_friend $temp_restore_dir nextcloudconfig restore_directory_from_friend $temp_restore_dir nextcloudconfig
temp_source_dir=$(find ${temp_restore_dir} -name config)
cp -r ${temp_source_dir} /var/www/${NEXTCLOUD_DOMAIN_NAME}/htdocs/ if [ -d $temp_restore_dir/var/www/${NEXTCLOUD_DOMAIN_NAME}/htdocs/config ]; then
cp -r $temp_restore_dir/var/www/${NEXTCLOUD_DOMAIN_NAME}/htdocs/config /var/www/${NEXTCLOUD_DOMAIN_NAME}/htdocs
else
cp -r $temp_restore_dir/* /var/www/${NEXTCLOUD_DOMAIN_NAME}/htdocs/config/
fi
if [ ! "$?" = "0" ]; then if [ ! "$?" = "0" ]; then
exit 573427 exit 573427
fi fi

View File

@ -449,7 +449,11 @@ function restore_local_pelican {
temp_restore_dir=/root/temppelican temp_restore_dir=/root/temppelican
function_check restore_directory_from_usb function_check restore_directory_from_usb
restore_directory_from_usb $temp_restore_dir pelican restore_directory_from_usb $temp_restore_dir pelican
if [ -d $temp_restore_dir/etc/blog ]; then
cp -r $temp_restore_dir/etc/blog/* /etc/blog/ cp -r $temp_restore_dir/etc/blog/* /etc/blog/
else
cp -r $temp_restore_dir/* /etc/blog/
fi
if [ ! "$?" = "0" ]; then if [ ! "$?" = "0" ]; then
rm -rf $temp_restore_dir rm -rf $temp_restore_dir
function_check set_user_permissions function_check set_user_permissions
@ -466,7 +470,11 @@ function restore_local_pelican {
temp_restore_dir=/root/temppelican-site temp_restore_dir=/root/temppelican-site
function_check restore_directory_from_usb function_check restore_directory_from_usb
restore_directory_from_usb $temp_restore_dir pelican-site restore_directory_from_usb $temp_restore_dir pelican-site
if [ -d $temp_restore_dir/var/www/$PELICAN_DOMAIN_NAME/htdocs ]; then
cp -r $temp_restore_dir/var/www/$PELICAN_DOMAIN_NAME/htdocs/* /var/www/$PELICAN_DOMAIN_NAME/htdocs/ cp -r $temp_restore_dir/var/www/$PELICAN_DOMAIN_NAME/htdocs/* /var/www/$PELICAN_DOMAIN_NAME/htdocs/
else
cp -r $temp_restore_dir/* /var/www/$PELICAN_DOMAIN_NAME/htdocs/
fi
if [ ! "$?" = "0" ]; then if [ ! "$?" = "0" ]; then
rm -rf $temp_restore_dir rm -rf $temp_restore_dir
function_check set_user_permissions function_check set_user_permissions
@ -495,7 +503,11 @@ function restore_remote_pelican {
temp_restore_dir=/root/temppelican temp_restore_dir=/root/temppelican
function_check restore_directory_from_friend function_check restore_directory_from_friend
restore_directory_from_friend $temp_restore_dir pelican restore_directory_from_friend $temp_restore_dir pelican
if [ -d $temp_restore_dir/etc/blog ]; then
cp -r $temp_restore_dir/etc/blog/* /etc/blog/ cp -r $temp_restore_dir/etc/blog/* /etc/blog/
else
cp -r $temp_restore_dir/* /etc/blog/
fi
if [ ! "$?" = "0" ]; then if [ ! "$?" = "0" ]; then
exit 782352 exit 782352
fi fi
@ -507,7 +519,11 @@ function restore_remote_pelican {
temp_restore_dir=/root/temppelican-site temp_restore_dir=/root/temppelican-site
function_check restore_directory_from_friend function_check restore_directory_from_friend
restore_directory_from_friend $temp_restore_dir pelican-site restore_directory_from_friend $temp_restore_dir pelican-site
if [ -d $temp_restore_dir/var/www/$PELICAN_DOMAIN_NAME/htdocs ]; then
cp -r $temp_restore_dir/var/www/$PELICAN_DOMAIN_NAME/htdocs/* /var/www/$PELICAN_DOMAIN_NAME/htdocs/ cp -r $temp_restore_dir/var/www/$PELICAN_DOMAIN_NAME/htdocs/* /var/www/$PELICAN_DOMAIN_NAME/htdocs/
else
cp -r $temp_restore_dir/* /var/www/$PELICAN_DOMAIN_NAME/htdocs/
fi
if [ ! "$?" = "0" ]; then if [ ! "$?" = "0" ]; then
exit 76382562 exit 76382562
fi fi

View File

@ -446,16 +446,31 @@ function restore_local_postactiv {
function_check restore_directory_from_usb function_check restore_directory_from_usb
restore_directory_from_usb $temp_restore_dir postactivconfig restore_directory_from_usb $temp_restore_dir postactivconfig
if [ -d $temp_restore_dir ]; then if [ -d $temp_restore_dir ]; then
if [ -d $temp_restore_dir$postactiv_dir ]; then
cp $temp_restore_dir$postactiv_dir/backup/config.php $postactiv_dir/ cp $temp_restore_dir$postactiv_dir/backup/config.php $postactiv_dir/
chown www-data:www-data $postactiv_dir/config.php
cp -rp $temp_restore_dir$postactiv_dir/static $postactiv_dir/ cp -rp $temp_restore_dir$postactiv_dir/static $postactiv_dir/
else
cp $temp_restore_dir/backup/config.php $postactiv_dir/
if [ ! -d $postactiv_dir/static ]; then
mkdir $postactiv_dir/static
fi
cp -rp $temp_restore_dir/static/* $postactiv_dir/static/
fi
chown www-data:www-data $postactiv_dir/config.php
chown -R www-data:www-data $postactiv_dir/static chown -R www-data:www-data $postactiv_dir/static
rm -rf $temp_restore_dir rm -rf $temp_restore_dir
fi fi
restore_directory_from_usb $temp_restore_dir postactivfile restore_directory_from_usb $temp_restore_dir postactivfile
if [ -d $temp_restore_dir ]; then if [ -d $temp_restore_dir ]; then
if [ -d $temp_restore_dir$postactiv_dir/file ]; then
cp -rp $temp_restore_dir$postactiv_dir/file $postactiv_dir/ cp -rp $temp_restore_dir$postactiv_dir/file $postactiv_dir/
else
if [ ! -d $postactiv_dir/file ]; then
mkdir $postactiv_dir/file
fi
cp -rp $temp_restore_dir/* $postactiv_dir/file/
fi
chown -R www-data:www-data $postactiv_dir/file chown -R www-data:www-data $postactiv_dir/file
rm -rf $temp_restore_dir rm -rf $temp_restore_dir
fi fi
@ -527,16 +542,31 @@ function restore_remote_postactiv {
function_check restore_directory_from_friend function_check restore_directory_from_friend
restore_directory_from_friend $temp_restore_dir postactivconfig restore_directory_from_friend $temp_restore_dir postactivconfig
if [ -d $temp_restore_dir ]; then if [ -d $temp_restore_dir ]; then
if [ -d $temp_restore_dir$postactiv_dir ]; then
cp $temp_restore_dir$postactiv_dir/backup/config.php $postactiv_dir/ cp $temp_restore_dir$postactiv_dir/backup/config.php $postactiv_dir/
chown www-data:www-data $postactiv_dir/config.php
cp -rp $temp_restore_dir$postactiv_dir/static $postactiv_dir/ cp -rp $temp_restore_dir$postactiv_dir/static $postactiv_dir/
else
cp $temp_restore_dir/config.php $postactiv_dir/
if [ ! -d $postactiv_dir/static ]; then
mkdir $postactiv_dir/static
fi
cp -rp $temp_restore_dir/static/* $postactiv_dir/static/
fi
chown www-data:www-data $postactiv_dir/config.php
chown -R www-data:www-data $postactiv_dir/static chown -R www-data:www-data $postactiv_dir/static
rm -rf $temp_restore_dir rm -rf $temp_restore_dir
fi fi
restore_directory_from_friend $temp_restore_dir postactivfile restore_directory_from_friend $temp_restore_dir postactivfile
if [ -d $temp_restore_dir ]; then if [ -d $temp_restore_dir ]; then
if [ -d $temp_restore_dir$postactiv_dir/file ]; then
cp -rp $temp_restore_dir$postactiv_dir/file $postactiv_dir/ cp -rp $temp_restore_dir$postactiv_dir/file $postactiv_dir/
else
if [ ! -d $postactiv_dir/file ]; then
mkdir $postactiv_dir/file
fi
cp -rp $temp_restore_dir/* $postactiv_dir/file/
fi
chown -R www-data:www-data $postactiv_dir/file chown -R www-data:www-data $postactiv_dir/file
rm -rf $temp_restore_dir rm -rf $temp_restore_dir
fi fi

View File

@ -214,7 +214,11 @@ function restore_local_radicale {
temp_restore_dir=/root/tempradicale temp_restore_dir=/root/tempradicale
function_check restore_directory_from_usb function_check restore_directory_from_usb
restore_directory_from_usb $temp_restore_dir radicale restore_directory_from_usb $temp_restore_dir radicale
if [ -d $temp_restore_dir${RADICALE_DIRECTORY} ]; then
cp -r $temp_restore_dir${RADICALE_DIRECTORY}/* ${RADICALE_DIRECTORY} cp -r $temp_restore_dir${RADICALE_DIRECTORY}/* ${RADICALE_DIRECTORY}
else
cp -r $temp_restore_dir/* ${RADICALE_DIRECTORY}/
fi
if [ ! "$?" = "0" ]; then if [ ! "$?" = "0" ]; then
function_check backup_unmount_drive function_check backup_unmount_drive
backup_unmount_drive backup_unmount_drive
@ -224,7 +228,11 @@ function restore_local_radicale {
temp_restore_dir=/root/tempradicalewww temp_restore_dir=/root/tempradicalewww
restore_directory_from_usb $temp_restore_dir radicalewww restore_directory_from_usb $temp_restore_dir radicalewww
if [ -d $temp_restore_dir/var/www/radicale ]; then
cp -r $temp_restore_dir/var/www/radicale/* /var/www/radicale cp -r $temp_restore_dir/var/www/radicale/* /var/www/radicale
else
cp -r $temp_restore_dir/* /var/www/radicale/*
fi
if [ ! "$?" = "0" ]; then if [ ! "$?" = "0" ]; then
function_check backup_unmount_drive function_check backup_unmount_drive
backup_unmount_drive backup_unmount_drive
@ -251,7 +259,11 @@ function restore_remote_radicale {
temp_restore_dir=/root/tempradicale temp_restore_dir=/root/tempradicale
function_check restore_directory_from_friend function_check restore_directory_from_friend
restore_directory_from_friend $temp_restore_dir radicale restore_directory_from_friend $temp_restore_dir radicale
if [ -d $temp_restore_dir${RADICALE_DIRECTORY} ]; then
cp -r $temp_restore_dir${RADICALE_DIRECTORY}/* ${RADICALE_DIRECTORY} cp -r $temp_restore_dir${RADICALE_DIRECTORY}/* ${RADICALE_DIRECTORY}
else
cp -r $temp_restore_dir/* ${RADICALE_DIRECTORY}/
fi
if [ ! "$?" = "0" ]; then if [ ! "$?" = "0" ]; then
exit 236746 exit 236746
fi fi
@ -259,7 +271,11 @@ function restore_remote_radicale {
temp_restore_dir=/root/tempradicalewww temp_restore_dir=/root/tempradicalewww
restore_directory_from_friend $temp_restore_dir radicalewww restore_directory_from_friend $temp_restore_dir radicalewww
if [ -d $temp_restore_dir/var/www/radicale ]; then
cp -r $temp_restore_dir/var/www/radicale/* /var/www/radicale cp -r $temp_restore_dir/var/www/radicale/* /var/www/radicale
else
cp -r $temp_restore_dir/* /var/www/radicale
fi
if [ ! "$?" = "0" ]; then if [ ! "$?" = "0" ]; then
exit 3674284 exit 3674284
fi fi

View File

@ -171,9 +171,13 @@ function restore_local_rss {
restore_database ttrss ${RSS_READER_DOMAIN_NAME} restore_database ttrss ${RSS_READER_DOMAIN_NAME}
if [ -d /etc/share/tt-rss ]; then if [ -d /etc/share/tt-rss ]; then
if [ -d /root/tempttrss/etc/share/tt-rss ]; then if [ -d $temp_restore_dir/etc/share/tt-rss ]; then
if [ -d $temp_restore_dir/etc/share/tt-rss ]; then
rm -rf /etc/share/tt-rss rm -rf /etc/share/tt-rss
mv /root/tempttrss/etc/share/tt-rss /etc/share/ mv $temp_restore_dir/etc/share/tt-rss /etc/share/
else
cp -r $temp_restore_dir/* /etc/share/tt-rss/
fi
if [ ! "$?" = "0" ]; then if [ ! "$?" = "0" ]; then
function_check set_user_permissions function_check set_user_permissions
set_user_permissions set_user_permissions
@ -230,6 +234,7 @@ function backup_remote_rss {
} }
function restore_remote_rss { function restore_remote_rss {
temp_restore_dir=/root/tempttrss
if grep -q "rss reader domain" $COMPLETION_FILE; then if grep -q "rss reader domain" $COMPLETION_FILE; then
echo $"Restoring ttrss" echo $"Restoring ttrss"
function_check restore_database_from_friend function_check restore_database_from_friend
@ -240,8 +245,12 @@ function restore_remote_rss {
restore_database_from_friend ttrss ${RSS_READER_DOMAIN_NAME} restore_database_from_friend ttrss ${RSS_READER_DOMAIN_NAME}
if [ -d /etc/share/tt-rss ]; then if [ -d /etc/share/tt-rss ]; then
if [ -d $temp_restore_dir/etc/share/tt-rss ]; then
rm -rf /etc/share/tt-rss rm -rf /etc/share/tt-rss
mv /root/tempttrss/etc/share/tt-rss /etc/share/ mv $temp_restore_dir/etc/share/tt-rss /etc/share/
else
cp -r $temp_restore_dir/* /etc/share/tt-rss/
fi
if [ ! "$?" = "0" ]; then if [ ! "$?" = "0" ]; then
exit 6391 exit 6391
fi fi

View File

@ -144,8 +144,13 @@ function restore_local_scuttlebot {
temp_restore_dir=/root/tempscuttlebot temp_restore_dir=/root/tempscuttlebot
function_check restore_directory_from_usb function_check restore_directory_from_usb
restore_directory_from_usb $temp_restore_dir scuttlebot restore_directory_from_usb $temp_restore_dir scuttlebot
if [ -d $temp_restore_dir/etc/scuttlebot/.ssb ]; then
cp -r $temp_restore_dir/etc/scuttlebot/.ssb /etc/scuttlebot/ cp -r $temp_restore_dir/etc/scuttlebot/.ssb /etc/scuttlebot/
else
cp -r $temp_restore_dir/* /etc/scuttlebot/.ssb/*
fi
systemctl start scuttlebot systemctl start scuttlebot
rm -rf $temp_restore_dir
fi fi
} }
@ -164,8 +169,13 @@ function restore_remote_scuttlebot {
temp_restore_dir=/root/tempscuttlebot temp_restore_dir=/root/tempscuttlebot
function_check restore_directory_from_friend function_check restore_directory_from_friend
restore_directory_from_friend $temp_restore_dir scuttlebot restore_directory_from_friend $temp_restore_dir scuttlebot
if [ -d $temp_restore_dir/etc/scuttlebot/.ssb ]; then
cp -r $temp_restore_dir/etc/scuttlebot/.ssb /etc/scuttlebot/ cp -r $temp_restore_dir/etc/scuttlebot/.ssb /etc/scuttlebot/
else
cp -r $temp_restore_dir/* /etc/scuttlebot/.ssb/*
fi
systemctl start scuttlebot systemctl start scuttlebot
rm -rf $temp_restore_dir
fi fi
} }

View File

@ -145,7 +145,11 @@ function restore_local_sip {
temp_restore_dir=/root/tempsip temp_restore_dir=/root/tempsip
function_check restore_directory_from_usb function_check restore_directory_from_usb
restore_directory_from_usb $temp_restore_dir sip restore_directory_from_usb $temp_restore_dir sip
if [ -d $temp_restore_dir/home/$ADMIN_USERNAME/tempbackup ]; then
cp -f $temp_restore_dir/home/$ADMIN_USERNAME/tempbackup/sipwitch.conf /etc/sipwitch.conf cp -f $temp_restore_dir/home/$ADMIN_USERNAME/tempbackup/sipwitch.conf /etc/sipwitch.conf
else
cp -f $temp_restore_dir/sipwitch.conf /etc/sipwitch.conf
fi
if [ ! "$?" = "0" ]; then if [ ! "$?" = "0" ]; then
rm -rf $temp_restore_dir rm -rf $temp_restore_dir
function_check set_user_permissions function_check set_user_permissions
@ -173,7 +177,23 @@ function backup_remote_sip {
} }
function restore_remote_sip { function restore_remote_sip {
echo -n '' temp_restore_dir=/root/tempsip
function_check restore_directory_from_friend
restore_directory_from_friend $temp_restore_dir sip
if [ -d $temp_restore_dir/home/$ADMIN_USERNAME/tempbackup ]; then
cp -f $temp_restore_dir/home/$ADMIN_USERNAME/tempbackup/sipwitch.conf /etc/sipwitch.conf
else
cp -f $temp_restore_dir/sipwitch.conf /etc/sipwitch.conf
fi
if [ ! "$?" = "0" ]; then
rm -rf $temp_restore_dir
function_check set_user_permissions
set_user_permissions
backup_unmount_drive
exit 3679
fi
rm -rf $temp_restore_dir
systemctl restart sipwitch
} }
function remove_sip { function remove_sip {

View File

@ -286,7 +286,13 @@ function restore_local_syncthing {
echo $"Restoring syncthing configuration" echo $"Restoring syncthing configuration"
function_check restore_directory_from_usb function_check restore_directory_from_usb
restore_directory_from_usb ${temp_restore_dir}config syncthingconfig restore_directory_from_usb ${temp_restore_dir}config syncthingconfig
cp -r ${temp_restore_dir}config/* / #cp -r ${temp_restore_dir}config/* /
if [ ! -d /root/.config/syncthing ]; then
mkdir -p /root/.config/syncthing
fi
cp -r ${temp_restore_dir}config/* /root/.config/syncthing/
if [ ! "$?" = "0" ]; then if [ ! "$?" = "0" ]; then
set_user_permissions set_user_permissions
backup_unmount_drive backup_unmount_drive
@ -300,7 +306,13 @@ function restore_local_syncthing {
if [ -d $USB_MOUNT/backup/syncthingshared ]; then if [ -d $USB_MOUNT/backup/syncthingshared ]; then
echo $"Restoring syncthing shared files" echo $"Restoring syncthing shared files"
restore_directory_from_usb ${temp_restore_dir}shared syncthingshared restore_directory_from_usb ${temp_restore_dir}shared syncthingshared
cp -r ${temp_restore_dir}shared/* / #cp -r ${temp_restore_dir}shared/* /
if [ ! -d /var/lib/syncthing/SyncShared ]; then
mkdir -p /var/lib/syncthing/SyncShared
fi
cp -r ${temp_restore_dir}shared/* /var/lib/syncthing/SyncShared/
if [ ! "$?" = "0" ]; then if [ ! "$?" = "0" ]; then
set_user_permissions set_user_permissions
backup_unmount_drive backup_unmount_drive
@ -320,7 +332,11 @@ function restore_local_syncthing {
fi fi
echo $"Restoring syncthing files for $USERNAME" echo $"Restoring syncthing files for $USERNAME"
restore_directory_from_usb ${temp_restore_dir} syncthing/$USERNAME restore_directory_from_usb ${temp_restore_dir} syncthing/$USERNAME
if [ -d ${temp_restore_dir}/home/$USERNAME/Sync ]; then
cp -r ${temp_restore_dir}/home/$USERNAME/Sync /home/$USERNAME/ cp -r ${temp_restore_dir}/home/$USERNAME/Sync /home/$USERNAME/
else
cp -r ${temp_restore_dir}/* /home/$USERNAME/Sync/
fi
if [ ! "$?" = "0" ]; then if [ ! "$?" = "0" ]; then
rm -rf ${temp_restore_dir} rm -rf ${temp_restore_dir}
set_user_permissions set_user_permissions
@ -399,7 +415,11 @@ function restore_remote_syncthing {
temp_restore_dir=/root/tempsyncthingconfig temp_restore_dir=/root/tempsyncthingconfig
function_check restore_directory_from_friend function_check restore_directory_from_friend
restore_directory_from_friend $temp_restore_dir syncthingconfig restore_directory_from_friend $temp_restore_dir syncthingconfig
cp -r $temp_restore_dir/* / #cp -r $temp_restore_dir/* /
if [ ! -d /root/.config/syncthing ]; then
mkdir -p /root/.config/syncthing
fi
cp -r ${temp_restore_dir}config/* /root/.config/syncthing/
if [ ! "$?" = "0" ]; then if [ ! "$?" = "0" ]; then
systemctl start syncthing systemctl start syncthing
systemctl start cron systemctl start cron
@ -413,7 +433,11 @@ function restore_remote_syncthing {
temp_restore_dir=/root/tempsyncthingshared temp_restore_dir=/root/tempsyncthingshared
function_check restore_directory_from_friend function_check restore_directory_from_friend
restore_directory_from_friend $temp_restore_dir syncthingshared restore_directory_from_friend $temp_restore_dir syncthingshared
cp -r $temp_restore_dir/* / #cp -r $temp_restore_dir/* /
if [ ! -d /var/lib/syncthing/SyncShared ]; then
mkdir -p /var/lib/syncthing/SyncShared
fi
cp -r ${temp_restore_dir}shared/* /var/lib/syncthing/SyncShared/
if [ ! "$?" = "0" ]; then if [ ! "$?" = "0" ]; then
systemctl start syncthing systemctl start syncthing
systemctl start cron systemctl start cron
@ -433,7 +457,11 @@ function restore_remote_syncthing {
temp_restore_dir=/root/tempsyncthing temp_restore_dir=/root/tempsyncthing
function_check restore_directory_from_friend function_check restore_directory_from_friend
restore_directory_from_friend $temp_restore_dir syncthing/$USERNAME restore_directory_from_friend $temp_restore_dir syncthing/$USERNAME
if [ -d $temp_restore_dir/home/$USERNAME/Sync ]; then
cp -r $temp_restore_dir/home/$USERNAME/Sync /home/$USERNAME/ cp -r $temp_restore_dir/home/$USERNAME/Sync /home/$USERNAME/
else
cp -r $temp_restore_dir/* /home/$USERNAME/Sync/
fi
if [ ! "$?" = "0" ]; then if [ ! "$?" = "0" ]; then
rm -rf $temp_restore_dir rm -rf $temp_restore_dir
systemctl start syncthing systemctl start syncthing

View File

@ -298,13 +298,22 @@ function restore_local_tahoelafs {
systemctl stop tahoelafs-client systemctl stop tahoelafs-client
temp_restore_dir=/root/temptahoelafs temp_restore_dir=/root/temptahoelafs
restore_directory_from_usb $temp_restore_dir tahoelafs restore_directory_from_usb $temp_restore_dir tahoelafs
if [ -d $temp_restore_dir$TAHOE_DIR ]; then
mv $TAHOE_DIR ${TAHOE_DIR}-old mv $TAHOE_DIR ${TAHOE_DIR}-old
cp -r $temp_restore_dir$TAHOE_DIR $TAHOE_DIR cp -r $temp_restore_dir$TAHOE_DIR $TAHOE_DIR
else
cp -r $temp_restore_dir/* $TAHOE_DIR/
fi
if [ ! "$?" = "0" ]; then if [ ! "$?" = "0" ]; then
if [ -d ${TAHOE_DIR}-old ]; then
mv ${TAHOE_DIR}-old $TAHOE_DIR mv ${TAHOE_DIR}-old $TAHOE_DIR
fi
exit 246833 exit 246833
fi fi
if [ -d ${TAHOE_DIR}-old ]; then
rm -rf ${TAHOE_DIR}-old rm -rf ${TAHOE_DIR}-old
fi
rm -rf $temp_restore_dir
chown -R tahoelafs:debian-tor $TAHOE_DIR chown -R tahoelafs:debian-tor $TAHOE_DIR
systemctl start tahoelafs-client systemctl start tahoelafs-client
systemctl start tahoelafs-storage systemctl start tahoelafs-storage
@ -331,13 +340,22 @@ function restore_remote_tahoelafs {
systemctl stop tahoelafs-client systemctl stop tahoelafs-client
temp_restore_dir=/root/temptahoelafs temp_restore_dir=/root/temptahoelafs
restore_directory_from_friend $temp_restore_dir tahoelafs restore_directory_from_friend $temp_restore_dir tahoelafs
if [ -d $temp_restore_dir$TAHOE_DIR ]; then
mv $TAHOE_DIR ${TAHOE_DIR}-old mv $TAHOE_DIR ${TAHOE_DIR}-old
cp -r $temp_restore_dir$TAHOE_DIR $TAHOE_DIR cp -r $temp_restore_dir$TAHOE_DIR $TAHOE_DIR
else
cp -r $temp_restore_dir/* $TAHOE_DIR/
fi
if [ ! "$?" = "0" ]; then if [ ! "$?" = "0" ]; then
mv ${TAHOE_DIR}old $TAHOE_DIR if [ -d ${$TAHOE_DIR}-old ]; then
mv ${TAHOE_DIR}-old $TAHOE_DIR
fi
exit 623925 exit 623925
fi fi
if [ -d ${$TAHOE_DIR}-old ]; then
rm -rf ${$TAHOE_DIR}-old rm -rf ${$TAHOE_DIR}-old
fi
rm -rf $temp_restore_dir
chown -R tahoelafs:debian-tor $TAHOE_DIR chown -R tahoelafs:debian-tor $TAHOE_DIR
systemctl start tahoelafs-client systemctl start tahoelafs-client
systemctl start tahoelafs-storage systemctl start tahoelafs-storage

View File

@ -213,7 +213,8 @@ function restore_local_tox {
if [ -d $USB_MOUNT/backup/tox ]; then if [ -d $USB_MOUNT/backup/tox ]; then
echo $"Restoring Tox node settings" echo $"Restoring Tox node settings"
function_check restore_directory_from_usb function_check restore_directory_from_usb
restore_directory_from_usb / tox #restore_directory_from_usb / tox
restore_directory_from_usb /var/lib/tox-bootstrapd tox
if [ ! "$?" = "0" ]; then if [ ! "$?" = "0" ]; then
function_check set_user_permissions function_check set_user_permissions
set_user_permissions set_user_permissions
@ -250,7 +251,8 @@ function restore_remote_tox {
if [ -d $SERVER_DIRECTORY/backup/tox ]; then if [ -d $SERVER_DIRECTORY/backup/tox ]; then
echo $"Restoring Tox node settings" echo $"Restoring Tox node settings"
function_check restore_directory_from_friend function_check restore_directory_from_friend
restore_directory_from_friend / tox #restore_directory_from_friend / tox
restore_directory_from_friend /var/lib/tox-bootstrapd tox
if [ ! "$?" = "0" ]; then if [ ! "$?" = "0" ]; then
exit 93653 exit 93653
fi fi

View File

@ -249,18 +249,14 @@ function restore_local_turtl {
if [ $TURTL_DOMAIN_NAME ]; then if [ $TURTL_DOMAIN_NAME ]; then
temp_restore_dir=/root/tempturtl temp_restore_dir=/root/tempturtl
restore_directory_from_usb $temp_restore_dir turtl restore_directory_from_usb $temp_restore_dir turtl
if [ -d $TURTL_BASE_DIR ]; then
if [ -d /etc/turtl_previous ]; then if [ -d ${temp_restore_dir}/etc/turtl ]; then
rm -rf /etc/turtl_previous cp -r ${temp_restore_dir}/etc/turtl/* /etc/turtl/
else
cp -r ${temp_restore_dir}/* /etc/turtl/
fi fi
mv $TURTL_BASE_DIR /etc/turtl_previous
fi
temp_source_dir=$(find ${temp_restore_dir} -name turtl)
cp -r ${temp_source_dir} /etc/
if [ ! "$?" = "0" ]; then if [ ! "$?" = "0" ]; then
if [ -d /etc/turtl_previous ]; then
mv /etc/turtl_previous $TURTL_BASE_DIR
fi
set_user_permissions set_user_permissions
backup_unmount_drive backup_unmount_drive
exit 36723 exit 36723
@ -270,18 +266,14 @@ function restore_local_turtl {
temp_restore_dir=/root/temprethinkdb temp_restore_dir=/root/temprethinkdb
restore_directory_from_usb $temp_restore_dir rethinkdb restore_directory_from_usb $temp_restore_dir rethinkdb
if [ -d /var/lib/rethinkdb ]; then
if [ -d /var/lib/previous_rethinkdb ]; then if [ -d ${temp_restore_dir}/var/lib/rethinkdb ]; then
rm -rf /var/lib/previous_rethinkdb cp -r ${temp_restore_dir}/var/lib/rethinkdb/* /var/lib/rethinkdb/
else
cp -r ${temp_restore_dir}/* /var/lib/rethinkdb/
fi fi
mv /var/lib/rethinkdb /var/lib/previous_rethinkdb
fi
temp_source_dir=$(find ${temp_restore_dir} -name rethinkdb)
cp -r ${temp_source_dir} /var/lib/
if [ ! "$?" = "0" ]; then if [ ! "$?" = "0" ]; then
if [ -d /var/lib/previous_rethinkdb ]; then
mv /var/lib/previous_rethinkdb /var/lib/rethinkdb
fi
set_user_permissions set_user_permissions
backup_unmount_drive backup_unmount_drive
exit 378324 exit 378324
@ -319,18 +311,18 @@ function restore_remote_turtl {
mkdir $temp_restore_dir mkdir $temp_restore_dir
function_check restore_directory_from_friend function_check restore_directory_from_friend
restore_directory_from_friend $temp_restore_dir turtl restore_directory_from_friend $temp_restore_dir turtl
if [ -d $TURTL_BASE_DIR ]; then
if [ -d /etc/turtl_previous ]; then if [ -d ${temp_restore_dir}/etc/turtl ]; then
rm -rf /etc/turtl_previous cp -r ${temp_restore_dir}/etc/turtl/* /etc/turtl/
else
cp -r ${temp_restore_dir}/* /etc/turtl/
fi fi
mv $TURTL_BASE_DIR /etc/turtl_previous
fi
temp_source_dir=$(find ${temp_restore_dir} -name turtl)
cp -r ${temp_source_dir} /etc/
if [ ! "$?" = "0" ]; then if [ ! "$?" = "0" ]; then
if [ -d /etc/turtl_previous ]; then if [ -d /etc/turtl_previous ]; then
mv /etc/turtl_previous $TURTL_BASE_DIR mv /etc/turtl_previous $TURTL_BASE_DIR
fi fi
set_user_permissions
exit 37823 exit 37823
fi fi
rm -rf ${temp_restore_dir} rm -rf ${temp_restore_dir}
@ -339,18 +331,15 @@ function restore_remote_turtl {
mkdir $temp_restore_dir mkdir $temp_restore_dir
function_check restore_directory_from_friend function_check restore_directory_from_friend
restore_directory_from_friend $temp_restore_dir rethinkdb restore_directory_from_friend $temp_restore_dir rethinkdb
if [ -d /var/lib/rethinkdb ]; then
if [ -d /var/lib/previous_rethinkdb ]; then if [ -d ${temp_restore_dir}/var/lib/rethinkdb ]; then
rm -rf /var/lib/previous_rethinkdb cp -r ${temp_restore_dir}/var/lib/rethinkdb/* /var/lib/rethinkdb/
else
cp -r ${temp_restore_dir}/* /var/lib/rethinkdb/
fi fi
mv /var/lib/rethinkdb /var/lib/previous_rethinkdb
fi
temp_source_dir=$(find ${temp_restore_dir} -name rethinkdb)
cp -r ${temp_source_dir} /var/lib/
if [ ! "$?" = "0" ]; then if [ ! "$?" = "0" ]; then
if [ -d /var/lib/previous_rethinkdb ]; then set_user_permissions
mv /var/lib/previous_rethinkdb /var/lib/rethinkdb
fi
exit 26783 exit 26783
fi fi
rm -rf ${temp_restore_dir} rm -rf ${temp_restore_dir}

View File

@ -100,7 +100,14 @@ function restore_local_vim {
echo $"Restoring Vim config for $USERNAME" echo $"Restoring Vim config for $USERNAME"
function_check restore_directory_from_usb function_check restore_directory_from_usb
restore_directory_from_usb $temp_restore_dir vim/$USERNAME restore_directory_from_usb $temp_restore_dir vim/$USERNAME
if [ -d $temp_restore_dir/home/$USERNAME/$VIM_TEMP_DIR ]; then
cp -r $temp_restore_dir/home/$USERNAME/$VIM_TEMP_DIR /home/$USERNAME/ cp -r $temp_restore_dir/home/$USERNAME/$VIM_TEMP_DIR /home/$USERNAME/
else
if [ ! -d /home/$USERNAME/$VIM_TEMP_DIR ]; then
mkdir /home/$USERNAME/$VIM_TEMP_DIR
fi
cp -r $temp_restore_dir/* /home/$USERNAME/$VIM_TEMP_DIR/
fi
if [ ! "$?" = "0" ]; then if [ ! "$?" = "0" ]; then
rm -rf $temp_restore_dir rm -rf $temp_restore_dir
function_check set_user_permissions function_check set_user_permissions
@ -168,7 +175,14 @@ function restore_remote_vim {
echo $"Restoring Vim config for $USERNAME" echo $"Restoring Vim config for $USERNAME"
function_check restore_directory_from_friend function_check restore_directory_from_friend
restore_directory_from_friend $temp_restore_dir vim/$USERNAME restore_directory_from_friend $temp_restore_dir vim/$USERNAME
if [ -d $temp_restore_dir/home/$USERNAME/$VIM_TEMP_DIR ]; then
cp -r $temp_restore_dir/home/$USERNAME/$VIM_TEMP_DIR /home/$USERNAME/ cp -r $temp_restore_dir/home/$USERNAME/$VIM_TEMP_DIR /home/$USERNAME/
else
if [ ! -d /home/$USERNAME/$VIM_TEMP_DIR ]; then
mkdir /home/$USERNAME/$VIM_TEMP_DIR
fi
cp -r $temp_restore_dir/* /home/$USERNAME/$VIM_TEMP_DIR/
fi
if [ ! "$?" = "0" ]; then if [ ! "$?" = "0" ]; then
rm -rf $temp_restore_dir rm -rf $temp_restore_dir
function_check set_user_permissions function_check set_user_permissions

View File

@ -134,8 +134,12 @@ function restore_local_wekan {
temp_restore_dir=/root/tempwekan temp_restore_dir=/root/tempwekan
function_check restore_directory_from_usb function_check restore_directory_from_usb
restore_directory_from_usb $temp_restore_dir wekan restore_directory_from_usb $temp_restore_dir wekan
if [ -d $temp_restore_dir$WEKAN_DIR/data ]; then
cp -r $temp_restore_dir$WEKAN_DIR/data/* $WEKAN_DIR/data/ cp -r $temp_restore_dir$WEKAN_DIR/data/* $WEKAN_DIR/data/
else
cp -r $temp_restore_dir/* $WEKAN_DIR/data/
fi
rm -rf $temp_restore_dir
systemctl start wekan systemctl start wekan
fi fi
} }
@ -177,8 +181,12 @@ function restore_remote_wekan {
temp_restore_dir=/root/tempwekan temp_restore_dir=/root/tempwekan
function_check restore_directory_from_usb function_check restore_directory_from_usb
restore_directory_from_friend $temp_restore_dir wekan restore_directory_from_friend $temp_restore_dir wekan
if [ -d $temp_restore_dir$WEKAN_DIR/data ]; then
cp -r $temp_restore_dir$WEKAN_DIR/data/* $WEKAN_DIR/data/ cp -r $temp_restore_dir$WEKAN_DIR/data/* $WEKAN_DIR/data/
else
cp -r $temp_restore_dir/* $WEKAN_DIR/data/
fi
rm -rf $temp_restore_dir
systemctl start wekan systemctl start wekan
fi fi
} }

View File

@ -460,7 +460,11 @@ function restore_local_xmpp {
temp_restore_dir=/root/tempxmpp temp_restore_dir=/root/tempxmpp
function_check restore_directory_from_usb function_check restore_directory_from_usb
restore_directory_from_usb $temp_restore_dir xmpp restore_directory_from_usb $temp_restore_dir xmpp
if [ -d $temp_restore_dir/var/lib/prosody ]; then
cp -r $temp_restore_dir/var/lib/prosody/* /var/lib/prosody cp -r $temp_restore_dir/var/lib/prosody/* /var/lib/prosody
else
cp -r $temp_restore_dir/* /var/lib/prosody/
fi
if [ ! "$?" = "0" ]; then if [ ! "$?" = "0" ]; then
function_check set_user_permissions function_check set_user_permissions
set_user_permissions set_user_permissions
@ -489,7 +493,11 @@ function restore_remote_xmpp {
temp_restore_dir=/root/tempxmpp temp_restore_dir=/root/tempxmpp
function_check restore_directory_from_friend function_check restore_directory_from_friend
restore_directory_from_friend $temp_restore_dir xmpp restore_directory_from_friend $temp_restore_dir xmpp
if [ -d $temp_restore_dir/var/lib/prosody ]; then
cp -r $temp_restore_dir/var/lib/prosody/* /var/lib/prosody cp -r $temp_restore_dir/var/lib/prosody/* /var/lib/prosody
else
cp -r $temp_restore_dir/* /var/lib/prosody/
fi
if [ ! "$?" = "0" ]; then if [ ! "$?" = "0" ]; then
exit 725 exit 725
fi fi

View File

@ -123,8 +123,10 @@ function restore_blocklist {
temp_restore_dir=/root/tempblocklist temp_restore_dir=/root/tempblocklist
restore_directory_from_usb $temp_restore_dir blocklist restore_directory_from_usb $temp_restore_dir blocklist
if [ -f $temp_restore_dir/root/tempbackupblocklist/${PROJECT_NAME}-firewall-domains.cfg ]; then if [ -d $temp_restore_dir/root/tempbackupblocklist ]; then
cp -f $temp_restore_dir/root/tempbackupblocklist/${PROJECT_NAME}-firewall-domains.cfg /root/${PROJECT_NAME}-firewall-domains.cfg cp -f $temp_restore_dir/root/tempbackupblocklist/${PROJECT_NAME}-firewall-domains.cfg /root/${PROJECT_NAME}-firewall-domains.cfg
else
cp -f $temp_restore_dir/${PROJECT_NAME}-firewall-domains.cfg /root/${PROJECT_NAME}-firewall-domains.cfg
fi fi
rm -rf $temp_restore_dir rm -rf $temp_restore_dir
@ -146,6 +148,7 @@ function restore_configfiles {
temp_restore_dir=/root/tempconfigfiles temp_restore_dir=/root/tempconfigfiles
restore_directory_from_usb $temp_restore_dir configfiles restore_directory_from_usb $temp_restore_dir configfiles
if [ -d $temp_restore_dir/root ]; then
if [ -f $temp_restore_dir/root/.nostore ]; then if [ -f $temp_restore_dir/root/.nostore ]; then
if [ ! -f /root/.nostore ]; then if [ ! -f /root/.nostore ]; then
touch /root/.nostore touch /root/.nostore
@ -155,6 +158,17 @@ function restore_configfiles {
rm /root/.nostore rm /root/.nostore
fi fi
fi fi
else
if [ -f $temp_restore_dir/.nostore ]; then
if [ ! -f /root/.nostore ]; then
touch /root/.nostore
fi
else
if [ -f /root/.nostore ]; then
rm /root/.nostore
fi
fi
fi
#if [ -f $temp_restore_dir$NODEJS_INSTALLED_APPS_FILE ]; then #if [ -f $temp_restore_dir$NODEJS_INSTALLED_APPS_FILE ]; then
# cp -f $temp_restore_dir$NODEJS_INSTALLED_APPS_FILE $NODEJS_INSTALLED_APPS_FILE # cp -f $temp_restore_dir$NODEJS_INSTALLED_APPS_FILE $NODEJS_INSTALLED_APPS_FILE
@ -196,9 +210,15 @@ function restore_configfiles {
fi fi
# restore nginx password hashes # restore nginx password hashes
if [ -d $temp_restore_dir/root ]; then
if [ -f $temp_restore_dir/root/htpasswd ]; then if [ -f $temp_restore_dir/root/htpasswd ]; then
cp -f $temp_restore_dir/root/htpasswd /etc/nginx/.htpasswd cp -f $temp_restore_dir/root/htpasswd /etc/nginx/.htpasswd
fi fi
else
if [ -f $temp_restore_dir/htpasswd ]; then
cp -f $temp_restore_dir/htpasswd /etc/nginx/.htpasswd
fi
fi
rm -rf $temp_restore_dir rm -rf $temp_restore_dir
fi fi
@ -238,11 +258,19 @@ function restore_mariadb {
db_pass=$(cat /root/.mariadboriginal) db_pass=$(cat /root/.mariadboriginal)
if [ ${#db_pass} -gt 0 ]; then if [ ${#db_pass} -gt 0 ]; then
echo $"Restore the MariaDB user table" echo $"Restore the MariaDB user table"
if [ -d ${temp_restore_dir}${temp_restore_dir} ]; then
mysqlsuccess=$(mysql -u root --password="$db_pass" mysql -o < ${temp_restore_dir}${temp_restore_dir}/mysql.sql) mysqlsuccess=$(mysql -u root --password="$db_pass" mysql -o < ${temp_restore_dir}${temp_restore_dir}/mysql.sql)
else
mysqlsuccess=$(mysql -u root --password="$db_pass" mysql -o < ${temp_restore_dir}/mysql.sql)
fi
if [ ! "$?" = "0" ]; then if [ ! "$?" = "0" ]; then
echo $"Try again using the password obtained from backup" echo $"Try again using the password obtained from backup"
db_pass=$(${PROJECT_NAME}-pass -u root -a mariadb) db_pass=$(${PROJECT_NAME}-pass -u root -a mariadb)
if [ -d ${temp_restore_dir}${temp_restore_dir} ]; then
mysqlsuccess=$(mysql -u root --password="$db_pass" mysql -o < ${temp_restore_dir}${temp_restore_dir}/mysql.sql) mysqlsuccess=$(mysql -u root --password="$db_pass" mysql -o < ${temp_restore_dir}${temp_restore_dir}/mysql.sql)
else
mysqlsuccess=$(mysql -u root --password="$db_pass" mysql -o < ${temp_restore_dir}/mysql.sql)
fi
fi fi
if [ ! "$?" = "0" ]; then if [ ! "$?" = "0" ]; then
echo "$mysqlsuccess" echo "$mysqlsuccess"
@ -269,7 +297,8 @@ function restore_letsencrypt {
fi fi
if [ -d $USB_MOUNT/backup/letsencrypt ]; then if [ -d $USB_MOUNT/backup/letsencrypt ]; then
echo $"Restoring Lets Encrypt settings" echo $"Restoring Lets Encrypt settings"
restore_directory_from_usb / letsencrypt #restore_directory_from_usb / letsencrypt
restore_directory_from_usb /etc/letsencrypt letsencrypt
chgrp -R ssl-cert /etc/letsencrypt chgrp -R ssl-cert /etc/letsencrypt
chmod -R g=rX /etc/letsencrypt chmod -R g=rX /etc/letsencrypt
fi fi
@ -284,7 +313,8 @@ function restore_passwordstore {
if [ -d $USB_MOUNT/backup/passwordstore ]; then if [ -d $USB_MOUNT/backup/passwordstore ]; then
store_original_mariadb_password store_original_mariadb_password
echo $"Restoring password store" echo $"Restoring password store"
restore_directory_from_usb / passwordstore #restore_directory_from_usb / passwordstore
restore_directory_from_usb /root/.passwords passwordstore
fi fi
} }
@ -296,7 +326,8 @@ function restore_tor {
fi fi
if [ -d $USB_MOUNT/backup/tor ]; then if [ -d $USB_MOUNT/backup/tor ]; then
echo $"Restoring Tor settings" echo $"Restoring Tor settings"
restore_directory_from_usb / tor #restore_directory_from_usb / tor
restore_directory_from_usb /var/lib/tor tor
fi fi
} }
@ -316,6 +347,7 @@ function restore_mutt_settings {
echo $"Restoring Mutt settings for $USERNAME" echo $"Restoring Mutt settings for $USERNAME"
temp_restore_dir=/root/tempmutt temp_restore_dir=/root/tempmutt
restore_directory_from_usb $temp_restore_dir mutt/$USERNAME restore_directory_from_usb $temp_restore_dir mutt/$USERNAME
if [ -d $temp_restore_dir/home/$USERNAME/tempbackup ]; then
if [ -f $temp_restore_dir/home/$USERNAME/tempbackup/.muttrc ]; then if [ -f $temp_restore_dir/home/$USERNAME/tempbackup/.muttrc ]; then
cp -f $temp_restore_dir/home/$USERNAME/tempbackup/.muttrc /home/$USERNAME/.muttrc cp -f $temp_restore_dir/home/$USERNAME/tempbackup/.muttrc /home/$USERNAME/.muttrc
sed -i '/set sidebar_delim/d' /home/$USERNAME/.muttrc sed -i '/set sidebar_delim/d' /home/$USERNAME/.muttrc
@ -326,6 +358,18 @@ function restore_mutt_settings {
sed -i '/set sidebar_delim/d' /etc/Muttrc sed -i '/set sidebar_delim/d' /etc/Muttrc
sed -i '/set sidebar_sort/d' /etc/Muttrc sed -i '/set sidebar_sort/d' /etc/Muttrc
fi fi
else
if [ -f $temp_restore_dir/.muttrc ]; then
cp -f $temp_restore_dir/.muttrc /home/$USERNAME/.muttrc
sed -i '/set sidebar_delim/d' /home/$USERNAME/.muttrc
sed -i '/set sidebar_sort/d' /home/$USERNAME/.muttrc
fi
if [ -f $temp_restore_dir/Muttrc ]; then
cp -f $temp_restore_dir/Muttrc /etc/Muttrc
sed -i '/set sidebar_delim/d' /etc/Muttrc
sed -i '/set sidebar_sort/d' /etc/Muttrc
fi
fi
if [ ! "$?" = "0" ]; then if [ ! "$?" = "0" ]; then
rm -rf $temp_restore_dir rm -rf $temp_restore_dir
set_user_permissions set_user_permissions
@ -353,7 +397,11 @@ function restore_gpg {
echo $"Restoring gnupg settings for $USERNAME" echo $"Restoring gnupg settings for $USERNAME"
temp_restore_dir=/root/tempgnupg temp_restore_dir=/root/tempgnupg
restore_directory_from_usb $temp_restore_dir gnupg/$USERNAME restore_directory_from_usb $temp_restore_dir gnupg/$USERNAME
if [ -d $temp_restore_dir/home/$USERNAME/.gnupg ]; then
cp -r $temp_restore_dir/home/$USERNAME/.gnupg /home/$USERNAME/ cp -r $temp_restore_dir/home/$USERNAME/.gnupg /home/$USERNAME/
else
cp -r $temp_restore_dir/* /home/$USERNAME/.gnupg/
fi
if [ ! "$?" = "0" ]; then if [ ! "$?" = "0" ]; then
rm -rf $temp_restore_dir rm -rf $temp_restore_dir
set_user_permissions set_user_permissions
@ -393,7 +441,11 @@ function restore_procmail {
temp_restore_dir=/root/tempprocmail temp_restore_dir=/root/tempprocmail
restore_directory_from_usb $temp_restore_dir procmail/$USERNAME restore_directory_from_usb $temp_restore_dir procmail/$USERNAME
if [ -d $temp_restore_dir ]; then if [ -d $temp_restore_dir ]; then
if [ -d $temp_restore_dir/home/$USERNAME/tempbackup ]; then
cp -f $temp_restore_dir/home/$USERNAME/tempbackup/.procmailrc /home/$USERNAME/ cp -f $temp_restore_dir/home/$USERNAME/tempbackup/.procmailrc /home/$USERNAME/
else
cp -f $temp_restore_dir/.procmailrc /home/$USERNAME/.procmailrc
fi
if [ ! "$?" = "0" ]; then if [ ! "$?" = "0" ]; then
rm -rf $temp_restore_dir rm -rf $temp_restore_dir
set_user_permissions set_user_permissions
@ -424,7 +476,11 @@ function restore_spamassassin {
echo $"Restoring spamassassin settings for $USERNAME" echo $"Restoring spamassassin settings for $USERNAME"
temp_restore_dir=/root/tempspamassassin temp_restore_dir=/root/tempspamassassin
restore_directory_from_usb $temp_restore_dir spamassassin/$USERNAME restore_directory_from_usb $temp_restore_dir spamassassin/$USERNAME
if [ -d $temp_restore_dir/home/$USERNAME ]; then
cp -rf $temp_restore_dir/home/$USERNAME/.spamassassin /home/$USERNAME/ cp -rf $temp_restore_dir/home/$USERNAME/.spamassassin /home/$USERNAME/
else
cp -rf $temp_restore_dir/* /home/$USERNAME/.spamassassin/
fi
if [ ! "$?" = "0" ]; then if [ ! "$?" = "0" ]; then
rm -rf $temp_restore_dir rm -rf $temp_restore_dir
set_user_permissions set_user_permissions
@ -457,7 +513,11 @@ function restore_admin_readme {
temp_restore_dir=/root/tempreadme temp_restore_dir=/root/tempreadme
restore_directory_from_usb $temp_restore_dir readme restore_directory_from_usb $temp_restore_dir readme
if [ -d $temp_restore_dir/home/$ADMIN_USERNAME/tempbackup ]; then
cp -f $temp_restore_dir/home/$ADMIN_USERNAME/tempbackup/README /home/$ADMIN_USERNAME/ cp -f $temp_restore_dir/home/$ADMIN_USERNAME/tempbackup/README /home/$ADMIN_USERNAME/
else
cp -f $temp_restore_dir/README /home/$ADMIN_USERNAME/README
fi
if [ ! "$?" = "0" ]; then if [ ! "$?" = "0" ]; then
rm -rf $temp_restore_dir rm -rf $temp_restore_dir
set_user_permissions set_user_permissions
@ -484,7 +544,11 @@ function restore_user_ssh_keys {
echo $"Restoring ssh keys for $USERNAME" echo $"Restoring ssh keys for $USERNAME"
temp_restore_dir=/root/tempssh temp_restore_dir=/root/tempssh
restore_directory_from_usb $temp_restore_dir ssh/$USERNAME restore_directory_from_usb $temp_restore_dir ssh/$USERNAME
if [ -d $temp_restore_dir/home/$USERNAME/.ssh ]; then
cp -r $temp_restore_dir/home/$USERNAME/.ssh /home/$USERNAME/ cp -r $temp_restore_dir/home/$USERNAME/.ssh /home/$USERNAME/
else
cp -r $temp_restore_dir/* /home/$USERNAME/.ssh/
fi
if [ ! "$?" = "0" ]; then if [ ! "$?" = "0" ]; then
rm -rf $temp_restore_dir rm -rf $temp_restore_dir
set_user_permissions set_user_permissions
@ -513,7 +577,11 @@ function restore_user_config {
echo $"Restoring config files for $USERNAME" echo $"Restoring config files for $USERNAME"
temp_restore_dir=/root/tempconfig temp_restore_dir=/root/tempconfig
restore_directory_from_usb $temp_restore_dir config/$USERNAME restore_directory_from_usb $temp_restore_dir config/$USERNAME
if [ -d $temp_restore_dir/home/$USERNAME/.config ]; then
cp -r $temp_restore_dir/home/$USERNAME/.config /home/$USERNAME/ cp -r $temp_restore_dir/home/$USERNAME/.config /home/$USERNAME/
else
cp -r $temp_restore_dir/* /home/$USERNAME/.config/
fi
if [ ! "$?" = "0" ]; then if [ ! "$?" = "0" ]; then
rm -rf $temp_restore_dir rm -rf $temp_restore_dir
set_user_permissions set_user_permissions
@ -542,7 +610,11 @@ function restore_user_monkeysphere {
echo $"Restoring monkeysphere ids for $USERNAME" echo $"Restoring monkeysphere ids for $USERNAME"
temp_restore_dir=/root/tempmonkeysphere temp_restore_dir=/root/tempmonkeysphere
restore_directory_from_usb $temp_restore_dir monkeysphere/$USERNAME restore_directory_from_usb $temp_restore_dir monkeysphere/$USERNAME
if [ -d $temp_restore_dir/home/$USERNAME/.monkeysphere ]; then
cp -r $temp_restore_dir/home/$USERNAME/.monkeysphere /home/$USERNAME/ cp -r $temp_restore_dir/home/$USERNAME/.monkeysphere /home/$USERNAME/
else
cp -r $temp_restore_dir/* /home/$USERNAME/.monkeysphere
fi
if [ ! "$?" = "0" ]; then if [ ! "$?" = "0" ]; then
rm -rf $temp_restore_dir rm -rf $temp_restore_dir
set_user_permissions set_user_permissions
@ -579,7 +651,11 @@ function restore_user_fin {
echo $"Restoring fin files for $USERNAME" echo $"Restoring fin files for $USERNAME"
temp_restore_dir=/root/tempfin temp_restore_dir=/root/tempfin
restore_directory_from_usb $temp_restore_dir fin/$USERNAME restore_directory_from_usb $temp_restore_dir fin/$USERNAME
if [ -d $temp_restore_dir/home/$USERNAME/.fin ]; then
cp -r $temp_restore_dir/home/$USERNAME/.fin /home/$USERNAME/ cp -r $temp_restore_dir/home/$USERNAME/.fin /home/$USERNAME/
else
cp -r $temp_restore_dir/* /home/$USERNAME/.fin/
fi
if [ ! "$?" = "0" ]; then if [ ! "$?" = "0" ]; then
rm -rf $temp_restore_dir rm -rf $temp_restore_dir
set_user_permissions set_user_permissions
@ -608,7 +684,11 @@ function restore_user_local {
echo $"Restoring local files for $USERNAME" echo $"Restoring local files for $USERNAME"
temp_restore_dir=/root/templocal temp_restore_dir=/root/templocal
restore_directory_from_usb $temp_restore_dir local/$USERNAME restore_directory_from_usb $temp_restore_dir local/$USERNAME
if [ -d $temp_restore_dir/home/$USERNAME/.local ]; then
cp -r $temp_restore_dir/home/$USERNAME/.local /home/$USERNAME/ cp -r $temp_restore_dir/home/$USERNAME/.local /home/$USERNAME/
else
cp -r $temp_restore_dir/* /home/$USERNAME/.local/
fi
if [ ! "$?" = "0" ]; then if [ ! "$?" = "0" ]; then
rm -rf $temp_restore_dir rm -rf $temp_restore_dir
set_user_permissions set_user_permissions
@ -631,7 +711,11 @@ function restore_certs {
echo $"Restoring certificates" echo $"Restoring certificates"
mkdir /root/tempssl mkdir /root/tempssl
restore_directory_from_usb /root/tempssl ssl restore_directory_from_usb /root/tempssl ssl
if [ -d /root/tempssl/etc/ssl ]; then
cp -r /root/tempssl/etc/ssl/* /etc/ssl cp -r /root/tempssl/etc/ssl/* /etc/ssl
else
cp -r /root/tempssl/* /etc/ssl/
fi
if [ ! "$?" = "0" ]; then if [ ! "$?" = "0" ]; then
set_user_permissions set_user_permissions
backup_unmount_drive backup_unmount_drive
@ -686,7 +770,11 @@ function restore_personal_settings {
if [ -d /home/$USERNAME/personal ]; then if [ -d /home/$USERNAME/personal ]; then
rm -rf /home/$USERNAME/personal rm -rf /home/$USERNAME/personal
fi fi
if [ -d $temp_restore_dir/home/$USERNAME/personal ]; then
mv $temp_restore_dir/home/$USERNAME/personal /home/$USERNAME mv $temp_restore_dir/home/$USERNAME/personal /home/$USERNAME
else
cp -r $temp_restore_dir/* /home/$USERNAME/personal/
fi
if [ ! "$?" = "0" ]; then if [ ! "$?" = "0" ]; then
set_user_permissions set_user_permissions
backup_unmount_drive backup_unmount_drive
@ -709,7 +797,11 @@ function restore_mailing_list {
echo $"Restoring public mailing list" echo $"Restoring public mailing list"
temp_restore_dir=/root/tempmailinglist temp_restore_dir=/root/tempmailinglist
restore_directory_from_usb $temp_restore_dir mailinglist restore_directory_from_usb $temp_restore_dir mailinglist
if [ -d $temp_restore_dir/root/spool/mlmmj ]; then
cp -r $temp_restore_dir/root/spool/mlmmj/* /var/spool/mlmmj cp -r $temp_restore_dir/root/spool/mlmmj/* /var/spool/mlmmj
else
cp -r $temp_restore_dir/* /var/spool/mlmmj/
fi
if [ ! "$?" = "0" ]; then if [ ! "$?" = "0" ]; then
set_user_permissions set_user_permissions
backup_unmount_drive backup_unmount_drive
@ -738,11 +830,15 @@ function restore_email {
if [ ! -d /home/$USERNAME/Maildir ]; then if [ ! -d /home/$USERNAME/Maildir ]; then
mkdir /home/$USERNAME/Maildir mkdir /home/$USERNAME/Maildir
fi fi
if [ -d $temp_restore_dir/root/tempbackupemail/$USERNAME ]; then
tar -xzvf $temp_restore_dir/root/tempbackupemail/$USERNAME/maildir.tar.gz -C / tar -xzvf $temp_restore_dir/root/tempbackupemail/$USERNAME/maildir.tar.gz -C /
else
tar -xzvf $temp_restore_dir/maildir.tar.gz -C /
fi
if [ ! "$?" = "0" ]; then if [ ! "$?" = "0" ]; then
set_user_permissions set_user_permissions
backup_unmount_drive backup_unmount_drive
exit 927 exit 9276382
fi fi
rm -rf $temp_restore_dir rm -rf $temp_restore_dir
fi fi

View File

@ -113,10 +113,11 @@ function restore_blocklist {
echo $"Restoring blocklist" echo $"Restoring blocklist"
temp_restore_dir=/root/tempblocklist temp_restore_dir=/root/tempblocklist
restore_directory_from_friend $temp_restore_dir blocklist restore_directory_from_friend $temp_restore_dir blocklist
restore_directory_from_usb $temp_restore_dir blocklist
if [ -f $temp_restore_dir/root/tempbackupblocklist/${PROJECT_NAME}-firewall-domains.cfg ]; then if [ -d $temp_restore_dir/root/tempbackupblocklist ]; then
cp -f $temp_restore_dir/root/tempbackupblocklist/${PROJECT_NAME}-firewall-domains.cfg /root/${PROJECT_NAME}-firewall-domains.cfg cp -f $temp_restore_dir/root/tempbackupblocklist/${PROJECT_NAME}-firewall-domains.cfg /root/${PROJECT_NAME}-firewall-domains.cfg
else
cp -f $temp_restore_dir/${PROJECT_NAME}-firewall-domains.cfg /root/${PROJECT_NAME}-firewall-domains.cfg
fi fi
rm -rf $temp_restore_dir rm -rf $temp_restore_dir
@ -136,6 +137,7 @@ function restore_configfiles {
temp_restore_dir=/root/tempconfigfiles temp_restore_dir=/root/tempconfigfiles
restore_directory_from_friend $temp_restore_dir configfiles restore_directory_from_friend $temp_restore_dir configfiles
if [ -d $temp_restore_dir/root ]; then
if [ -f $temp_restore_dir/root/.nostore ]; then if [ -f $temp_restore_dir/root/.nostore ]; then
if [ ! -f /root/.nostore ]; then if [ ! -f /root/.nostore ]; then
touch /root/.nostore touch /root/.nostore
@ -145,6 +147,17 @@ function restore_configfiles {
rm /root/.nostore rm /root/.nostore
fi fi
fi fi
else
if [ -f $temp_restore_dir/.nostore ]; then
if [ ! -f /root/.nostore ]; then
touch /root/.nostore
fi
else
if [ -f /root/.nostore ]; then
rm /root/.nostore
fi
fi
fi
#if [ -f $temp_restore_dir$NODEJS_INSTALLED_APPS_FILE ]; then #if [ -f $temp_restore_dir$NODEJS_INSTALLED_APPS_FILE ]; then
# cp -f $temp_restore_dir$NODEJS_INSTALLED_APPS_FILE $NODEJS_INSTALLED_APPS_FILE # cp -f $temp_restore_dir$NODEJS_INSTALLED_APPS_FILE $NODEJS_INSTALLED_APPS_FILE
@ -214,11 +227,19 @@ function restore_mariadb {
db_pass=$(cat /root/.mariadboriginal) db_pass=$(cat /root/.mariadboriginal)
if [ ${#db_pass} -gt 0 ]; then if [ ${#db_pass} -gt 0 ]; then
echo $"Restore the MariaDB user table" echo $"Restore the MariaDB user table"
if [ -d ${temp_restore_dir}${temp_restore_dir} ]; then
mysqlsuccess=$(mysql -u root --password="$db_pass" mysql -o < ${temp_restore_dir}${temp_restore_dir}/mysql.sql) mysqlsuccess=$(mysql -u root --password="$db_pass" mysql -o < ${temp_restore_dir}${temp_restore_dir}/mysql.sql)
else
mysqlsuccess=$(mysql -u root --password="$db_pass" mysql -o < ${temp_restore_dir}/mysql.sql)
fi
if [ ! "$?" = "0" ]; then if [ ! "$?" = "0" ]; then
echo $"Try again using the password obtained from backup" echo $"Try again using the password obtained from backup"
db_pass=$(${PROJECT_NAME}-pass -u root -a mariadb) db_pass=$(${PROJECT_NAME}-pass -u root -a mariadb)
if [ -d ${temp_restore_dir}${temp_restore_dir} ]; then
mysqlsuccess=$(mysql -u root --password="$db_pass" mysql -o < ${temp_restore_dir}${temp_restore_dir}/mysql.sql) mysqlsuccess=$(mysql -u root --password="$db_pass" mysql -o < ${temp_restore_dir}${temp_restore_dir}/mysql.sql)
else
mysqlsuccess=$(mysql -u root --password="$db_pass" mysql -o < ${temp_restore_dir}/mysql.sql)
fi
fi fi
if [ ! "$?" = "0" ]; then if [ ! "$?" = "0" ]; then
echo "$mysqlsuccess" echo "$mysqlsuccess"
@ -242,7 +263,7 @@ function restore_letsencrypt {
fi fi
if [ -d $SERVER_DIRECTORY/backup/letsencrypt ]; then if [ -d $SERVER_DIRECTORY/backup/letsencrypt ]; then
echo $"Restoring Lets Encrypt settings" echo $"Restoring Lets Encrypt settings"
restore_directory_from_friend / letsencrypt restore_directory_from_friend /etc/letsencrypt letsencrypt
fi fi
} }
@ -255,7 +276,7 @@ function restore_passwordstore {
if [ -d $SERVER_DIRECTORY/backup/passwordstore ]; then if [ -d $SERVER_DIRECTORY/backup/passwordstore ]; then
store_original_mariadb_password store_original_mariadb_password
echo $"Restoring password store" echo $"Restoring password store"
restore_directory_from_friend / passwordstore restore_directory_from_friend /root/.passwords passwordstore
fi fi
} }
@ -267,7 +288,7 @@ function restore_tor {
fi fi
if [ -d $SERVER_DIRECTORY/backup/tor ]; then if [ -d $SERVER_DIRECTORY/backup/tor ]; then
echo $"Restoring Tor settings" echo $"Restoring Tor settings"
restore_directory_from_friend / tor restore_directory_from_friend /var/lib/tor tor
fi fi
} }
@ -287,6 +308,7 @@ function restore_mutt_settings {
echo $"Restoring Mutt settings for $USERNAME" echo $"Restoring Mutt settings for $USERNAME"
temp_restore_dir=/root/tempmutt temp_restore_dir=/root/tempmutt
restore_directory_from_friend ${temp_restore_dir} mutt/$USERNAME restore_directory_from_friend ${temp_restore_dir} mutt/$USERNAME
if [ -d ${temp_restore_dir}/home/$USERNAME/tempbackup ]; then
if [ -f ${temp_restore_dir}/home/$USERNAME/tempbackup/.muttrc ]; then if [ -f ${temp_restore_dir}/home/$USERNAME/tempbackup/.muttrc ]; then
cp -f ${temp_restore_dir}/home/$USERNAME/tempbackup/.muttrc /home/$USERNAME/.muttrc cp -f ${temp_restore_dir}/home/$USERNAME/tempbackup/.muttrc /home/$USERNAME/.muttrc
sed -i '/set sidebar_delim/d' /home/$USERNAME/.muttrc sed -i '/set sidebar_delim/d' /home/$USERNAME/.muttrc
@ -297,6 +319,18 @@ function restore_mutt_settings {
sed -i '/set sidebar_delim/d' /etc/Muttrc sed -i '/set sidebar_delim/d' /etc/Muttrc
sed -i '/set sidebar_sort/d' /etc/Muttrc sed -i '/set sidebar_sort/d' /etc/Muttrc
fi fi
else
if [ -f ${temp_restore_dir}/.muttrc ]; then
cp -f ${temp_restore_dir}/.muttrc /home/$USERNAME/.muttrc
sed -i '/set sidebar_delim/d' /home/$USERNAME/.muttrc
sed -i '/set sidebar_sort/d' /home/$USERNAME/.muttrc
fi
if [ -f ${temp_restore_dir}/Muttrc ]; then
cp -f ${temp_restore_dir}/Muttrc /etc/Muttrc
sed -i '/set sidebar_delim/d' /etc/Muttrc
sed -i '/set sidebar_sort/d' /etc/Muttrc
fi
fi
if [ ! "$?" = "0" ]; then if [ ! "$?" = "0" ]; then
rm -rf ${temp_restore_dir} rm -rf ${temp_restore_dir}
exit 276 exit 276
@ -322,7 +356,11 @@ function restore_gpg {
echo $"Restoring gnupg settings for $USERNAME" echo $"Restoring gnupg settings for $USERNAME"
temp_restore_dir=/root/tempgnupg temp_restore_dir=/root/tempgnupg
restore_directory_from_friend ${temp_restore_dir} gnupg/$USERNAME restore_directory_from_friend ${temp_restore_dir} gnupg/$USERNAME
if [ -d ${temp_restore_dir}/home/$USERNAME/.gnupg ]; then
cp -r ${temp_restore_dir}/home/$USERNAME/.gnupg /home/$USERNAME/ cp -r ${temp_restore_dir}/home/$USERNAME/.gnupg /home/$USERNAME/
else
cp -r ${temp_restore_dir}/* /home/$USERNAME/.gnupg/
fi
if [ ! "$?" = "0" ]; then if [ ! "$?" = "0" ]; then
rm -rf ${temp_restore_dir} rm -rf ${temp_restore_dir}
exit 276 exit 276
@ -356,7 +394,11 @@ function restore_procmail {
echo $"Restoring procmail settings for $USERNAME" echo $"Restoring procmail settings for $USERNAME"
temp_restore_dir=/root/tempprocmail temp_restore_dir=/root/tempprocmail
restore_directory_from_friend ${temp_restore_dir} procmail/$USERNAME restore_directory_from_friend ${temp_restore_dir} procmail/$USERNAME
if [ -d ${temp_restore_dir}/home/$USERNAME/tempbackup ]; then
cp -f ${temp_restore_dir}/home/$USERNAME/tempbackup/.procmailrc /home/$USERNAME/ cp -f ${temp_restore_dir}/home/$USERNAME/tempbackup/.procmailrc /home/$USERNAME/
else
cp -f ${temp_restore_dir}/.procmailrc /home/$USERNAME/.procmailrc
fi
if [ ! "$?" = "0" ]; then if [ ! "$?" = "0" ]; then
rm -rf ${temp_restore_dir} rm -rf ${temp_restore_dir}
exit 276 exit 276
@ -383,7 +425,11 @@ function restore_spamassassin {
echo $"Restoring spamassassin settings for $USERNAME" echo $"Restoring spamassassin settings for $USERNAME"
temp_restore_dir=/root/tempspamassassin temp_restore_dir=/root/tempspamassassin
restore_directory_from_friend $temp_restore_dir spamassassin/$USERNAME restore_directory_from_friend $temp_restore_dir spamassassin/$USERNAME
if [ -d $temp_restore_dir/home/$USERNAME ]; then
cp -rf $temp_restore_dir/home/$USERNAME/.spamassassin /home/$USERNAME/ cp -rf $temp_restore_dir/home/$USERNAME/.spamassassin /home/$USERNAME/
else
cp -rf $temp_restore_dir/* /home/$USERNAME/.spamassassin/
fi
if [ ! "$?" = "0" ]; then if [ ! "$?" = "0" ]; then
rm -rf $temp_restore_dir rm -rf $temp_restore_dir
exit 276 exit 276
@ -404,7 +450,11 @@ function restore_admin_readme {
echo $"Restoring README" echo $"Restoring README"
temp_restore_dir=/root/tempreadme temp_restore_dir=/root/tempreadme
restore_directory_from_friend $temp_restore_dir readme restore_directory_from_friend $temp_restore_dir readme
if [ -d $temp_restore_dir/home/$ADMIN_USERNAME/tempbackup ]; then
cp -f $temp_restore_dir/home/$ADMIN_USERNAME/tempbackup/README /home/$ADMIN_USERNAME/ cp -f $temp_restore_dir/home/$ADMIN_USERNAME/tempbackup/README /home/$ADMIN_USERNAME/
else
cp -f $temp_restore_dir/README /home/$ADMIN_USERNAME/README
fi
if [ ! "$?" = "0" ]; then if [ ! "$?" = "0" ]; then
rm -rf $temp_restore_dir rm -rf $temp_restore_dir
exit 276 exit 276
@ -429,7 +479,11 @@ function restore_ssh_keys {
echo $"Restoring ssh keys for $USERNAME" echo $"Restoring ssh keys for $USERNAME"
temp_restore_dir=/root/tempssh temp_restore_dir=/root/tempssh
restore_directory_from_friend $temp_restore_dir ssh/$USERNAME restore_directory_from_friend $temp_restore_dir ssh/$USERNAME
if [ -d $temp_restore_dir/home/$USERNAME/.ssh ]; then
cp -r $temp_restore_dir/home/$USERNAME/.ssh /home/$USERNAME/ cp -r $temp_restore_dir/home/$USERNAME/.ssh /home/$USERNAME/
else
cp -r $temp_restore_dir/* /home/$USERNAME/.ssh/
fi
if [ ! "$?" = "0" ]; then if [ ! "$?" = "0" ]; then
rm -rf $temp_restore_dir rm -rf $temp_restore_dir
exit 664 exit 664
@ -456,7 +510,11 @@ function restore_user_config {
echo $"Restoring config files for $USERNAME" echo $"Restoring config files for $USERNAME"
temp_restore_dir=/root/tempconfig temp_restore_dir=/root/tempconfig
restore_directory_from_friend $temp_restore_dir config/$USERNAME restore_directory_from_friend $temp_restore_dir config/$USERNAME
if [ -d $temp_restore_dir/home/$USERNAME ]; then
cp -r $temp_restore_dir/home/$USERNAME/.config /home/$USERNAME/ cp -r $temp_restore_dir/home/$USERNAME/.config /home/$USERNAME/
else
cp -r $temp_restore_dir/* /home/$USERNAME/.config/
fi
if [ ! "$?" = "0" ]; then if [ ! "$?" = "0" ]; then
rm -rf $temp_restore_dir rm -rf $temp_restore_dir
exit 664 exit 664
@ -483,7 +541,11 @@ function restore_user_monkeysphere {
echo $"Restoring monkeysphere ids for $USERNAME" echo $"Restoring monkeysphere ids for $USERNAME"
temp_restore_dir=/root/tempmonkeysphere temp_restore_dir=/root/tempmonkeysphere
restore_directory_from_friend $temp_restore_dir monkeysphere/$USERNAME restore_directory_from_friend $temp_restore_dir monkeysphere/$USERNAME
if [ -d $temp_restore_dir/home/$USERNAME/.monkeysphere ]; then
cp -r $temp_restore_dir/home/$USERNAME/.monkeysphere /home/$USERNAME/ cp -r $temp_restore_dir/home/$USERNAME/.monkeysphere /home/$USERNAME/
else
cp -r $temp_restore_dir/* /home/$USERNAME/.monkeysphere/
fi
if [ ! "$?" = "0" ]; then if [ ! "$?" = "0" ]; then
rm -rf $temp_restore_dir rm -rf $temp_restore_dir
exit 664 exit 664
@ -518,7 +580,11 @@ function restore_user_fin {
echo $"Restoring fin files for $USERNAME" echo $"Restoring fin files for $USERNAME"
temp_restore_dir=/root/tempfin temp_restore_dir=/root/tempfin
restore_directory_from_friend $temp_restore_dir fin/$USERNAME restore_directory_from_friend $temp_restore_dir fin/$USERNAME
if [ -d $temp_restore_dir/home/$USERNAME/.fin ]; then
cp -r $temp_restore_dir/home/$USERNAME/.fin /home/$USERNAME/ cp -r $temp_restore_dir/home/$USERNAME/.fin /home/$USERNAME/
else
cp -r $temp_restore_dir/* /home/$USERNAME/.fin/
fi
if [ ! "$?" = "0" ]; then if [ ! "$?" = "0" ]; then
rm -rf $temp_restore_dir rm -rf $temp_restore_dir
exit 664 exit 664
@ -545,7 +611,11 @@ function restore_user_local {
echo $"Restoring local files for $USERNAME" echo $"Restoring local files for $USERNAME"
temp_restore_dir=/root/templocal temp_restore_dir=/root/templocal
restore_directory_from_friend $temp_restore_dir local/$USERNAME restore_directory_from_friend $temp_restore_dir local/$USERNAME
if [ -d $temp_restore_dir/home/$USERNAME/.local ]; then
cp -r $temp_restore_dir/home/$USERNAME/.local /home/$USERNAME/ cp -r $temp_restore_dir/home/$USERNAME/.local /home/$USERNAME/
else
cp -r $temp_restore_dir/* /home/$USERNAME/.local/
fi
if [ ! "$?" = "0" ]; then if [ ! "$?" = "0" ]; then
rm -rf $temp_restore_dir rm -rf $temp_restore_dir
exit 664 exit 664
@ -565,7 +635,11 @@ function restore_certs {
if [ -d $SERVER_DIRECTORY/backup/ssl ]; then if [ -d $SERVER_DIRECTORY/backup/ssl ]; then
echo $"Restoring certificates" echo $"Restoring certificates"
restore_directory_from_friend /root/tempssl ssl restore_directory_from_friend /root/tempssl ssl
if [ -d /root/tempssl/etc/ssl ]; then
cp -r /root/tempssl/etc/ssl/* /etc/ssl cp -r /root/tempssl/etc/ssl/* /etc/ssl
else
cp -r /root/tempssl/* /etc/ssl/
fi
if [ ! "$?" = "0" ]; then if [ ! "$?" = "0" ]; then
exit 276 exit 276
fi fi
@ -614,12 +688,16 @@ function restore_personal_settings {
echo $"Restoring personal settings for $USERNAME" echo $"Restoring personal settings for $USERNAME"
temp_restore_dir=/root/temppersonal temp_restore_dir=/root/temppersonal
restore_directory_from_friend $temp_restore_dir personal/$USERNAME restore_directory_from_friend $temp_restore_dir personal/$USERNAME
if [ -d $temp_restore_dir/home/$USERNAME/personal ]; then
if [ -d /home/$USERNAME/personal ]; then if [ -d /home/$USERNAME/personal ]; then
rm -rf /home/$USERNAME/personal rm -rf /home/$USERNAME/personal
fi fi
mv $temp_restore_dir/home/$USERNAME/personal /home/$USERNAME mv $temp_restore_dir/home/$USERNAME/personal /home/$USERNAME
else
cp -r $temp_restore_dir/* /home/$USERNAME/personal/
fi
if [ ! "$?" = "0" ]; then if [ ! "$?" = "0" ]; then
exit 184 exit 18437643
fi fi
rm -rf $temp_restore_dir rm -rf $temp_restore_dir
fi fi
@ -637,7 +715,11 @@ function restore_mailing_list {
echo $"Restoring public mailing list" echo $"Restoring public mailing list"
temp_restore_dir=/root/tempmailinglist temp_restore_dir=/root/tempmailinglist
restore_directory_from_friend $temp_restore_dir mailinglist restore_directory_from_friend $temp_restore_dir mailinglist
if [ -d $temp_restore_dir/root/spool/mlmmj ]; then
cp -r $temp_restore_dir/root/spool/mlmmj/* /var/spool/mlmmj cp -r $temp_restore_dir/root/spool/mlmmj/* /var/spool/mlmmj
else
cp -r $temp_restore_dir/* /var/spool/mlmmj/
fi
if [ ! "$?" = "0" ]; then if [ ! "$?" = "0" ]; then
exit 526 exit 526
fi fi
@ -664,7 +746,11 @@ function restore_email {
if [ ! -d /home/$USERNAME/Maildir ]; then if [ ! -d /home/$USERNAME/Maildir ]; then
mkdir /home/$USERNAME/Maildir mkdir /home/$USERNAME/Maildir
fi fi
if [ -d $temp_restore_dir/root/tempbackupemail/$USERNAME ]; then
tar -xzvf $temp_restore_dir/root/tempbackupemail/$USERNAME/maildir.tar.gz -C / tar -xzvf $temp_restore_dir/root/tempbackupemail/$USERNAME/maildir.tar.gz -C /
else
tar -xzvf $temp_restore_dir/maildir.tar.gz -C /
fi
if [ ! "$?" = "0" ]; then if [ ! "$?" = "0" ]; then
exit 927 exit 927
fi fi

View File

@ -628,7 +628,11 @@ function restore_database_from_friend {
echo $"Restoring ${1} database" echo $"Restoring ${1} database"
local_database_dir=/root/temp${1}data local_database_dir=/root/temp${1}data
restore_directory_from_friend ${local_database_dir} ${1}data restore_directory_from_friend ${local_database_dir} ${1}data
if [ ! -f ${local_database_dir}/${RESTORE_SUBDIR}/temp${1}data/${1}.sql ]; then database_file=${local_database_dir}/${RESTORE_SUBDIR}/temp${restore_app_name}data/${restore_app_name}.sql
if [ ! -f $database_file ]; then
database_file=${local_database_dir}/${restore_app_name}.sql
fi
if [ ! -f $database_file ]; then
echo $"Unable to restore ${1} database" echo $"Unable to restore ${1} database"
rm -rf ${local_database_dir} rm -rf ${local_database_dir}
exit 503 exit 503
@ -639,21 +643,35 @@ function restore_database_from_friend {
echo "$mysqlsuccess" echo "$mysqlsuccess"
exit 964 exit 964
fi fi
if [ -d ${local_database_dir}/${RESTORE_SUBDIR}/temp${1}data ]; then
shred -zu ${local_database_dir}/${RESTORE_SUBDIR}/temp${1}data/* shred -zu ${local_database_dir}/${RESTORE_SUBDIR}/temp${1}data/*
else
shred -zu ${local_database_dir}/*.sql
fi
rm -rf ${local_database_dir} rm -rf ${local_database_dir}
echo $"Restoring ${1} installation" echo $"Restoring ${1} installation"
restore_directory_from_friend /root/temp${1} ${1} restore_directory_from_friend /root/temp${1} ${1}
RESTORE_SUBDIR="var" RESTORE_SUBDIR="var"
if [ ${1} ]; then if [ ${1} ]; then
# create directory to restore to
if [ ! -d /var/www/${2}/htdocs ]; then if [ ! -d /var/www/${2}/htdocs ]; then
mkdir -p /var/www/${2}/htdocs mkdir -p /var/www/${2}/htdocs
chown www-data:www-data /var/www/${2}/htdocs chown www-data:www-data /var/www/${2}/htdocs
fi fi
if [ -d /var/www/${2}/htdocs ]; then if [ -d /var/www/${2}/htdocs ]; then
restore_from_dir=/root/temp${1}/${RESTORE_SUBDIR}/www/${2}/htdocs
if [ ! -d /root/temp${1}/${RESTORE_SUBDIR}/www/${2}/htdocs ]; then
restore_from_dir=/root/temp${1}
fi
if [ -d $restore_from_dir ]; then
if [ -d /root/temp${1}/${RESTORE_SUBDIR}/www/${2}/htdocs ]; then if [ -d /root/temp${1}/${RESTORE_SUBDIR}/www/${2}/htdocs ]; then
rm -rf /var/www/${2}/htdocs rm -rf /var/www/${2}/htdocs
mv /root/temp${1}/${RESTORE_SUBDIR}/www/${2}/htdocs /var/www/${2}/ mv $restore_from_dir /var/www/${2}/
else
cp -r $restore_from_dir/* /var/www/${2}/htdocs/
fi
if [ ! "$?" = "0" ]; then if [ ! "$?" = "0" ]; then
exit 683 exit 683
fi fi
@ -685,7 +703,11 @@ function restore_database {
fi fi
function_check restore_directory_from_usb function_check restore_directory_from_usb
restore_directory_from_usb "${local_database_dir}" "${restore_app_name}data" restore_directory_from_usb "${local_database_dir}" "${restore_app_name}data"
if [ ! -f /root/temp${restore_app_name}data/${RESTORE_SUBDIR}/temp${restore_app_name}data/${restore_app_name}.sql ]; then database_file=${local_database_dir}/${RESTORE_SUBDIR}/temp${restore_app_name}data/${restore_app_name}.sql
if [ ! -f $database_file ]; then
database_file=${local_database_dir}/${restore_app_name}.sql
fi
if [ ! -f $database_file ]; then
echo $"Unable to restore ${restore_app_name} database" echo $"Unable to restore ${restore_app_name} database"
rm -rf ${local_database_dir} rm -rf ${local_database_dir}
function_check set_user_permissions function_check set_user_permissions
@ -695,7 +717,7 @@ function restore_database {
exit 503 exit 503
fi fi
keep_database_running keep_database_running
mysqlsuccess=$(mysql -u root --password="$DATABASE_PASSWORD" ${restore_app_name} -o < ${local_database_dir}/${RESTORE_SUBDIR}/temp${restore_app_name}data/${restore_app_name}.sql) mysqlsuccess=$(mysql -u root --password="$DATABASE_PASSWORD" ${restore_app_name} -o < $database_file)
if [ ! "$?" = "0" ]; then if [ ! "$?" = "0" ]; then
echo "$mysqlsuccess" echo "$mysqlsuccess"
function_check set_user_permissions function_check set_user_permissions
@ -704,7 +726,12 @@ function restore_database {
backup_unmount_drive backup_unmount_drive
exit 964 exit 964
fi fi
if [ -d ${local_database_dir}/${RESTORE_SUBDIR}/temp${restore_app_name}data ]; then
shred -zu ${local_database_dir}/${RESTORE_SUBDIR}/temp${restore_app_name}data/* shred -zu ${local_database_dir}/${RESTORE_SUBDIR}/temp${restore_app_name}data/*
else
shred -zu ${local_database_dir}/*.sql
fi
rm -rf ${local_database_dir} rm -rf ${local_database_dir}
echo $"Restoring ${restore_app_name} installation" echo $"Restoring ${restore_app_name} installation"
if [ ! -d /root/temp${restore_app_name} ]; then if [ ! -d /root/temp${restore_app_name} ]; then
@ -714,14 +741,24 @@ function restore_database {
restore_directory_from_usb "/root/temp${restore_app_name}" "${restore_app_name}" restore_directory_from_usb "/root/temp${restore_app_name}" "${restore_app_name}"
RESTORE_SUBDIR="var" RESTORE_SUBDIR="var"
if [ ${restore_app_domain} ]; then if [ ${restore_app_domain} ]; then
# create directory to restore to
if [ ! -d /var/www/${restore_app_domain}/htdocs ]; then if [ ! -d /var/www/${restore_app_domain}/htdocs ]; then
mkdir -p /var/www/${restore_app_domain}/htdocs mkdir -p /var/www/${restore_app_domain}/htdocs
chown www-data:www-data /var/www/${restore_app_domain}/htdocs chown www-data:www-data /var/www/${restore_app_domain}/htdocs
fi fi
if [ -d /var/www/${restore_app_domain}/htdocs ]; then if [ -d /var/www/${restore_app_domain}/htdocs ]; then
restore_from_dir=/root/temp${restore_app_name}/${RESTORE_SUBDIR}/www/${restore_app_domain}/htdocs
if [ ! -d $restore_from_dir ]; then
restore_from_dir=/root/temp${restore_app_name}
fi
if [ -d $restore_from_dir ]; then
if [ -d /root/temp${restore_app_name}/${RESTORE_SUBDIR}/www/${restore_app_domain}/htdocs ]; then if [ -d /root/temp${restore_app_name}/${RESTORE_SUBDIR}/www/${restore_app_domain}/htdocs ]; then
rm -rf /var/www/${restore_app_domain}/htdocs rm -rf /var/www/${restore_app_domain}/htdocs
mv /root/temp${restore_app_name}/${RESTORE_SUBDIR}/www/${restore_app_domain}/htdocs /var/www/${restore_app_domain}/ mv $restore_from_dir /var/www/${restore_app_domain}/
else
cp -r $restore_from_dir/* /var/www/${restore_app_domain}/htdocs/
fi
if [ ! "$?" = "0" ]; then if [ ! "$?" = "0" ]; then
set_user_permissions set_user_permissions
backup_unmount_drive backup_unmount_drive