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

Local backup function for blog

parent f17bdebb
No related branches found
No related tags found
No related merge requests found
......@@ -47,11 +47,31 @@ function upgrade_blog {
}
function backup_local_blog {
echo ''
FULLBLOG_DOMAIN_NAME='blog'
if grep -q "Blog domain" $COMPLETION_FILE; then
FULLBLOG_DOMAIN_NAME=$(cat $COMPLETION_FILE | grep "Blog domain" | awk -F ':' '{print $2}')
fi
source_directory=/var/www/${FULLBLOG_DOMAIN_NAME}/htdocs
if [ -d $source_directory ]; then
dest_directory=blog
echo $"Backing up $source_directory to $dest_directory"
function_check suspend_site
suspend_site ${FULLBLOG_DOMAIN_NAME}
function_check backup_directory_to_usb
backup_directory_to_usb $source_directory $dest_directory
function_check restart_site
restart_site
echo $"Backup to $dest_directory complete"
fi
}
function backup_remote_blog {
echo ''
echo ''
}
function remove_blog {
......
......@@ -31,11 +31,18 @@
PROJECT_NAME='freedombone'
COMPLETION_FILE=$HOME/${PROJECT_NAME}-completed.txt
BACKUP_EXTRA_DIRECTORIES=/root/backup-extra-dirs.csv
ENABLE_VERIFICATION="no"
ENABLE_BACKUP_VERIFICATION="no"
export TEXTDOMAIN=${PROJECT_NAME}-backup-local
export TEXTDOMAINDIR="/usr/share/locale"
# include utils which allow function_check
UTILS_FILES=/usr/share/${PROJECT_NAME}/utils/${PROJECT_NAME}-utils-*
for f in $UTILS_FILES
do
source $f
done
USB_DRIVE=/dev/sdb1
USB_MOUNT=/mnt/usb
......@@ -63,26 +70,6 @@ if [ -f /root/dbpass ]; then
DATABASE_PASSWORD=$(cat /root/dbpass)
fi
function suspend_site {
# suspends a given website
if [[ $ENABLE_VERIFICATION != "yes" ]]; then
return
fi
SUSPENDED_SITE="$1"
nginx_dissite $SUSPENDED_SITE
service nginx reload
}
function restart_site {
# restarts a given website
if [ ! $SUSPENDED_SITE ]; then
return
fi
nginx_ensite $SUSPENDED_SITE
service nginx reload
SUSPENDED_SITE=
}
function update_domains {
RSS_READER_DOMAIN_NAME='ttrss'
if grep -q "RSS reader domain" $COMPLETION_FILE; then
......@@ -214,7 +201,7 @@ function backup_directory_to_usb {
fi
obnam force-lock -r $USB_MOUNT/backup/${2} --encrypt-with $MY_BACKUP_KEY_ID ${1}
obnam backup -r $USB_MOUNT/backup/${2} --encrypt-with $MY_BACKUP_KEY_ID ${1}
if [[ $ENABLE_VERIFICATION == "yes" ]]; then
if [[ $ENABLE_BACKUP_VERIFICATION == "yes" ]]; then
obnam verify -r $USB_MOUNT/backup/${2} --encrypt-with $MY_BACKUP_KEY_ID ${1}
if [ ! "$?" = "0" ]; then
umount $USB_MOUNT
......
......@@ -53,6 +53,9 @@ MAX_PHP_MEMORY=64
# logging level for Nginx
WEBSERVER_LOG_LEVEL='warn'
# whether a given site is being suspended during backup
SUSPENDED_SITE=
# test a domain name to see if it's valid
function validate_domain_name {
# count the number of dots in the domain name
......@@ -548,4 +551,21 @@ function install_command_line_browser {
echo 'install_command_line_browser' >> $COMPLETION_FILE
}
function suspend_site {
# suspends a given website
SUSPENDED_SITE="$1"
nginx_dissite $SUSPENDED_SITE
service nginx reload
}
function restart_site {
# restarts a given website
if [ ! $SUSPENDED_SITE ]; then
return
fi
nginx_ensite $SUSPENDED_SITE
service nginx reload
SUSPENDED_SITE=
}
# NOTE: deliberately no exit 0
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