if the backup storage is local do not use webdav

This commit is contained in:
goldsquid
2026-06-06 11:36:58 +07:00
parent eccae5039f
commit 1aef140a9a
3 changed files with 56 additions and 11 deletions

View File

@@ -2,6 +2,12 @@
dir="$(dirname "$0")"
source "$dir/volume-utils.sh"
remote_source="$2"
if [[ -n "$remote_source" ]] && is_local_backup_url "$remote_source"; then
echo "Source URL points to this server, using local /backup instead of $remote_source"
remote_source=""
fi
# Path to the backup directory
backup_dir="/backup"
@@ -25,9 +31,9 @@ while IFS= read -r key; do
volume_name="rpc_$key"
declare newest_file
if [[ -n $2 ]]; then
if [[ -n "$remote_source" ]]; then
volume_name="rpc_$key-20" # needs to be followed by a date 2024
newest_file=$($dir/list-backups.sh $2 | grep "${volume_name}" | sort | tail -n 1)
newest_file=$($dir/list-backups.sh "$remote_source" | grep "${volume_name}" | sort | tail -n 1)
else
newest_file=$(ls -1 "$backup_dir"/"${volume_name}"-[0-9]*G.tar.zst 2>/dev/null | sort | tail -n 1)
fi
@@ -55,12 +61,12 @@ echo "done cleanup"
for file in "${restore_files[@]}"; do
echo "Processing: $file"
if [[ -n $2 ]]; then
if [[ -n "$remote_source" ]]; then
if [ ! -d "$backup_dir" ]; then
echo "Error: /backup directory does not exist. download from http and extract directly to /var/lib/docker"
curl --ipv4 -# "${2}${file}" | zstd -d | tar -xvf - --dereference -C /
curl --ipv4 -# "${remote_source}${file}" | zstd -d | tar -xvf - --dereference -C /
if [ $? -ne 0 ]; then
echo "Error processing $file"
@@ -71,7 +77,7 @@ for file in "${restore_files[@]}"; do
else
echo "have backup dir to cache... $file"
if [ ! -e "$backup_dir/$(basename $file)" ]; then
aria2c -c -Z -x8 -j8 -s8 -d "$backup_dir" "${2}${file}"
aria2c -c -Z -x8 -j8 -s8 -d "$backup_dir" "${remote_source}${file}"
fi
tar -I zstd -xf "$backup_dir/$(basename $file)" --dereference -C /
echo "Backup '$file' processed"