libreerp_ynh/scripts/backup

36 lines
1,010 B
Text
Raw Normal View History

2016-11-29 00:20:02 +01:00
#!/bin/bash
2016-07-05 15:22:12 +02:00
# Exit on command errors and treat unset variables as an error
set -eu
2017-05-18 23:28:18 +02:00
source /usr/share/yunohost/helpers
#source _future.sh
source ../settings/scripts/_common.sh
2016-07-05 15:22:12 +02:00
app=$YNH_APP_INSTANCE_NAME
2017-05-18 23:28:18 +02:00
domain=$(ynh_app_setting_get "$app" domain)
odoo_version=$(ynh_app_setting_get "$app" odoo_version)
2016-07-05 15:22:12 +02:00
2017-05-18 23:28:18 +02:00
define_paths
2016-07-05 15:22:12 +02:00
# Backup sources & data
2017-05-18 23:28:18 +02:00
ynh_backup "${source_path}addons" "$1${source_path}addons"
2017-06-25 19:16:49 +02:00
mkdir -p /opt/odoo-oca-addons
ynh_backup "/opt/odoo-oca-addons" "$1/opt/odoo-oca-addons"
2017-05-18 23:28:18 +02:00
# Backup configuration
ynh_backup "$conf_file" "$1$conf_file"
2016-07-05 15:22:12 +02:00
# Copy NGINX configuration
2017-05-18 23:28:18 +02:00
ynh_backup "/etc/nginx/conf.d/${domain}.d/${app}.conf" "etc/nginx/conf.d/${domain}.d/${app}.conf"
# Save postgresql conf
2018-09-19 15:53:06 +02:00
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
2016-07-05 15:22:12 +02:00
# Copy database
database=${domain//./-}
sudo su -c "pg_dump $database" postgres > ./dump.sql