backup/restore for both root and subdir

This commit is contained in:
Kay0u 2020-12-24 18:39:32 +01:00
parent a45b22132c
commit a4c0a3fcc4
No known key found for this signature in database
GPG key ID: AE1DCADB6415A156
2 changed files with 82 additions and 66 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,8 @@ TEST_BACKUP_RESTORE () {
if [ $ret -ne 0 ] if [ $ret -ne 0 ]
then then
log_error "Installation failed..." log_error "Installation failed..."
main_result=1
continue
else else
log_small_title "Backup of the application..." log_small_title "Backup of the application..."
@ -516,11 +527,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
} }

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() {