test_apps/legacy_app_ynh/scripts/backup
2020-04-12 17:35:01 +02:00

27 lines
746 B
Bash

#!/bin/bash
set -eu
# Source app helpers
source /usr/share/yunohost/helpers
# Retrieve parameters
# Backup directory (location dedicated to the app)
backup_dir=$1
# App instance name
app=$2
domain=$(ynh_app_setting_get $app domain)
# Copy the app files (explicitly specifying the backup dir)
sudo mkdir -p "${backup_dir}/var/www"
ynh_backup /var/www/$app "${backup_dir}/var/www/$app"
# Copy the conf files (without explicitly specifying the backup dir)
sudo mkdir -p "${backup_dir}/conf"
ynh_backup /etc/nginx/conf.d/$domain.d/$app.conf "conf/nginx.conf"
# Copy the custom file as if it was a big file (1 at the end)
ynh_backup /etc/importantfile "${backup_dir}/importantfile" 1
# Backup db
ynh_mysql_dump_db $app > "${backup_dir}/db.sql"