From 990c6f8ceb20d01471bf83f8975e69d106ee1022 Mon Sep 17 00:00:00 2001 From: Glyn Hudson Date: Fri, 22 Jun 2018 00:28:59 +0000 Subject: [PATCH 1/6] show verbose output during backup --- emoncms-export.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/emoncms-export.sh b/emoncms-export.sh index 45f9f54..2ffdbe1 100755 --- a/emoncms-export.sh +++ b/emoncms-export.sh @@ -17,7 +17,7 @@ then else echo "ERROR: Backup /home/pi/backup/config.cfg file does not exist" exit 1 -fi +fi #----------------------------------------------------------------------------------------------- # Remove Old backup files @@ -82,7 +82,7 @@ echo "Emoncms MYSQL database dump complete, adding files to archive .." tar -cf $backup_location/emoncms-backup-$date.tar $backup_location/emoncms.sql $emonhub_config_path/emonhub.conf $emoncms_config_path/emoncms.conf $emoncms_location/settings.php /home/pi/data/node-red/flows_emonpi.json /home/pi/data/node-red/flows_emonpi_cred.json /home/pi/data/node-red/settings.js --transform 's?.*/??g' # Append database folder to the archive with absolute path -tar --append --file=$backup_location/emoncms-backup-$date.tar -C $mysql_path phpfina phptimeseries +tar -vr --file=$backup_location/emoncms-backup-$date.tar -C $mysql_path phpfina phptimeseries # Compress backup echo "Compressing archive..." From c6ca17aacc836a7e7052bcd84595f3f5e0694b0d Mon Sep 17 00:00:00 2001 From: Glyn Hudson Date: Fri, 22 Jun 2018 00:38:28 +0000 Subject: [PATCH 2/6] more detail log and restart feedwritier if errored exit --- emoncms-export.sh | 7 +++++-- emoncms-import.sh | 2 +- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/emoncms-export.sh b/emoncms-export.sh index 2ffdbe1..12fef0d 100755 --- a/emoncms-export.sh +++ b/emoncms-export.sh @@ -17,6 +17,7 @@ then else echo "ERROR: Backup /home/pi/backup/config.cfg file does not exist" exit 1 + sudo service feedwriter start > /dev/null fi #----------------------------------------------------------------------------------------------- @@ -65,6 +66,7 @@ if [ -f /home/pi/backup/get_emoncms_mysql_auth.php ]; then else echo "Error: cannot read MYSQL authentication details from Emoncms settings.php" echo "$PWD" + sudo service feedwriter start > /dev/null exit 1 fi @@ -73,10 +75,11 @@ if [ -n "$username" ]; then # if username sring is not empty mysqldump -u$username -p$password emoncms > $backup_location/emoncms.sql else echo "Error: Cannot read MYSQL authentication details from Emoncms settings.php" + sudo service feedwriter start > /dev/null exit 1 fi -echo "Emoncms MYSQL database dump complete, adding files to archive .." +echo "Emoncms MYSQL database dump complete, adding files to archive..." # Create backup archive and add config files stripping out the path tar -cf $backup_location/emoncms-backup-$date.tar $backup_location/emoncms.sql $emonhub_config_path/emonhub.conf $emoncms_config_path/emoncms.conf $emoncms_location/settings.php /home/pi/data/node-red/flows_emonpi.json /home/pi/data/node-red/flows_emonpi_cred.json /home/pi/data/node-red/settings.js --transform 's?.*/??g' @@ -86,7 +89,7 @@ tar -vr --file=$backup_location/emoncms-backup-$date.tar -C $mysql_path phpfina # Compress backup echo "Compressing archive..." -gzip -f $backup_location/emoncms-backup-$date.tar +gzip -fv $backup_location/emoncms-backup-$date.tar sudo service feedwriter start > /dev/null diff --git a/emoncms-import.sh b/emoncms-import.sh index 819beca..61c9a5d 100755 --- a/emoncms-import.sh +++ b/emoncms-import.sh @@ -80,7 +80,7 @@ if [ ! -d $backup_location/import ]; then sudo chown pi $backup_location/import -R fi -tar xfz $backup_source_path/$backup_filename -C $backup_location/import 2>&1 +tar xfzv $backup_source_path/$backup_filename -C $backup_location/import 2>&1 if [ $? -ne 0 ]; then echo "Error: failed to decompress backup" echo "$backup_source_path/$backup_filename has not been removed for diagnotics" From 9f2685804ef78d27166b2e20bc2cc5d8d5b691a7 Mon Sep 17 00:00:00 2001 From: Glyn Hudson Date: Sat, 23 Jun 2018 16:28:17 +0000 Subject: [PATCH 3/6] use redis service runner for import --- backup/backup_controller.php | 10 +--------- 1 file changed, 1 insertion(+), 9 deletions(-) diff --git a/backup/backup_controller.php b/backup/backup_controller.php index f9bcea4..b901f53 100644 --- a/backup/backup_controller.php +++ b/backup/backup_controller.php @@ -81,15 +81,7 @@ function backup_controller() if ((move_uploaded_file($_FILES['file']['tmp_name'], $target_path)) && ($uploadOk == 1)) { - $fh = @fopen($import_flag,"w"); - if (!$fh) { - $result = "ERROR: Can't write the flag $import_flag."; - } else { - fwrite($fh,"$import_script>$import_logfile"); - $result = "Backup flag set"; - } - @fclose($fh); - + $redis->rpush("service-runner","$import_script $import_flag>$import_logfile"); header('Location: '.$path.'backup'); } else { $result = "Sorry, there was an error uploading the file"; From 6afabb9fe56fbf55a0d8a0ee237a8ccee90ffb82 Mon Sep 17 00:00:00 2001 From: Glyn Hudson Date: Sat, 23 Jun 2018 16:37:57 +0000 Subject: [PATCH 4/6] readme update fix #5 --- readme.md | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/readme.md b/readme.md index 446563f..33baf65 100644 --- a/readme.md +++ b/readme.md @@ -1,4 +1,3 @@ - ## Emoncms backup export and import tool for backup and migration * Export a compressed archive containing Emoncms Inputs, Feed data, Dashboards & config. @@ -48,7 +47,10 @@ Follow on screen prompts, RasPi will shutdown when process is compleate. It can git clone https://github.com/emoncms/backup.git ln -s /home/pi/backup/backup/ /var/www/emoncms/Modules/backup -**Note: Ensure you are running the latest version of Emoncms on the Stable branch. [A change was merged on the 9th Feb 16 to Emoncms core](https://github.com/emoncms/emoncms/commit/e83ad78e6155275d7537104367b8d44ef63d78fe) that enables symlinked modules which is essential for backup module to appear in Emoncms** +**Note: + +- Ensure you are running the latest version of Emoncms on the Stable branch. [A change was merged on the 9th Feb 16 to Emoncms core](https://github.com/emoncms/emoncms/commit/e83ad78e6155275d7537104367b8d44ef63d78fe) that enables symlinked modules which is essential for backup module to appear in Emoncms** +- As of June 18 Backup module requires Redis to set service runner flags **If your running the older 'low-write' branch of Emoncms emonSD-17Jun15 or before then you won't be able to update to the latest version to enable symlinks, to get around this after installing the module browse to [http://emonpi/emoncms/backup](http://emonpi/emoncms/backup)** @@ -74,14 +76,20 @@ or saving log in var log In order to enable uploads of backup zip files we need to set the maximum upload size to be larger than the file we want to upload. This can be set system wide in `/etc/php5/apache2/php.ini`: +If using php5 + sudo nano /etc/php5/apache2/php.ini +if using php7 + + sudo nano /etc/php/7.0/apache2/php.ini + Use `[CTRL + W]` to search test Set: - post_max_size = 200M - upload_max_filesize = 200M + post_max_size = 3G + upload_max_filesize = 3G # Create uploads folder From 06e2f446e8d672395f1e1426e6f608dc15a96972 Mon Sep 17 00:00:00 2001 From: Glyn Hudson Date: Sat, 23 Jun 2018 16:28:17 +0000 Subject: [PATCH 5/6] use redis service runner for import --- backup/backup_controller.php | 10 +--------- 1 file changed, 1 insertion(+), 9 deletions(-) diff --git a/backup/backup_controller.php b/backup/backup_controller.php index f9bcea4..b901f53 100644 --- a/backup/backup_controller.php +++ b/backup/backup_controller.php @@ -81,15 +81,7 @@ function backup_controller() if ((move_uploaded_file($_FILES['file']['tmp_name'], $target_path)) && ($uploadOk == 1)) { - $fh = @fopen($import_flag,"w"); - if (!$fh) { - $result = "ERROR: Can't write the flag $import_flag."; - } else { - fwrite($fh,"$import_script>$import_logfile"); - $result = "Backup flag set"; - } - @fclose($fh); - + $redis->rpush("service-runner","$import_script $import_flag>$import_logfile"); header('Location: '.$path.'backup'); } else { $result = "Sorry, there was an error uploading the file"; From 7c317e64b50898ca8cdc344756b65e6f133246e4 Mon Sep 17 00:00:00 2001 From: Glyn Hudson Date: Sat, 23 Jun 2018 16:37:57 +0000 Subject: [PATCH 6/6] readme update fix #5 --- readme.md | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/readme.md b/readme.md index 446563f..33baf65 100644 --- a/readme.md +++ b/readme.md @@ -1,4 +1,3 @@ - ## Emoncms backup export and import tool for backup and migration * Export a compressed archive containing Emoncms Inputs, Feed data, Dashboards & config. @@ -48,7 +47,10 @@ Follow on screen prompts, RasPi will shutdown when process is compleate. It can git clone https://github.com/emoncms/backup.git ln -s /home/pi/backup/backup/ /var/www/emoncms/Modules/backup -**Note: Ensure you are running the latest version of Emoncms on the Stable branch. [A change was merged on the 9th Feb 16 to Emoncms core](https://github.com/emoncms/emoncms/commit/e83ad78e6155275d7537104367b8d44ef63d78fe) that enables symlinked modules which is essential for backup module to appear in Emoncms** +**Note: + +- Ensure you are running the latest version of Emoncms on the Stable branch. [A change was merged on the 9th Feb 16 to Emoncms core](https://github.com/emoncms/emoncms/commit/e83ad78e6155275d7537104367b8d44ef63d78fe) that enables symlinked modules which is essential for backup module to appear in Emoncms** +- As of June 18 Backup module requires Redis to set service runner flags **If your running the older 'low-write' branch of Emoncms emonSD-17Jun15 or before then you won't be able to update to the latest version to enable symlinks, to get around this after installing the module browse to [http://emonpi/emoncms/backup](http://emonpi/emoncms/backup)** @@ -74,14 +76,20 @@ or saving log in var log In order to enable uploads of backup zip files we need to set the maximum upload size to be larger than the file we want to upload. This can be set system wide in `/etc/php5/apache2/php.ini`: +If using php5 + sudo nano /etc/php5/apache2/php.ini +if using php7 + + sudo nano /etc/php/7.0/apache2/php.ini + Use `[CTRL + W]` to search test Set: - post_max_size = 200M - upload_max_filesize = 200M + post_max_size = 3G + upload_max_filesize = 3G # Create uploads folder