From a448ff2bf04f80eaa45a376c3a7376aebe3d14f1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?F=C3=A9lix=20Pi=C3=A9dallu?= Date: Sat, 2 Sep 2023 18:08:57 +0200 Subject: [PATCH] Add backup/restore scripts --- scripts/backup | 34 ++++++++++++++++++++++++++++++++++ scripts/restore | 38 ++++++++++++++++++++++++++++++++++++++ 2 files changed, 72 insertions(+) create mode 100755 scripts/backup create mode 100755 scripts/restore diff --git a/scripts/backup b/scripts/backup new file mode 100755 index 0000000..52eea5b --- /dev/null +++ b/scripts/backup @@ -0,0 +1,34 @@ +#!/bin/bash + +#================================================= +# GENERIC START +#================================================= +# IMPORT GENERIC HELPERS +#================================================= + +# Keep this path for calling _common.sh inside the execution's context of backup and restore scripts +source ../settings/scripts/_common.sh +source /usr/share/yunohost/helpers + +#================================================= +# DECLARE DATA AND CONF FILES TO BACKUP +#================================================= +ynh_print_info --message="Declaring files to be backed up..." + +#================================================= +# BACKUP THE APP MAIN DIR +#================================================= + +ynh_backup --src_path="$install_dir" + +#================================================= +# BACKUP THE NGINX CONFIGURATION +#================================================= + +ynh_backup --src_path="/etc/nginx/conf.d/$domain.d/$app.conf" + +#================================================= +# END OF SCRIPT +#================================================= + +ynh_print_info --message="Backup script completed for $app. (YunoHost will then actually copy those files to the archive)." diff --git a/scripts/restore b/scripts/restore new file mode 100755 index 0000000..f285c32 --- /dev/null +++ b/scripts/restore @@ -0,0 +1,38 @@ +#!/bin/bash + +#================================================= +# GENERIC START +#================================================= +# IMPORT GENERIC HELPERS +#================================================= + +# Keep this path for calling _common.sh inside the execution's context of backup and restore scripts +source ../settings/scripts/_common.sh +source /usr/share/yunohost/helpers + +#================================================= +# RESTORE THE APP MAIN DIR +#================================================= +ynh_script_progression --message="Restoring the app main directory..." --weight=1 + +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 SYSTEM CONFIGURATIONS +#================================================= +# RESTORE THE PHP-FPM CONFIGURATION +#================================================= +ynh_script_progression --message="Restoring system configurations related to $app..." --weight=1 + +ynh_restore_file --origin_path="/etc/nginx/conf.d/$domain.d/$app.conf" + +#================================================= +# END OF SCRIPT +#================================================= + +ynh_script_progression --message="Restoration completed for $app" --last