1
0
Fork 0
mirror of https://github.com/YunoHost-Apps/piwigo_ynh.git synced 2024-09-03 20:06:03 +02:00
piwigo_ynh/scripts/backup
Jimmy Monin 76fc701a4b Major refactoring & complete Piwigo upgrade process:
- refactoring to comply with packaging latest standards/helpers
- use Piwigo internal upgrade process via a curl command
2017-06-03 18:13:29 +02:00

68 lines
No EOL
1.9 KiB
Bash

#!/bin/bash
# Exit on command errors and treat unset variables as an error
set -eu
#=================================================
# IMPORT GENERIC HELPERS
#=================================================
if [ ! -e _common.sh ]; then
# Fetch helpers file if not in current directory
sudo cp ../settings/scripts/_common.sh ./_common.sh
sudo chmod a+rx _common.sh
fi
source _common.sh
source /usr/share/yunohost/helpers
#=================================================
# LOAD SETTINGS
#=================================================
app=$YNH_APP_INSTANCE_NAME
domain=$(ynh_app_setting_get $app domain)
final_path="/var/www/${app}"
db_name=$(ynh_app_setting_get $app db_name)
#=================================================
# STANDARD BACKUP STEPS
#=================================================
# BACKUP APP MAIN DIR
#=================================================
CHECK_SIZE "$final_path"
ynh_backup "$final_path" "sources"
# Copy the data directory
backup_core_only=$(ynh_app_setting_get "$app" backup_core_only)
if [ -z $backup_core_only ] # If backup_core_only setting set, don't backup data directory
then
DATADIR="/home/yunohost.app/${app}"
CHECK_SIZE "$DATADIR"
ynh_backup "$DATADIR" "data" 1
else
echo "Data dir won't be saved, because backup_core_only is set." >&2
fi
#=================================================
# BACKUP NGINX CONFIGURATION
#=================================================
ynh_backup "/etc/nginx/conf.d/$domain.d/$app.conf" "nginx.conf"
#=================================================
# BACKUP PHP-FPM CONFIGURATION
#=================================================
ynh_backup "/etc/php5/fpm/pool.d/$app.conf" "php-fpm.conf"
#=================================================
# BACKUP MYSQL DB
#=================================================
ynh_mysql_dump_db "$db_name" > dump.sql
CHECK_SIZE "dump.sql"
ynh_backup "dump.sql" "db.sql"