2016-01-10 20:10:16 +01:00
|
|
|
#!/bin/bash
|
|
|
|
|
2016-05-10 14:21:26 +02:00
|
|
|
# causes the shell to exit if any subcommand or pipeline returns a non-zero status
|
|
|
|
set -e
|
|
|
|
|
2016-05-10 15:51:32 +02:00
|
|
|
# Source YNH helpers
|
|
|
|
. /usr/share/yunohost/helpers
|
2016-01-10 20:10:16 +01:00
|
|
|
|
2016-05-10 15:51:32 +02:00
|
|
|
# This is a multi-instance app, meaning it can be installed several times independently
|
|
|
|
# The id of the app as stated in the manifest is available as $YNH_APP_ID
|
|
|
|
# The instance number is available as $YNH_APP_INSTANCE_NUMBER (equals "1", "2", ...)
|
|
|
|
# The app instance name is available as $YNH_APP_INSTANCE_NAME
|
|
|
|
# - the first time the app is installed, YNH_APP_INSTANCE_NAME = ynhexample
|
|
|
|
# - the second time the app is installed, YNH_APP_INSTANCE_NAME = ynhexample__2
|
|
|
|
# - ynhexample__{N} for the subsequent installations, with N=3,4, ...
|
|
|
|
# The app instance name is probably what you are interested the most, since this is
|
|
|
|
# guaranteed to be unique. This is a good unique identifier to define installation path,
|
|
|
|
# db names, ...
|
|
|
|
app=$YNH_APP_INSTANCE_NAME
|
2016-01-10 20:10:16 +01:00
|
|
|
|
|
|
|
domain=$(sudo yunohost app setting $app domain)
|
|
|
|
path=$(sudo yunohost app setting $app path)
|
|
|
|
|
|
|
|
# Copy the app files
|
2016-05-04 14:34:47 +02:00
|
|
|
final_path="/var/www/$app"
|
2016-05-10 14:21:26 +02:00
|
|
|
ynh_backup "$final_path" "./www"
|
2016-01-10 20:10:16 +01:00
|
|
|
|
|
|
|
# Copy the conf files
|
2016-05-04 14:34:47 +02:00
|
|
|
sudo mkdir -p ./conf
|
2016-05-10 14:21:26 +02:00
|
|
|
ynh_backup "/etc/nginx/conf.d/$domain.d/$app.conf" "./conf/nginx.conf"
|
|
|
|
ynh_backup "/etc/cron.d/$app" "./conf/cron"
|
2016-01-10 20:10:16 +01:00
|
|
|
|
|
|
|
# Backup db
|
|
|
|
root_pwd=$(sudo cat /etc/yunohost/mysql)
|
2016-05-04 14:34:47 +02:00
|
|
|
sudo su -c "mysqldump -u root -p$root_pwd --no-create-db $app > ./db.sql"
|