mirror of
https://github.com/YunoHost-Apps/glitchsoc_ynh.git
synced 2024-09-03 19:15:59 +02:00
Standardization of backup
This commit is contained in:
parent
6be35a9f26
commit
5799993dc4
1 changed files with 61 additions and 27 deletions
|
@ -1,46 +1,80 @@
|
||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
|
|
||||||
# Exit on command errors and treat unset variables as an error
|
#=================================================
|
||||||
set -eu
|
# GENERIC START
|
||||||
|
#=================================================
|
||||||
|
# IMPORT GENERIC HELPERS
|
||||||
|
#=================================================
|
||||||
|
|
||||||
if [ ! -e _common.sh ]; then
|
if [ ! -e _common.sh ]; then
|
||||||
# Get file fonction if not been to the current directory
|
# Get the _common.sh file if it's not in the current directory
|
||||||
sudo cp ../settings/scripts/_common.sh ./_common.sh
|
cp ../settings/scripts/_common.sh ./_common.sh
|
||||||
sudo chmod a+rx _common.sh
|
cp ../settings/scripts/_future.sh ./_future.sh
|
||||||
|
chmod a+rx _common.sh _future.sh
|
||||||
fi
|
fi
|
||||||
# Loads the generic functions usually used in the script
|
|
||||||
source _common.sh
|
source _common.sh
|
||||||
# Source app helpers
|
|
||||||
source /usr/share/yunohost/helpers
|
source /usr/share/yunohost/helpers
|
||||||
|
source _future.sh
|
||||||
|
|
||||||
|
#=================================================
|
||||||
|
# MANAGE SCRIPT FAILURE
|
||||||
|
#=================================================
|
||||||
|
|
||||||
|
# Exit if an error occurs during the execution of the script
|
||||||
|
ynh_abort_if_errors
|
||||||
|
|
||||||
|
#=================================================
|
||||||
|
# LOAD SETTINGS
|
||||||
|
#=================================================
|
||||||
|
|
||||||
# Get multi-instances specific variables
|
# Get multi-instances specific variables
|
||||||
app=$YNH_APP_INSTANCE_NAME
|
app=$YNH_APP_INSTANCE_NAME
|
||||||
|
|
||||||
# Retrieve app settings
|
# Retrieve app settings
|
||||||
domain=$(ynh_app_setting_get "$app" domain)
|
domain=$(ynh_app_setting_get "$app" domain)
|
||||||
|
final_path=$(ynh_app_setting_get "$app" final_path)
|
||||||
|
db_name=$(ynh_sanitize_dbid "$app")
|
||||||
|
|
||||||
# Copy the app files
|
#=================================================
|
||||||
final_path="/opt/${app}"
|
# STANDARD BACKUP STEPS
|
||||||
ynh_backup "$final_path" "sources" 1
|
#=================================================
|
||||||
|
# BACKUP THE APP MAIN DIR
|
||||||
|
#=================================================
|
||||||
|
|
||||||
# final_path on nginx
|
ynh_backup "$final_path"
|
||||||
sudo sed -i "s@$final_path@__FINALPATH__@g" /etc/nginx/conf.d/${domain}.d/${app}.conf
|
|
||||||
|
#=================================================
|
||||||
|
# BACKUP THE NGINX CONFIGURATION
|
||||||
|
#=================================================
|
||||||
|
|
||||||
|
ynh_backup "/etc/nginx/conf.d/$domain.d/$app.conf"
|
||||||
|
|
||||||
|
#=================================================
|
||||||
|
# BACKUP THE MYSQL DATABASE
|
||||||
|
#=================================================
|
||||||
|
|
||||||
|
ynh_psql_dump_db "$db_name" > db.sql
|
||||||
|
|
||||||
|
#=================================================
|
||||||
|
# SPECIFIC BACKUP
|
||||||
|
#=================================================
|
||||||
|
# BACKUP SYSTEMD
|
||||||
|
#=================================================
|
||||||
|
|
||||||
|
ynh_backup "/etc/systemd/system/$app-web.service"
|
||||||
|
ynh_backup "/etc/systemd/system/$app-sidekiq.service"
|
||||||
|
ynh_backup "/etc/systemd/system/$app-streaming.service"
|
||||||
|
|
||||||
|
#=================================================
|
||||||
|
# BACKUP THE CRON FILE
|
||||||
|
#=================================================
|
||||||
|
|
||||||
# Copy the nginx conf files
|
# Copy the nginx conf files
|
||||||
ynh_backup "/etc/nginx/conf.d/${domain}.d/${app}.conf" "nginx.conf"
|
ynh_backup "/etc/cron.d/$app"
|
||||||
ynh_backup "/etc/cron.d/${app}" "cron.conf"
|
|
||||||
ynh_backup "/etc/systemd/system/mastodon-web.service" "systemd_web.service"
|
#=================================================
|
||||||
ynh_backup "/etc/systemd/system/mastodon-sidekiq.service" "systemd_sidekiq.service"
|
# BACKUP THE sources.list FILES
|
||||||
ynh_backup "/etc/systemd/system/mastodon-streaming.service" "systemd_streaming.service"
|
#=================================================
|
||||||
|
|
||||||
ynh_backup "/etc/apt/sources.list.d/backports.list" "apt_backports.list"
|
ynh_backup "/etc/apt/sources.list.d/backports.list" "apt_backports.list"
|
||||||
ynh_backup "/etc/apt/sources.list.d/yarn.list" "apt_yarn.list"
|
ynh_backup "/etc/apt/sources.list.d/yarn.list" "apt_yarn.list"
|
||||||
|
|
||||||
# final_path on nginx
|
|
||||||
sudo sed -i "s@__FINALPATH__@$final_path@g" /etc/nginx/conf.d/${domain}.d/${app}.conf
|
|
||||||
|
|
||||||
# Backup db
|
|
||||||
db_name=$(ynh_sanitize_dbid "$app")
|
|
||||||
ynh_psql_dump_db "$db_name"
|
|
||||||
|
|
||||||
# Fix backup fail on yunohost 2.6
|
|
||||||
#ynh_secure_remove /var/lib/postgresql/mastodon_db.sql
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue