mirror of
https://framagit.org/YunoHost-Apps/gitea_ynh.git
synced 2024-11-23 11:31:35 +01:00
Add backup core only
This commit is contained in:
parent
ef962d9560
commit
c788865334
@ -35,4 +35,18 @@ ynh_backup "/etc/systemd/system/${app}.service"
|
||||
ynh_backup "/var/log/$app"
|
||||
|
||||
# Dump the database
|
||||
ynh_mysql_dump_db "$dbname" > ./db.sql
|
||||
ynh_mysql_dump_db "$dbname" > ./db.sql
|
||||
|
||||
|
||||
#=================================================
|
||||
# BACKUP THE DATA DIRECTORY
|
||||
#=================================================
|
||||
|
||||
backup_core_only=$(ynh_app_setting_get "$app" backup_core_only)
|
||||
# If backup_core_only have any value in the settings.yml file, do not backup the data directory
|
||||
if [ -z $backup_core_only ]
|
||||
then
|
||||
ynh_backup "/home/$app"
|
||||
else
|
||||
echo "Data dir will not be saved, because backup_core_only is set." >&2
|
||||
fi
|
@ -43,10 +43,46 @@ test getent passwd "$app" &>/dev/null || \
|
||||
# Should be replaced by this when getops is available in the helper ynh_system_user_create (probably in Yunohost 3.5)
|
||||
# ynh_system_user_create --username= $app --home_dir=/opt/yunohost/$app --use_shell
|
||||
|
||||
# Restore all files
|
||||
ynh_restore
|
||||
|
||||
# Create and restore the database
|
||||
#=================================================
|
||||
# RESTORE THE NGINX CONFIGURATION
|
||||
#=================================================
|
||||
|
||||
ynh_restore_file "/etc/nginx/conf.d/$domain.d/$app.conf"
|
||||
|
||||
#=================================================
|
||||
# RESTORE THE LOGROTATE CONFIGURATION
|
||||
#=================================================
|
||||
|
||||
ynh_restore_file "/etc/logrotate.d/$app"
|
||||
|
||||
#=================================================
|
||||
# RESTORE THE APP MAIN DIR
|
||||
#=================================================
|
||||
ynh_restore_file "$final_path"
|
||||
|
||||
#=================================================
|
||||
# RESTORE DATADIR
|
||||
#=================================================
|
||||
# Restore all files
|
||||
datadir="/home/${app}"
|
||||
|
||||
# The data directory will be restored only if it exists in the backup archive
|
||||
# So only if it was backup previously.
|
||||
if [ -d "$YNH_BACKUP_DIR/apps/$app/backup/home/$app" ]
|
||||
then
|
||||
ynh_restore_file "$datadir"
|
||||
else
|
||||
# Create app folders
|
||||
mkdir -p "$datadir"
|
||||
fi
|
||||
# Remove the option backup_core_only if it's in the settings.yml file
|
||||
ynh_app_setting_delete $app backup_core_only
|
||||
|
||||
|
||||
#=================================================
|
||||
# RESTORE DATABASE
|
||||
#=================================================
|
||||
ynh_mysql_create_db "$dbname" "$dbuser" "$dbpass"
|
||||
ynh_mysql_connect_as "$dbuser" "$dbpass" "$dbname" < ./db.sql
|
||||
|
||||
|
@ -24,6 +24,8 @@ is_public=$(ynh_app_setting_get "$app" is_public)
|
||||
port=$(ynh_app_setting_get "$app" web_port)
|
||||
|
||||
# Backup the current version of the app
|
||||
# Inform the backup/restore process that it should not save the data directory
|
||||
ynh_app_setting_set $app backup_core_only 1
|
||||
ynh_backup_before_upgrade
|
||||
ynh_clean_setup () {
|
||||
ynh_restore_upgradebackup
|
||||
|
Loading…
Reference in New Issue
Block a user