1
0
Fork 0
mirror of https://github.com/YunoHost-Apps/libreerp_ynh.git synced 2024-09-03 19:36:13 +02:00
libreerp_ynh/scripts/backup
2018-09-19 15:53:06 +02:00

35 lines
1,010 B
Bash

#!/bin/bash
# Exit on command errors and treat unset variables as an error
set -eu
source /usr/share/yunohost/helpers
#source _future.sh
source ../settings/scripts/_common.sh
app=$YNH_APP_INSTANCE_NAME
domain=$(ynh_app_setting_get "$app" domain)
odoo_version=$(ynh_app_setting_get "$app" odoo_version)
define_paths
# Backup sources & data
ynh_backup "${source_path}addons" "$1${source_path}addons"
mkdir -p /opt/odoo-oca-addons
ynh_backup "/opt/odoo-oca-addons" "$1/opt/odoo-oca-addons"
# Backup configuration
ynh_backup "$conf_file" "$1$conf_file"
# Copy NGINX configuration
ynh_backup "/etc/nginx/conf.d/${domain}.d/${app}.conf" "etc/nginx/conf.d/${domain}.d/${app}.conf"
# Save postgresql conf
if is_jessie ; then
ynh_backup "/etc/postgresql/9.4/main/pg_hba.conf" "etc/postgresql/9.4/main/pg_hba.conf"
else
ynh_backup "/etc/postgresql/9.6/main/pg_hba.conf" "etc/postgresql/9.6/main/pg_hba.conf"
fi
# Copy database
database=${domain//./-}
sudo su -c "pg_dump $database" postgres > ./dump.sql