From ac656c0f20e4254e0a64a697b012274609bc592b Mon Sep 17 00:00:00 2001 From: orhtej2 <2871798+orhtej2@users.noreply.github.com> Date: Sat, 21 Oct 2023 23:45:57 +0200 Subject: [PATCH] Fix backup and restore. --- scripts/backup | 26 ++++---------------------- scripts/restore | 26 ++++++++++---------------- 2 files changed, 14 insertions(+), 38 deletions(-) diff --git a/scripts/backup b/scripts/backup index 4eca8dd..6d7c8b0 100644 --- a/scripts/backup +++ b/scripts/backup @@ -1,8 +1,5 @@ #!/bin/bash -#### App file generated with YoloGen, the Yunohost app generator, version 0.6.5. -# This is the tutorial version of the app. -# It contains extra commands to explain what should be done in case you want to adjust some part of the script. -# Once you are done, you may remove them. + #================================================= # GENERIC START #================================================= @@ -18,10 +15,6 @@ source /usr/share/yunohost/helpers #================================================= 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 -### 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 #================================================= @@ -34,12 +27,6 @@ ynh_backup --src_path="$install_dir" ynh_backup --src_path="/etc/nginx/conf.d/$domain.d/$app.conf" -#================================================= -# BACKUP FAIL2BAN CONFIGURATION -#================================================= - -ynh_backup --src_path="/etc/fail2ban/jail.d/$app.conf" -ynh_backup --src_path="/etc/fail2ban/filter.d/$app.conf" #================================================= # SPECIFIC BACKUP #================================================= @@ -47,19 +34,12 @@ ynh_backup --src_path="/etc/fail2ban/filter.d/$app.conf" #================================================= ynh_backup --src_path="/etc/logrotate.d/$app" + #================================================= # BACKUP SYSTEMD #================================================= ynh_backup --src_path="/etc/systemd/system/$app.service" -#================================================= -# BACKUP VARIOUS FILES -#================================================= - -ynh_backup --src_path="/etc/cron.d/$app" - -ynh_backup --src_path="/etc/$app/" - #================================================= # BACKUP THE DATABASE @@ -70,6 +50,8 @@ ynh_print_info --message="Backing up the mysql database..." ### copy of the generated dump to the archive still happens later) ynh_mysql_dump_db --database="$db_name" > db.sql +ynh_mysql_dump_db --database="$db_name_tokenserver" > db_tokenserver.sql + #================================================= # END OF SCRIPT #================================================= diff --git a/scripts/restore b/scripts/restore index 0714e5f..1e262c8 100644 --- a/scripts/restore +++ b/scripts/restore @@ -1,8 +1,5 @@ #!/bin/bash -#### App file generated with YoloGen, the Yunohost app generator, version 0.6.5. -# This is the tutorial version of the app. -# It contains extra commands to explain what should be done in case you want to adjust some part of the script. -# Once you are done, you may remove them. + #================================================= # GENERIC START #================================================= @@ -20,18 +17,22 @@ ynh_script_progression --message="Restoring the app main directory..." --weight= ynh_restore_file --origin_path="$install_dir" -# $install_dir will automatically be initialized with some decent -# permission by default ... however, you may need to recursively reapply -# ownership to all files such as after the ynh_setup_source step chown -R $app:www-data "$install_dir" #================================================= # RESTORE THE MYSQL DATABASE #================================================= - ynh_script_progression --message="Restoring the MySQL database..." --weight=1 +ynh_script_progression --message="Restoring the MySQL database..." --weight=1 ynh_mysql_connect_as --user=$db_user --password=$db_pwd --database=$db_name < ./db.sql - #================================================= + +ynh_mysql_connect_as --user=$db_user --password=$db_pwd --database=$db_name < ./db.sql + +ynh_script_progression --message="Restoring tokenserver database..." --weight=1 +ynh_mysql_create_db "$db_name_tokenserver" "$db_user" "$db_pwd" +ynh_mysql_connect_as --user=$db_user --password=$db_pwd --database=$db_name_tokenserver < ./db_tokenserver.sql + +#================================================= # RESTORE SYSTEM CONFIGURATIONS #================================================= # RESTORE THE PHP-FPM CONFIGURATION @@ -47,13 +48,6 @@ systemctl enable $app.service --quiet yunohost service add $app --description="Firefox Sync Server (Rust)" --log="/var/log/$app/$app.log" ynh_restore_file --origin_path="/etc/logrotate.d/$app" -ynh_restore_file --origin_path="/etc/fail2ban/jail.d/$app.conf" -ynh_restore_file --origin_path="/etc/fail2ban/filter.d/$app.conf" -ynh_systemd_action --action=restart --service_name=fail2ban -# Other various files... - -ynh_restore_file --origin_path="/etc/cron.d/$app" -ynh_restore_file --origin_path="/etc/$app/" #================================================= # GENERIC FINALIZATION