From 5acbc674605e58105094e9a593dc0e7690b23ca8 Mon Sep 17 00:00:00 2001 From: Bob Mottram Date: Mon, 20 Nov 2017 11:15:54 +0000 Subject: [PATCH] Backup and restore files containing list of mongodb apps --- src/freedombone-backup-local | 4 ++++ src/freedombone-backup-remote | 4 ++++ src/freedombone-restore-local | 11 +++++++++++ src/freedombone-restore-remote | 10 ++++++++++ src/freedombone-utils-mongodb | 2 +- 5 files changed, 30 insertions(+), 1 deletion(-) diff --git a/src/freedombone-backup-local b/src/freedombone-backup-local index 59e12d85..b324a444 100755 --- a/src/freedombone-backup-local +++ b/src/freedombone-backup-local @@ -31,6 +31,7 @@ PROJECT_NAME='freedombone' COMPLETION_FILE=$HOME/${PROJECT_NAME}-completed.txt CONFIGURATION_FILE=$HOME/${PROJECT_NAME}.cfg +MONGODB_APPS_FILE=$HOME/.mongodbapps BACKUP_EXTRA_DIRECTORIES=/root/backup-extra-dirs.csv ENABLE_BACKUP_VERIFICATION="no" @@ -296,6 +297,9 @@ function backup_configfiles { if [ -f $BACKUP_EXTRA_DIRECTORIES ]; then cp -f $BACKUP_EXTRA_DIRECTORIES $temp_backup_dir fi + if [ -f $MONGODB_APPS_FILE ]; then + cp -f $MONGODB_APPS_FILE $temp_backup_dir + fi # nginx password hashes if [ -f /etc/nginx/.htpasswd ]; then cp -f /etc/nginx/.htpasswd $temp_backup_dir/htpasswd diff --git a/src/freedombone-backup-remote b/src/freedombone-backup-remote index 6b582549..bb76192c 100755 --- a/src/freedombone-backup-remote +++ b/src/freedombone-backup-remote @@ -31,6 +31,7 @@ PROJECT_NAME='freedombone' COMPLETION_FILE=$HOME/${PROJECT_NAME}-completed.txt CONFIGURATION_FILE=$HOME/${PROJECT_NAME}.cfg +MONGODB_APPS_FILE=$HOME/.mongodbapps BACKUP_EXTRA_DIRECTORIES=/root/backup-extra-dirs.csv ENABLE_VERIFICATION="no" @@ -142,6 +143,9 @@ function backup_configfiles { if [ -f $BACKUP_EXTRA_DIRECTORIES ]; then cp -f $BACKUP_EXTRA_DIRECTORIES $temp_backup_dir fi + if [ -f $MONGODB_APPS_FILE ]; then + cp -f $MONGODB_APPS_FILE $temp_backup_dir + fi # nginx password hashes if [ -f /etc/nginx/.htpasswd ]; then cp -f /etc/nginx/.htpasswd $temp_backup_dir/htpasswd diff --git a/src/freedombone-restore-local b/src/freedombone-restore-local index 75c40db8..bceae807 100755 --- a/src/freedombone-restore-local +++ b/src/freedombone-restore-local @@ -30,6 +30,7 @@ PROJECT_NAME='freedombone' COMPLETION_FILE=$HOME/${PROJECT_NAME}-completed.txt +MONGODB_APPS_FILE=$HOME/.mongodbapps CONFIGURATION_FILE=$HOME/${PROJECT_NAME}.cfg BACKUP_EXTRA_DIRECTORIES=/root/backup-extra-dirs.csv @@ -184,6 +185,16 @@ function restore_configfiles { # fi #fi + if [ -f $temp_restore_dir$MONGODB_APPS_FILE ]; then + cp -f $temp_restore_dir$MONGODB_APPS_FILE $MONGODB_APPS_FILE + if [ ! "$?" = "0" ]; then + set_user_permissions + backup_unmount_drive + rm -rf $temp_restore_dir + exit 859034853 + fi + fi + #if [ -f $CONFIGURATION_FILE ]; then # # install according to the config file # freedombone -c $CONFIGURATION_FILE diff --git a/src/freedombone-restore-remote b/src/freedombone-restore-remote index 6cc18f3b..e6a448dc 100755 --- a/src/freedombone-restore-remote +++ b/src/freedombone-restore-remote @@ -31,6 +31,7 @@ PROJECT_NAME='freedombone' COMPLETION_FILE=$HOME/${PROJECT_NAME}-completed.txt CONFIGURATION_FILE=$HOME/${PROJECT_NAME}.cfg +MONGODB_APPS_FILE=$HOME/.mongodbapps BACKUP_EXTRA_DIRECTORIES=/root/backup-extra-dirs.csv export TEXTDOMAIN=${PROJECT_NAME}-restore-remote @@ -172,6 +173,15 @@ function restore_configfiles { # fi #fi + if [ -f $temp_restore_dir$MONGODB_APPS_FILE ]; then + cp -f $temp_restore_dir$MONGODB_APPS_FILE $MONGODB_APPS_FILE + if [ ! "$?" = "0" ]; then + unmount_drive + rm -rf $temp_restore_dir + exit 7835335 + fi + fi + #if [ -f $CONFIGURATION_FILE ]; then # # install according to the config file # freedombone -c $CONFIGURATION_FILE diff --git a/src/freedombone-utils-mongodb b/src/freedombone-utils-mongodb index 34924519..60cc23b4 100755 --- a/src/freedombone-utils-mongodb +++ b/src/freedombone-utils-mongodb @@ -30,7 +30,7 @@ # Set this when calling backup and restore commands USE_MONGODB= -MONGODB_APPS_FILE=/root/.mongodbapps +MONGODB_APPS_FILE=$HOME/.mongodbapps function store_original_mongodb_password { if [ ! -f /root/.mongodboriginal ]; then