1
0
Fork 0
mirror of https://github.com/YunoHost-Apps/mastodon_ynh.git synced 2024-09-03 19:46:02 +02:00
mastodon_ynh/scripts/backup

47 lines
1.5 KiB
Text
Raw Normal View History

#!/bin/bash
# Exit on command errors and treat unset variables as an error
set -eu
2018-04-06 19:58:23 +02:00
if [ ! -e _common.sh ]; then
# Get file fonction if not been to the current directory
2018-04-06 19:58:23 +02:00
sudo cp ../settings/scripts/_common.sh ./_common.sh
sudo chmod a+rx _common.sh
fi
# Loads the generic functions usually used in the script
2018-04-06 19:58:23 +02:00
source _common.sh
# Source app helpers
source /usr/share/yunohost/helpers
# Get multi-instances specific variables
app=$YNH_APP_INSTANCE_NAME
# Retrieve app settings
domain=$(ynh_app_setting_get "$app" domain)
# Copy the app files
final_path="/opt/${app}"
ynh_backup "$final_path" "sources" 1
# final_path on nginx
sudo sed -i "s@$final_path@__FINALPATH__@g" /etc/nginx/conf.d/${domain}.d/${app}.conf
# 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"
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"
2017-05-07 00:30:50 +02:00
ynh_backup "/etc/apt/sources.list.d/backports.list" "apt_backports.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
2018-05-01 11:29:25 +02:00
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