From 51525a41dd2a1468c99a046ed4248cedf4504fb4 Mon Sep 17 00:00:00 2001 From: Alexandre Aubin Date: Thu, 7 May 2020 02:13:54 +0200 Subject: [PATCH 1/4] It shouldn't be the default to start/stop service during backup declarations.. --- scripts/backup | 12 ------------ 1 file changed, 12 deletions(-) diff --git a/scripts/backup b/scripts/backup index d985aba..7af1586 100755 --- a/scripts/backup +++ b/scripts/backup @@ -35,11 +35,6 @@ db_name=$(ynh_app_setting_get --app=$app --key=db_name) #================================================= # STANDARD BACKUP STEPS #================================================= -# STOP SYSTEMD SERVICE -#================================================= -ynh_script_progression --message="Stopping a systemd service..." --time --weight=1 - -ynh_systemd_action --service_name=$app --action="stop" --log_path="/var/log/$app/$app.log" #================================================= # BACKUP THE APP MAIN DIR @@ -99,13 +94,6 @@ ynh_backup --src_path="/etc/systemd/system/$app.service" ynh_backup --src_path="/etc/cron.d/$app" -#================================================= -# START SYSTEMD SERVICE -#================================================= -ynh_script_progression --message="Starting a systemd service..." --time --weight=1 - -ynh_systemd_action --service_name=$app --action="start" --log_path="/var/log/$app/$app.log" - #================================================= # END OF SCRIPT #================================================= From 961694bbf55de22e55807e75c4ea5570ef3dbac1 Mon Sep 17 00:00:00 2001 From: Alexandre Aubin Date: Thu, 7 May 2020 02:23:17 +0200 Subject: [PATCH 2/4] Add explanation about ynh_backup, remove progress bars and move mysqldump to the end --- scripts/backup | 37 +++++++++++++++++++++---------------- 1 file changed, 21 insertions(+), 16 deletions(-) diff --git a/scripts/backup b/scripts/backup index 7af1586..5c78747 100755 --- a/scripts/backup +++ b/scripts/backup @@ -24,7 +24,7 @@ ynh_abort_if_errors #================================================= # LOAD SETTINGS #================================================= -ynh_script_progression --message="Loading installation settings..." --time --weight=1 +ynh_print_info --message="Loading installation settings..." app=$YNH_APP_INSTANCE_NAME @@ -33,41 +33,37 @@ domain=$(ynh_app_setting_get --app=$app --key=domain) db_name=$(ynh_app_setting_get --app=$app --key=db_name) #================================================= -# STANDARD BACKUP STEPS +# DECLARE DATA AND CONF FILES TO BACKUP #================================================= +ynh_print_info --message="Declaring files to be backuped..." + +# N.B. : the following 'ynh_backup' calls are only a *declaration* of what needs +# to be backuped and not an actual copy of any file. The actual backup that +# creates and fill the archive with the files happens in the core after this +# script is called. Hence ynh_backups calls takes basically 0 seconds to run. + #================================================= # BACKUP THE APP MAIN DIR #================================================= -ynh_script_progression --message="Backing up the main app directory..." --time --weight=1 ynh_backup --src_path="$final_path" #================================================= # BACKUP THE NGINX CONFIGURATION #================================================= -ynh_script_progression --message="Backing up nginx web server configuration..." --time --weight=1 ynh_backup --src_path="/etc/nginx/conf.d/$domain.d/$app.conf" #================================================= # BACKUP THE PHP-FPM CONFIGURATION #================================================= -ynh_script_progression --message="Backing up php-fpm configuration..." --time --weight=1 ynh_backup --src_path="/etc/php/7.0/fpm/pool.d/$app.conf" -#================================================= -# BACKUP THE MYSQL DATABASE -#================================================= -ynh_script_progression --message="Backing up the MySQL database..." --time --weight=1 - -ynh_mysql_dump_db --database="$db_name" > db.sql - #================================================= # BACKUP FAIL2BAN CONFIGURATION #================================================= -ynh_script_progression --message="Backing up fail2ban configuration..." --time --weight=1 ynh_backup --src_path="/etc/fail2ban/jail.d/$app.conf" ynh_backup --src_path="/etc/fail2ban/filter.d/$app.conf" @@ -77,14 +73,12 @@ ynh_backup --src_path="/etc/fail2ban/filter.d/$app.conf" #================================================= # BACKUP LOGROTATE #================================================= -ynh_script_progression --message="Backing up logrotate configuration..." --time --weight=1 ynh_backup --src_path="/etc/logrotate.d/$app" #================================================= # BACKUP SYSTEMD #================================================= -ynh_script_progression --message="Backing up systemd configuration..." --time --weight=1 ynh_backup --src_path="/etc/systemd/system/$app.service" @@ -94,8 +88,19 @@ ynh_backup --src_path="/etc/systemd/system/$app.service" ynh_backup --src_path="/etc/cron.d/$app" +#================================================= +# BACKUP THE MYSQL DATABASE +#================================================= + +ynh_print_info --message="Backing up the database..." + +# (However, things like mysql dumps *do* take some time to run, though the +# copy of the generated dump to the archive still happens later) + +ynh_mysql_dump_db --database="$db_name" > db.sql + #================================================= # END OF SCRIPT #================================================= -ynh_script_progression --message="Backup script completed for $app. (YunoHost will then actually copy those files to the archive)." --time --last +ynh_print_info --message="Backup script completed for $app. (YunoHost will then actually copy those files to the archive)." --time --last From d8cff1c3cac195b0ae47b5eaae73d345a4f298f8 Mon Sep 17 00:00:00 2001 From: "ljf (zamentur)" Date: Thu, 7 May 2020 19:34:39 +0200 Subject: [PATCH 3/4] [fix] Unused option --- scripts/backup | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/backup b/scripts/backup index 5c78747..e33ae61 100755 --- a/scripts/backup +++ b/scripts/backup @@ -103,4 +103,4 @@ ynh_mysql_dump_db --database="$db_name" > db.sql # END OF SCRIPT #================================================= -ynh_print_info --message="Backup script completed for $app. (YunoHost will then actually copy those files to the archive)." --time --last +ynh_print_info --message="Backup script completed for $app. (YunoHost will then actually copy those files to the archive)." From 6a9368b635e3d59403af717952ac9da6279ada0a Mon Sep 17 00:00:00 2001 From: Alexandre Aubin Date: Mon, 25 May 2020 18:50:37 +0200 Subject: [PATCH 4/4] Update scripts/backup Co-authored-by: JimboJoe --- scripts/backup | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/backup b/scripts/backup index e33ae61..233936f 100755 --- a/scripts/backup +++ b/scripts/backup @@ -36,7 +36,7 @@ db_name=$(ynh_app_setting_get --app=$app --key=db_name) # DECLARE DATA AND CONF FILES TO BACKUP #================================================= -ynh_print_info --message="Declaring files to be backuped..." +ynh_print_info --message="Declaring files to be backed up..." # N.B. : the following 'ynh_backup' calls are only a *declaration* of what needs # to be backuped and not an actual copy of any file. The actual backup that