Skip to content

Commit d45498b

Browse files
committed
don't delete backup before we know that we can get a new
1 parent 6ae44c1 commit d45498b

File tree

1 file changed

+12
-5
lines changed

1 file changed

+12
-5
lines changed

lib.sh

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2318,17 +2318,24 @@ fi
23182318
# Clone or refresh local backup of repository
23192319
# This runs during update to keep a fresh copy as fallback
23202320
ensure_local_backup_repo() {
2321-
local BACKUP_REPO="/var/scripts/vm-repo-backup"
2321+
local BACKUP_REPO="$SCRIPTS/vm-repo-backup"
23222322

2323-
# Install git if needed
2323+
# Check if we can reach GitHub before deleting existing backup
2324+
if ! site_200 github.com
2325+
then
2326+
print_text_in_color "$IYellow" "Cannot reach GitHub - keeping existing local backup"
2327+
return 1
2328+
fi
2329+
2330+
# Install git if needed (after confirming we have internet)
23242331
install_if_not git
23252332

23262333
# Remove old clone and get fresh copy
23272334
print_text_in_color "$ICyan" "Creating local backup of repository (in case of network issues)..."
23282335
rm -rf "$BACKUP_REPO"
23292336

2330-
# Clone with timeout, don't fail if it doesn't work
2331-
if timeout 120 git clone --depth 1 --branch main \
2337+
# Clone repository
2338+
if git clone --depth 1 --branch main \
23322339
https://github.com/nextcloud/vm.git "$BACKUP_REPO" &>/dev/null
23332340
then
23342341
chmod -R +rx "$BACKUP_REPO"
@@ -2346,7 +2353,7 @@ try_local_backup() {
23462353
local url="$1"
23472354
local file="$2"
23482355
local dest_dir="$3"
2349-
local BACKUP_REPO="/var/scripts/vm-repo-backup"
2356+
local BACKUP_REPO="$SCRIPTS/vm-repo-backup"
23502357

23512358
# Check if backup exists
23522359
if [ ! -d "$BACKUP_REPO" ]

0 commit comments

Comments
 (0)