2017-04-10 04:55:10 +02:00
|
|
|
#!/bin/bash
|
|
|
|
|
|
|
|
# Exit on command errors and treat unset variables as an error
|
|
|
|
set -eu
|
|
|
|
|
2017-04-19 02:37:40 +02:00
|
|
|
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
|
|
|
|
fi
|
|
|
|
# Loads the generic functions usually used in the script
|
|
|
|
source .fonctions
|
2017-04-10 04:55:10 +02:00
|
|
|
# Source app helpers
|
|
|
|
source /usr/share/yunohost/helpers
|
|
|
|
|
2017-04-19 02:37:40 +02:00
|
|
|
# Get multi-instances specific variables
|
|
|
|
app=$YNH_APP_INSTANCE_NAME
|
|
|
|
|
2017-04-10 04:55:10 +02:00
|
|
|
# Retrieve app settings
|
|
|
|
domain=$(ynh_app_setting_get "$app" domain)
|
|
|
|
|
|
|
|
# Copy the app files
|
|
|
|
final_path="/opt/${app}"
|
|
|
|
ynh_backup "$final_path" "sources" 1
|
|
|
|
|
2017-07-13 00:12:42 +02:00
|
|
|
# final_path on nginx
|
|
|
|
sudo sed -i "s@$final_path@__FINALPATH__@g" /etc/nginx/conf.d/${domain}.d/${app}.conf
|
|
|
|
|
2017-04-10 04:55:10 +02:00
|
|
|
# Copy the nginx conf files
|
|
|
|
ynh_backup "/etc/nginx/conf.d/${domain}.d/${app}.conf" "nginx.conf"
|
2017-04-17 19:53:12 +02:00
|
|
|
ynh_backup "/etc/cron.d/${app}" "cron.conf"
|
2017-04-10 04:55:10 +02:00
|
|
|
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"
|
2018-06-12 15:33:34 +02:00
|
|
|
if [ "$(lsb_release --codename --short)" == "jessie" ]; then
|
2018-05-31 13:41:03 +02:00
|
|
|
ynh_backup "/etc/apt/sources.list.d/backports.list" "apt_backports.list"
|
|
|
|
fi
|
2017-05-07 00:30:50 +02:00
|
|
|
ynh_backup "/etc/apt/sources.list.d/yarn.list" "apt_yarn.list"
|
2017-04-10 04:55:10 +02:00
|
|
|
|
2017-07-13 00:12:42 +02:00
|
|
|
# final_path on nginx
|
|
|
|
sudo sed -i "s@__FINALPATH__@$final_path@g" /etc/nginx/conf.d/${domain}.d/${app}.conf
|
|
|
|
|
2017-04-10 04:55:10 +02:00
|
|
|
# Backup db
|
|
|
|
sudo su - postgres <<COMMANDS
|
2017-04-19 02:37:40 +02:00
|
|
|
pg_dump --role=mastodon -U postgres --no-password mastodon_production > mastodon_db.sql
|
2017-04-10 04:55:10 +02:00
|
|
|
COMMANDS
|
2017-04-19 02:37:40 +02:00
|
|
|
ynh_backup "/var/lib/postgresql/${app}_db.sql" "${app}_db.sql"
|