diff options
| author | nemsia <nemsia@nemsia.org> | 2018-06-19 15:24:45 +0200 |
|---|---|---|
| committer | nemsia <nemsia@nemsia.org> | 2018-06-19 15:24:45 +0200 |
| commit | ea9d2e8f0d93744988c03ef37a310bee4410e0b6 (patch) | |
| tree | 80330068f95864a32b5a2fa6dccad92338662476 /scripts/backup | |
| parent | e47519da19d66e8f5d276a6ee582456f59d0541b (diff) | |
| parent | ea65ebe0a1dfda010cd030c6861dd30e0c2b43f7 (diff) | |
| download | mastodon_ynh-ea9d2e8f0d93744988c03ef37a310bee4410e0b6.tar.gz mastodon_ynh-ea9d2e8f0d93744988c03ef37a310bee4410e0b6.tar.bz2 mastodon_ynh-ea9d2e8f0d93744988c03ef37a310bee4410e0b6.zip | |
Merge branch 'testing-2.4' into master
And Stay on 2.4.1
Diffstat (limited to 'scripts/backup')
| -rw-r--r-- | scripts/backup | 91 |
1 files changed, 60 insertions, 31 deletions
diff --git a/scripts/backup b/scripts/backup index 8040747..be3b0a4 100644 --- a/scripts/backup +++ b/scripts/backup @@ -1,47 +1,76 @@ #!/bin/bash -# Exit on command errors and treat unset variables as an error -set -eu +#================================================= +# GENERIC START +#================================================= +# IMPORT GENERIC HELPERS +#================================================= -if [ ! -e .fonctions ]; then - # Get file fonction if not been to the current directory - sudo cp ../settings/scripts/.fonctions ./.fonctions - sudo chmod a+rx .fonctions +if [ ! -e _common.sh ]; then + # Get the _common.sh file if it's not in the current directory + cp ../settings/scripts/_common.sh ./_common.sh + cp ../settings/scripts/_future.sh ./_future.sh + chmod a+rx _common.sh _future.sh fi -# Loads the generic functions usually used in the script -source .fonctions -# Source app helpers +source _common.sh 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 app=$YNH_APP_INSTANCE_NAME # Retrieve app settings domain=$(ynh_app_setting_get "$app" domain) +final_path=$(ynh_app_setting_get "$app" final_path) +db_name=$(ynh_app_setting_get "$app" db_name) +if [ -z "$db_name" ]; then + db_name="${app}_production" + ynh_app_setting_set "$app" db_name "$db_name" +fi -# Copy the app files -final_path="/opt/${app}" -ynh_backup "$final_path" "sources" 1 +#================================================= +# STANDARD BACKUP STEPS +#================================================= +# BACKUP THE APP MAIN DIR +#================================================= -# final_path on nginx -sudo sed -i "s@$final_path@__FINALPATH__@g" /etc/nginx/conf.d/${domain}.d/${app}.conf +ynh_backup "$final_path" -# Copy the nginx conf files -ynh_backup "/etc/nginx/conf.d/${domain}.d/${app}.conf" "nginx.conf" -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" -ynh_backup "/etc/systemd/system/mastodon-streaming.service" "systemd_streaming.service" -if [ "$(lsb_release --codename --short)" == "jessie" ]; then - ynh_backup "/etc/apt/sources.list.d/backports.list" "apt_backports.list" -fi -ynh_backup "/etc/apt/sources.list.d/yarn.list" "apt_yarn.list" +#================================================= +# BACKUP THE NGINX CONFIGURATION +#================================================= -# final_path on nginx -sudo sed -i "s@__FINALPATH__@$final_path@g" /etc/nginx/conf.d/${domain}.d/${app}.conf +ynh_backup "/etc/nginx/conf.d/$domain.d/$app.conf" -# Backup db -sudo su - postgres <<COMMANDS -pg_dump --role=mastodon -U postgres --no-password mastodon_production > mastodon_db.sql -COMMANDS -ynh_backup "/var/lib/postgresql/${app}_db.sql" "${app}_db.sql" +#================================================= +# 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 sources.list FILES +#================================================= + +ynh_backup "/etc/apt/sources.list.d/yarn.list" "apt_yarn.list" |
