mirror of
https://github.com/community-scripts/ProxmoxVE.git
synced 2026-08-04 11:53:24 +02:00
Compare commits
1 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 0dcf4cff08 |
+19
-18
@@ -1292,17 +1292,14 @@ create_temp_dir() {
|
||||
# - Copies each given file/directory into a persistent store at
|
||||
# /opt/<NSAPP>.backup, mirroring its absolute path inside the store, and
|
||||
# records it in a manifest so restore_backup needs no arguments.
|
||||
# - Idempotent per path: a path already recorded in the manifest (from this
|
||||
# run or a previous failed one) is left untouched, keeping the
|
||||
# last-known-good copy instead of overwriting it with now-partially-updated
|
||||
# data on retry. Any requested path NOT yet in the manifest is backed up
|
||||
# now and appended - so a manifest left incomplete by an interrupted prior
|
||||
# run gets completed instead of silently missing paths on restore.
|
||||
# - Idempotent: if a store from a previous (failed) run already exists, it is
|
||||
# left untouched and no new backup is taken. This keeps the last-known-good
|
||||
# data instead of overwriting it with now-partially-updated data on retry.
|
||||
# - Missing source paths are skipped with a warning (not fatal).
|
||||
# - Aborts the update on copy failure: if any file/dir cannot be backed up,
|
||||
# the script exits before the update runs against unprotected data (the
|
||||
# paths already recorded are left in place, so a retry only redoes the one
|
||||
# that failed).
|
||||
# the half-written store is removed and the script exits, so the update
|
||||
# never runs against unprotected data (and a retry re-attempts a clean
|
||||
# backup rather than skipping it).
|
||||
#
|
||||
# restore_backup
|
||||
# - Copies every path recorded in the manifest back to its origin (replacing
|
||||
@@ -1321,17 +1318,19 @@ create_backup() {
|
||||
return 0
|
||||
}
|
||||
|
||||
if ! mkdir -p "$store" || ! touch "$manifest"; then
|
||||
msg_error "Backup failed: could not create store at ${store} - aborting update"
|
||||
exit 1
|
||||
if [[ -f "$manifest" ]]; then
|
||||
msg_ok "Existing backup found at ${store}, skipping backup"
|
||||
return 0
|
||||
fi
|
||||
|
||||
msg_info "Backing up data"
|
||||
if ! mkdir -p "$store" || ! : >"$manifest"; then
|
||||
msg_error "Backup failed: could not create store at ${store} - aborting update"
|
||||
rm -rf "$store"
|
||||
exit 1
|
||||
fi
|
||||
for path in "$@"; do
|
||||
path="${path%/}"
|
||||
if grep -qxF "$path" "$manifest" 2>/dev/null; then
|
||||
continue
|
||||
fi
|
||||
if [[ ! -e "$path" ]]; then
|
||||
msg_warn "Skipping backup of '${path}' (not found)"
|
||||
continue
|
||||
@@ -1339,6 +1338,7 @@ create_backup() {
|
||||
dest="${store}/files${path}"
|
||||
if ! mkdir -p "$(dirname "$dest")" || ! cp -a "$path" "$dest"; then
|
||||
msg_error "Backup of '${path}' failed - aborting update"
|
||||
rm -rf "$store"
|
||||
exit 1
|
||||
fi
|
||||
echo "$path" >>"$manifest"
|
||||
@@ -2040,8 +2040,9 @@ cleanup_orphaned_sources() {
|
||||
local basename_file
|
||||
basename_file=$(basename "$sources_file")
|
||||
|
||||
# NEVER remove debian.sources - this is the standard Debian repository
|
||||
if [[ "$basename_file" == "debian.sources" ]]; then
|
||||
# NEVER remove the distro's own base sources file (debian.sources,
|
||||
# ubuntu.sources, ...)
|
||||
if [[ "$basename_file" == "$(get_os_info id).sources" ]]; then
|
||||
continue
|
||||
fi
|
||||
|
||||
@@ -2113,7 +2114,7 @@ ensure_apt_working() {
|
||||
# Step 4: More aggressive - remove all third-party sources
|
||||
msg_warn "APT update still failing, removing third-party sources"
|
||||
find /etc/apt/sources.list.d/ -type f \( -name "*.sources" -o -name "*.list" \) \
|
||||
! -name "debian.sources" -delete 2>/dev/null || true
|
||||
! -name "$(get_os_info id).sources" -delete 2>/dev/null || true
|
||||
|
||||
# Final attempt
|
||||
if ! $STD apt update; then
|
||||
|
||||
Reference in New Issue
Block a user