Update scripts/backup

This commit is contained in:
denis 2024-11-15 18:17:03 -05:00
parent 7cce865935
commit afd3ea99ed

View file

@ -4,17 +4,11 @@
# IMPORT GENERIC HELPERS # 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 ../settings/scripts/_common.sh
source /usr/share/yunohost/helpers source /usr/share/yunohost/helpers
ynh_print_info "Declaring files to be backed up..." ynh_print_info "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 fills the archive with the files happens in the core after this
### script is called. Hence ynh_backups calls take basically 0 seconds to run.
#================================================= #=================================================
# BACKUP THE APP MAIN DIR # BACKUP THE APP MAIN DIR
#================================================= #=================================================
@ -25,33 +19,18 @@ ynh_backup "$install_dir"
# BACKUP THE DATA DIR # BACKUP THE DATA DIR
#================================================= #=================================================
# Only relevant if there is a "data_dir" resource for this app
# NB: $data_dir is not backuped during safety-backup-before-upgrades,
# because the data dir may be huge and we don't want to just yolo-create a 10+ GB archive just for upgrades.
# On the other hand, $data_dir is also *not* removed by default in the "app remove" step unless --purge is used
# This means that even if the upgrade fails and the backup is restored, the data are still there.
ynh_backup "$data_dir" ynh_backup "$data_dir"
#================================================= #=================================================
# SYSTEM CONFIGURATION # SYSTEM CONFIGURATION
#================================================= #=================================================
# Backup the PHP-FPM configuration
ynh_backup "/etc/php/$php_version/fpm/pool.d/$app.conf" ynh_backup "/etc/php/$php_version/fpm/pool.d/$app.conf"
# Backup the NGINX configuration
ynh_backup "/etc/nginx/conf.d/$domain.d/$app.conf" ynh_backup "/etc/nginx/conf.d/$domain.d/$app.conf"
# Backup the systemd service unit
ynh_backup "/etc/systemd/system/$app.service" ynh_backup "/etc/systemd/system/$app.service"
# Backup the logrotate configuration
ynh_backup "/etc/logrotate.d/$app"
# Backup the Fail2Ban config
ynh_backup "/etc/fail2ban/jail.d/$app.conf"
ynh_backup "/etc/fail2ban/filter.d/$app.conf"
#================================================= #=================================================
# BACKUP VARIOUS FILES # BACKUP VARIOUS FILES
#================================================= #=================================================
@ -60,19 +39,8 @@ ynh_backup "/etc/cron.d/$app"
ynh_backup "/etc/$app/" ynh_backup "/etc/$app/"
# NB: /var/log is not backuped during safety-backup-before-upgrades, same as $data_dir
ynh_backup "/var/log/$app/" ynh_backup "/var/log/$app/"
#=================================================
# BACKUP THE MYSQL DATABASE
#=================================================
ynh_print_info "Backing up the MySQL 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 > db.sql
#================================================= #=================================================
# END OF SCRIPT # END OF SCRIPT
#================================================= #=================================================