1
0
Fork 0
mirror of https://github.com/YunoHost-Apps/glitchsoc_ynh.git synced 2024-09-03 19:15:59 +02:00
glitchsoc_ynh/scripts/backup
nemsia 64d3147a7b
Yunohost 3.0 Stretch app upgrade (#85)
* Ready to Debian Stretch

* rb 2.5.1 on install

* Yarn install on root

* Ready to mastodon 2.4.1
2018-05-31 13:41:03 +02:00

48 lines
1.6 KiB
Bash

#!/bin/bash
# Exit on command errors and treat unset variables as an error
set -eu
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
# 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"
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"
debian_version=$(lsb_release -c -s)
if [[ $debian_version = 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"
# final_path on nginx
sudo sed -i "s@__FINALPATH__@$final_path@g" /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"