mirror of
https://github.com/YunoHost-Apps/mattermost_ynh.git
synced 2024-09-03 19:36:29 +02:00
scripts: modernize backup script
This commit is contained in:
parent
cb0d4ddc75
commit
99f7d88424
1 changed files with 39 additions and 22 deletions
|
@ -1,29 +1,46 @@
|
||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
set -eu # exit on error ; treat unset variables as error
|
set -eu # exit on error ; treat unset variables as error
|
||||||
|
|
||||||
app=mattermost
|
#=================================================
|
||||||
db_name="$app"
|
# IMPORT GENERIC HELPERS
|
||||||
|
#=================================================
|
||||||
|
|
||||||
# The parameter $1 is the backup directory location
|
source /usr/share/yunohost/helpers
|
||||||
# which will be compressed afterward
|
|
||||||
backup_dir=${1}apps/$app
|
|
||||||
sudo mkdir -p $backup_dir
|
|
||||||
|
|
||||||
# Backup sources
|
#=================================================
|
||||||
echo "Backup sources from /var/www/$app…"
|
# LOAD SETTINGS
|
||||||
sudo cp -a /var/www/$app/. $backup_dir/sources
|
#=================================================
|
||||||
|
app=$YNH_APP_INSTANCE_NAME
|
||||||
|
|
||||||
# Backup database
|
final_path="/var/www/$app"
|
||||||
echo "Backup database…"
|
|
||||||
root_pwd=$(sudo cat /etc/yunohost/mysql)
|
|
||||||
ynh_mysql_dump_db $db_name > $backup_dir/mattermost.sql
|
|
||||||
|
|
||||||
# Backup uploaded files
|
|
||||||
echo "Backup uploaded files…"
|
|
||||||
sudo cp -a /home/yunohost.app/mattermost/. $backup_dir/data
|
|
||||||
|
|
||||||
# Copy Nginx and YunoHost parameters to make the script "standalone"
|
|
||||||
echo "Backup Yunohost configuration…"
|
|
||||||
sudo cp -a /etc/yunohost/apps/$app/. $backup_dir/yunohost
|
|
||||||
domain=$(ynh_app_setting_get $app domain)
|
domain=$(ynh_app_setting_get $app domain)
|
||||||
sudo cp -a /etc/nginx/conf.d/$domain.d/$app.conf $backup_dir/nginx.conf
|
db_name="$app"
|
||||||
|
default_backup_dir="${1}apps/$app"
|
||||||
|
backup_dir=${backup_dir:-"$default_backup_dir"}
|
||||||
|
|
||||||
|
#=================================================
|
||||||
|
# STANDARD BACKUP STEPS
|
||||||
|
#=================================================
|
||||||
|
# BACKUP THE APP MAIN DIR
|
||||||
|
#=================================================
|
||||||
|
|
||||||
|
ynh_backup "$final_path" "${backup_dir}$final_path"
|
||||||
|
|
||||||
|
#=================================================
|
||||||
|
# BACKUP THE DATABASE
|
||||||
|
#=================================================
|
||||||
|
|
||||||
|
ynh_mysql_dump_db "$db_name" > db.sql
|
||||||
|
ynh_backup "db.sql" "${backup_dir}/db.sql"
|
||||||
|
|
||||||
|
#=================================================
|
||||||
|
# BACKUP THE NGINX CONFIGURATION
|
||||||
|
#=================================================
|
||||||
|
|
||||||
|
ynh_backup "/etc/nginx/conf.d/$domain.d/$app.conf" "${backup_dir}/etc/nginx/conf.d/$domain.d/$app.conf"
|
||||||
|
|
||||||
|
#=================================================
|
||||||
|
# BACKUP SUPERVISOR CONFIG
|
||||||
|
#=================================================
|
||||||
|
|
||||||
|
ynh_backup "/etc/supervisor/conf.d/$app.conf" "${backup_dir}/etc/supervisor/conf.d/$app.conf"
|
||||||
|
|
Loading…
Reference in a new issue