2023-08-17 21:45:58 +02:00
|
|
|
#!/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..."
|
|
|
|
|
|
|
|
### 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_backup --src_path="$install_dir"
|
|
|
|
|
|
|
|
#=================================================
|
|
|
|
# BACKUP THE NGINX CONFIGURATION
|
|
|
|
#=================================================
|
|
|
|
|
|
|
|
ynh_backup --src_path="/etc/nginx/conf.d/$domain.d/$app.conf"
|
|
|
|
|
|
|
|
#=================================================
|
|
|
|
# SPECIFIC BACKUP
|
|
|
|
#=================================================
|
|
|
|
# BACKUP LOGROTATE
|
|
|
|
#=================================================
|
|
|
|
|
|
|
|
ynh_backup --src_path="/etc/logrotate.d/$app"
|
|
|
|
|
|
|
|
#=================================================
|
|
|
|
# BACKUP SYSTEMD
|
|
|
|
#=================================================
|
|
|
|
|
2023-08-24 23:42:42 +02:00
|
|
|
ynh_backup --src_path="/etc/systemd/system/$app.target"
|
|
|
|
ynh_backup --src_path="/etc/systemd/system/${app}-front.service"
|
|
|
|
ynh_backup --src_path="/etc/systemd/system/${app}-back.service"
|
2023-08-17 21:45:58 +02:00
|
|
|
|
|
|
|
#=================================================
|
2023-08-24 23:42:42 +02:00
|
|
|
# BACKUP THE POSTGRES DATABASE
|
2023-08-17 21:45:58 +02:00
|
|
|
#=================================================
|
2023-08-24 23:42:42 +02:00
|
|
|
ynh_print_info --message="Backing up the POSTGRES database..."
|
2023-08-17 21:45:58 +02:00
|
|
|
|
2023-08-24 23:42:42 +02:00
|
|
|
### (However, things like Postgres dumps *do* take some time to run, though the
|
2023-08-17 21:45:58 +02:00
|
|
|
### copy of the generated dump to the archive still happens later)
|
|
|
|
|
2023-08-24 23:42:42 +02:00
|
|
|
ynh_psql_dump_db --database="$db_name" > db.sql
|
2023-08-17 21:45:58 +02:00
|
|
|
|
|
|
|
#=================================================
|
|
|
|
# END OF SCRIPT
|
|
|
|
#=================================================
|
|
|
|
|
|
|
|
ynh_print_info --message="Backup script completed for $app. (YunoHost will then actually copy those files to the archive)."
|