Merge pull request #97 from YunoHost/backup/restore-for-both-root-and-subdir

backup/restore for both root and subdir
This commit is contained in:
Alexandre Aubin 2020-12-25 14:34:47 +01:00 committed by GitHub
commit 37292a300e
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 84 additions and 68 deletions

View file

@ -452,15 +452,24 @@ TEST_BACKUP_RESTORE () {
# Check if an install have previously work # Check if an install have previously work
at_least_one_install_succeeded || return 1 at_least_one_install_succeeded || return 1
local check_path="$(default_install_path)" local check_paths=()
if this_is_a_web_app; then
there_is_a_root_install_test && check_paths+=("$(root_path)")
there_is_a_subdir_install_test && check_paths+=("$(subdir_path)")
else
check_paths+=("")
fi
local main_result=0
for check_path in "${check_paths[@]}"
do
# Install the application in a LXC container # Install the application in a LXC container
_LOAD_SNAPSHOT_OR_INSTALL_APP "$check_path" _LOAD_SNAPSHOT_OR_INSTALL_APP "$check_path"
local ret=$? local ret=$?
local main_result=0
# Remove the previous residual backups # Remove the previous residual backups
RUN_INSIDE_LXC rm -rf /home/yunohost.backup/archives RUN_INSIDE_LXC rm -rf /home/yunohost.backup/archives
@ -469,6 +478,9 @@ TEST_BACKUP_RESTORE () {
if [ $ret -ne 0 ] if [ $ret -ne 0 ]
then then
log_error "Installation failed..." log_error "Installation failed..."
main_result=1
break_before_continue
continue
else else
log_small_title "Backup of the application..." log_small_title "Backup of the application..."
@ -477,7 +489,7 @@ TEST_BACKUP_RESTORE () {
ret=$? ret=$?
fi fi
[ $ret -eq 0 ] || main_result=1 [ $ret -eq 0 ] || { main_result=1; break_before_continue; continue; }
# Grab the backup archive into the LXC container, and keep a copy # Grab the backup archive into the LXC container, and keep a copy
lxc file pull -r $LXC_NAME/home/yunohost.backup/archives $TEST_CONTEXT/ynh_backups lxc file pull -r $LXC_NAME/home/yunohost.backup/archives $TEST_CONTEXT/ynh_backups
@ -516,11 +528,12 @@ TEST_BACKUP_RESTORE () {
_RUN_YUNOHOST_CMD "backup restore Backup_test --force --apps $app_id" \ _RUN_YUNOHOST_CMD "backup restore Backup_test --force --apps $app_id" \
&& _VALIDATE_THAT_APP_CAN_BE_ACCESSED "$SUBDOMAIN" "$check_path" && _VALIDATE_THAT_APP_CAN_BE_ACCESSED "$SUBDOMAIN" "$check_path"
local ret=$? ret=$?
[ $ret -eq 0 ] || main_result=1 [ $ret -eq 0 ] || main_result=1
break_before_continue break_before_continue
done done
done
return $main_result return $main_result
} }
@ -891,4 +904,3 @@ ACTIONS_CONFIG_PANEL () {
return $main_result return $main_result
} }

View file

@ -403,15 +403,19 @@ this_is_a_web_app () {
return $(there_is_a_root_install_test) || $(there_is_a_subdir_install_test) return $(there_is_a_root_install_test) || $(there_is_a_subdir_install_test)
} }
root_path () {
echo "/"
}
subdir_path () {
echo "/path"
}
default_install_path() { default_install_path() {
# All webapps should be installable at the root or in a subpath of a domain # All webapps should be installable at the root or in a subpath of a domain
if there_is_a_root_install_test; then there_is_a_root_install_test && { root_path; return; }
echo "/" there_is_a_subdir_install_test && { subdir_path; return; }
elif there_is_a_subdir_install_test; then
echo "/path"
else
echo "" echo ""
fi
} }
path_to_install_type() { path_to_install_type() {