Safer restore

This commit is contained in:
Bob Mottram 2016-11-06 16:42:24 +00:00
parent d6400e0a04
commit f2d5af32dc
2 changed files with 17 additions and 3 deletions

View File

@ -220,7 +220,6 @@ function restore_local_htmly {
HTMLY_DOMAIN_NAME=$(get_completion_param "htmly domain") HTMLY_DOMAIN_NAME=$(get_completion_param "htmly domain")
fi fi
if [ $HTMLY_DOMAIN_NAME ]; then if [ $HTMLY_DOMAIN_NAME ]; then
echo $"Restoring htmly installation"
temp_restore_dir=/root/temphtmly temp_restore_dir=/root/temphtmly
if [ -d $USB_MOUNT/backup/htmly ]; then if [ -d $USB_MOUNT/backup/htmly ]; then
restore_directory_from_usb $temp_restore_dir htmly restore_directory_from_usb $temp_restore_dir htmly
@ -228,11 +227,17 @@ function restore_local_htmly {
restore_directory_from_usb $temp_restore_dir blog restore_directory_from_usb $temp_restore_dir blog
fi fi
if [ -d /var/www/${HTMLY_DOMAIN_NAME}/htdocs ]; then if [ -d /var/www/${HTMLY_DOMAIN_NAME}/htdocs ]; then
rm -rf /var/www/${HTMLY_DOMAIN_NAME}/htdocs if [ -d /var/www/${HTMLY_DOMAIN_NAME}/previous ]; then
rm -rf /var/www/${HTMLY_DOMAIN_NAME}/previous
fi
mv /var/www/${HTMLY_DOMAIN_NAME}/htdocs /var/www/${HTMLY_DOMAIN_NAME}/previous
fi fi
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}/
if [ ! "$?" = "0" ]; then if [ ! "$?" = "0" ]; then
if [ -d /var/www/${HTMLY_DOMAIN_NAME}/previous ]; then
mv /var/www/${HTMLY_DOMAIN_NAME}/previous /var/www/${HTMLY_DOMAIN_NAME}/htdocs
fi
set_user_permissions set_user_permissions
backup_unmount_drive backup_unmount_drive
exit 593 exit 593
@ -288,11 +293,17 @@ function restore_remote_htmly {
function_check restore_directory_from_friend function_check restore_directory_from_friend
restore_directory_from_friend $temp_restore_dir htmly restore_directory_from_friend $temp_restore_dir htmly
if [ -d /var/www/${HTMLY_DOMAIN_NAME}/htdocs ]; then if [ -d /var/www/${HTMLY_DOMAIN_NAME}/htdocs ]; then
rm -rf /var/www/${HTMLY_DOMAIN_NAME}/htdocs if [ -d /var/www/${HTMLY_DOMAIN_NAME}/previous ]; then
rm -rf /var/www/${HTMLY_DOMAIN_NAME}/previous
fi
mv /var/www/${HTMLY_DOMAIN_NAME}/htdocs /var/www/${HTMLY_DOMAIN_NAME}/previous
fi fi
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}/
if [ ! "$?" = "0" ]; then if [ ! "$?" = "0" ]; then
if [ -d /var/www/${HTMLY_DOMAIN_NAME}/previous ]; then
mv /var/www/${HTMLY_DOMAIN_NAME}/previous /var/www/${HTMLY_DOMAIN_NAME}/htdocs
fi
exit 593 exit 593
fi fi
rm -rf ${temp_restore_dir} rm -rf ${temp_restore_dir}

View File

@ -125,6 +125,9 @@ function restore_local_mailpile {
cp -r ${temp_source_dir} /var/www/${MAILPILE_DOMAIN_NAME}/mail/ cp -r ${temp_source_dir} /var/www/${MAILPILE_DOMAIN_NAME}/mail/
if [ ! "$?" = "0" ]; then if [ ! "$?" = "0" ]; then
if [ -d mv /var/www/${MAILPILE_DOMAIN_NAME}/mail/.previous ]; then if [ -d mv /var/www/${MAILPILE_DOMAIN_NAME}/mail/.previous ]; then
if [ -d /var/www/${MAILPILE_DOMAIN_NAME}/mail/.previous ]; then
rm -rf /var/www/${MAILPILE_DOMAIN_NAME}/mail/.previous
fi
mv /var/www/${MAILPILE_DOMAIN_NAME}/mail/.previous /var/www/${MAILPILE_DOMAIN_NAME}/mail/.local mv /var/www/${MAILPILE_DOMAIN_NAME}/mail/.previous /var/www/${MAILPILE_DOMAIN_NAME}/mail/.local
fi fi
backup_unmount_drive backup_unmount_drive