diff --git a/scripts/_common.sh b/scripts/_common.sh index 669e9ba9..04f5ced1 100644 --- a/scripts/_common.sh +++ b/scripts/_common.sh @@ -10,6 +10,16 @@ php_dependencies="php${YNH_PHP_VERSION}-fpm php${YNH_PHP_VERSION}-bz2 php${YNH_P pkg_dependencies="imagemagick libmagickcore-6.q16-6-extra acl tar smbclient at $php_dependencies" + +set_datadir() { + if [[ -f $final_path/config/config.php ]]; then + datadir=$(grep datadirectory < $final_path/config/config.php | sed "s/.*=>.'\([^']*\)'.*/\1/") + else + datadir="/home/yunohost.app/$app/data" + fi +} + + #================================================= # EXPERIMENTAL HELPERS #================================================= diff --git a/scripts/backup b/scripts/backup index 6fd1086a..486c1eac 100755 --- a/scripts/backup +++ b/scripts/backup @@ -86,6 +86,8 @@ ynh_backup --src_path="/etc/cron.d/$app" #================================================= ynh_print_info --message="Backing up data directory..." +set_datadir + ynh_backup --src_path="$datadir" --is_big #================================================= diff --git a/scripts/restore b/scripts/restore index 42e6dcca..4603c603 100755 --- a/scripts/restore +++ b/scripts/restore @@ -127,6 +127,8 @@ ynh_restore_file --origin_path="/etc/logrotate.d/$app" #================================================= ynh_script_progression --message="Restoring data directory..." --weight=2 +set_datadir + # Use --not_mandatory for the data directory, because if the backup has been made with BACKUP_CORE_ONLY, there's no data into the backup. ynh_restore_file --origin_path="$datadir" --not_mandatory diff --git a/scripts/upgrade b/scripts/upgrade index eb1adb6f..d965dff2 100755 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -232,8 +232,8 @@ local mount_id=$(exec_occ files_external:create --output=json \ && ynh_print_warn --message="Unable to create external storage" \ || exec_occ files_external:option "$mount_id" enable_sharing true } -# Define app's data directory -datadir="/home/yunohost.app/$app/data" +# Define app's data directory (defined in _common.sh) +set_datadir if [ "$upgrade_type" == "UPGRADE_APP" ] then