Skip to content
Snippets Groups Projects
Commit 73cfa413 authored by Bob Mottram's avatar Bob Mottram
Browse files

Backup only the necessary postactiv data

Not all the files
parent 9030522b
No related branches found
No related tags found
No related merge requests found
...@@ -391,21 +391,31 @@ function backup_local_postactiv { ...@@ -391,21 +391,31 @@ function backup_local_postactiv {
POSTACTIV_DOMAIN_NAME=$(get_completion_param "postactiv domain") POSTACTIV_DOMAIN_NAME=$(get_completion_param "postactiv domain")
fi fi
source_directory=/var/www/${POSTACTIV_DOMAIN_NAME}/htdocs source_directory=/var/www/${POSTACTIV_DOMAIN_NAME}/htdocs/backup
if [ -d $source_directory ]; then if [ ! -d $source_directory ]; then
dest_directory=postactiv mkdir $source_directory
function_check suspend_site fi
suspend_site ${POSTACTIV_DOMAIN_NAME} cp -p /var/www/${POSTACTIV_DOMAIN_NAME}/htdocs/config.php $source_directory
if [ -d /var/www/${POSTACTIV_DOMAIN_NAME}/htdocs/static ]; then
cp -rp /var/www/${POSTACTIV_DOMAIN_NAME}/htdocs/static $source_directory
fi
function_check backup_directory_to_usb function_check suspend_site
backup_directory_to_usb $source_directory $dest_directory suspend_site ${POSTACTIV_DOMAIN_NAME}
function_check backup_database_to_usb function_check backup_directory_to_usb
backup_database_to_usb postactiv dest_directory=postactivconfig
backup_directory_to_usb $source_directory $dest_directory
function_check restart_site source_directory=/var/www/${POSTACTIV_DOMAIN_NAME}/htdocs/file
restart_site dest_directory=postactivfile
fi backup_directory_to_usb $source_directory $dest_directory
function_check backup_database_to_usb
backup_database_to_usb postactiv
function_check restart_site
restart_site
} }
function restore_local_postactiv { function restore_local_postactiv {
...@@ -414,6 +424,7 @@ function restore_local_postactiv { ...@@ -414,6 +424,7 @@ function restore_local_postactiv {
fi fi
POSTACTIV_DOMAIN_NAME=$(get_completion_param "postactiv domain") POSTACTIV_DOMAIN_NAME=$(get_completion_param "postactiv domain")
if [ $POSTACTIV_DOMAIN_NAME ]; then if [ $POSTACTIV_DOMAIN_NAME ]; then
echo $"Restoring postactiv"
temp_restore_dir=/root/temppostactiv temp_restore_dir=/root/temppostactiv
postactiv_dir=/var/www/${POSTACTIV_DOMAIN_NAME}/htdocs postactiv_dir=/var/www/${POSTACTIV_DOMAIN_NAME}/htdocs
# stop the daemons # stop the daemons
...@@ -423,55 +434,109 @@ function restore_local_postactiv { ...@@ -423,55 +434,109 @@ function restore_local_postactiv {
function_check postactiv_create_database function_check postactiv_create_database
postactiv_create_database postactiv_create_database
restore_database postactiv ${POSTACTIV_DOMAIN_NAME} restore_database postactiv
if [ -d $temp_restore_dir ]; then
rm -rf $temp_restore_dir
fi
function_check restore_directory_from_usb
restore_directory_from_usb $temp_restore_dir postactivconfig
if [ -d $temp_restore_dir ]; then if [ -d $temp_restore_dir ]; then
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/
chown -R www-data:www-data $postactiv_dir/static
rm -rf $temp_restore_dir
fi
restore_directory_from_usb $temp_restore_dir postactivfile
if [ -d $temp_restore_dir ]; then
cp -rp $temp_restore_dir$postactiv_dir/file $postactiv_dir/
chown -R www-data:www-data $postactiv_dir/file
rm -rf $temp_restore_dir rm -rf $temp_restore_dir
fi fi
gnusocial_update_after_restore postactiv ${POSTACTIV_DOMAIN_NAME} gnusocial_update_after_restore postactiv ${POSTACTIV_DOMAIN_NAME}
echo $"Restore of postactiv complete"
fi fi
} }
function backup_remote_postactiv { function backup_remote_postactiv {
POSTACTIV_DOMAIN_NAME='postactiv'
if grep -q "postactiv domain" $COMPLETION_FILE; then if grep -q "postactiv domain" $COMPLETION_FILE; then
POSTACTIV_DOMAIN_NAME=$(get_completion_param "postactiv domain") POSTACTIV_DOMAIN_NAME=$(get_completion_param "postactiv domain")
temp_backup_dir=/var/www/${POSTACTIV_DOMAIN_NAME}/htdocs fi
if [ -d $temp_backup_dir ]; then
function_check suspend_site
suspend_site ${POSTACTIV_DOMAIN_NAME}
function_check backup_database_to_friend source_directory=/var/www/${POSTACTIV_DOMAIN_NAME}/htdocs/backup
backup_database_to_friend postactiv if [ ! -d $source_directory ]; then
mkdir $source_directory
fi
cp -p /var/www/${POSTACTIV_DOMAIN_NAME}/htdocs/config.php $source_directory
if [ -d /var/www/${POSTACTIV_DOMAIN_NAME}/htdocs/static ]; then
cp -rp /var/www/${POSTACTIV_DOMAIN_NAME}/htdocs/static $source_directory
fi
function_check backup_directory_to_friend function_check suspend_site
backup_directory_to_friend $temp_backup_dir postactiv suspend_site ${POSTACTIV_DOMAIN_NAME}
function_check restart_site function_check backup_directory_to_friend
restart_site dest_directory=postactivconfig
else backup_directory_to_friend $source_directory $dest_directory
echo $"postactiv domain specified but not found in ${temp_backup_dir}"
fi source_directory=/var/www/${POSTACTIV_DOMAIN_NAME}/htdocs/file
fi dest_directory=postactivfile
backup_directory_to_friend $source_directory $dest_directory
function_check backup_database_to_friend
backup_database_to_friend postactiv
function_check restart_site
restart_site
} }
function restore_remote_postactiv { function restore_remote_postactiv {
if grep -q "postactiv domain" $COMPLETION_FILE; then if ! grep -q "postactiv domain" $COMPLETION_FILE; then
POSTACTIV_DOMAIN_NAME=$(get_completion_param "postactiv domain") return
fi
POSTACTIV_DOMAIN_NAME=$(get_completion_param "postactiv domain")
if [ $POSTACTIV_DOMAIN_NAME ]; then
echo $"Restoring postactiv"
temp_restore_dir=/root/temppostactiv
postactiv_dir=/var/www/${POSTACTIV_DOMAIN_NAME}/htdocs
# stop the daemons # stop the daemons
cd /var/www/${POSTACTIV_DOMAIN_NAME}/htdocs cd $postactiv_dir
scripts/stopdaemons.sh scripts/stopdaemons.sh
function_check postactiv_create_database function_check postactiv_create_database
postactiv_create_database postactiv_create_database
function_check restore_database_from_friend function_check restore_database_from_friend
restore_database_from_friend postactiv ${POSTACTIV_DOMAIN_NAME} restore_database_from_friend postactiv
if [ -d /root/temppostactiv ]; then if [ -d $temp_restore_dir ]; then
rm -rf /root/temppostactiv rm -rf $temp_restore_dir
fi
function_check restore_directory_from_friend
restore_directory_from_friend $temp_restore_dir postactivconfig
if [ -d $temp_restore_dir ]; then
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/
chown -R www-data:www-data $postactiv_dir/static
rm -rf $temp_restore_dir
fi
restore_directory_from_friend $temp_restore_dir postactivfile
if [ -d $temp_restore_dir ]; then
cp -rp $temp_restore_dir$postactiv_dir/file $postactiv_dir/
chown -R www-data:www-data $postactiv_dir/file
rm -rf $temp_restore_dir
fi fi
gnusocial_update_after_restore postactiv ${POSTACTIV_DOMAIN_NAME} gnusocial_update_after_restore postactiv ${POSTACTIV_DOMAIN_NAME}
echo $"Restore of postactiv complete"
fi fi
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment