update 1.2.4

This commit is contained in:
MacRimi
2026-07-22 16:39:34 +02:00
parent acebb1755d
commit 4f5ccc4933
5 changed files with 100 additions and 38 deletions

View File

@@ -221,7 +221,17 @@ read -r -p "Type YES to continue: " ans
systemctl stop pve-cluster || true
[[ -d "\$RECOVERY_ROOT/etc/pve" ]] && mkdir -p /etc/pve && cp -a "\$RECOVERY_ROOT/etc/pve/." /etc/pve/ || true
[[ -d "\$RECOVERY_ROOT/var/lib/pve-cluster" ]] && mkdir -p /var/lib/pve-cluster && cp -a "\$RECOVERY_ROOT/var/lib/pve-cluster/." /var/lib/pve-cluster/ || true
if [[ -d "\$RECOVERY_ROOT/var/lib/pve-cluster" ]]; then
mkdir -p /var/lib/pve-cluster
cp -a "\$RECOVERY_ROOT/var/lib/pve-cluster/." /var/lib/pve-cluster/ || true
# If the backup only carried the raw-fallback (no sqlite3 dump),
# promote it to config.db so pve-cluster picks it up on start.
if [[ ! -f /var/lib/pve-cluster/config.db && -f /var/lib/pve-cluster/config.db.raw-fallback ]]; then
mv -f /var/lib/pve-cluster/config.db.raw-fallback /var/lib/pve-cluster/config.db
else
rm -f /var/lib/pve-cluster/config.db.raw-fallback
fi
fi
systemctl start pve-cluster || true
echo "Cluster recovery finished."
EOF

View File

@@ -1648,6 +1648,13 @@ fi
if [[ -d "\$RECOVERY_ROOT/var/lib/pve-cluster" ]]; then
mkdir -p /var/lib/pve-cluster
cp -a "\$RECOVERY_ROOT/var/lib/pve-cluster/." /var/lib/pve-cluster/ || true
# If the backup only carried the raw-fallback (no sqlite3 dump), promote
# it to config.db so pve-cluster picks it up on start.
if [[ ! -f /var/lib/pve-cluster/config.db && -f /var/lib/pve-cluster/config.db.raw-fallback ]]; then
mv -f /var/lib/pve-cluster/config.db.raw-fallback /var/lib/pve-cluster/config.db
else
rm -f /var/lib/pve-cluster/config.db.raw-fallback
fi
fi
systemctl start pve-cluster || true

View File

@@ -525,6 +525,30 @@ hb_prepare_staging() {
: > "$selected_file"
: > "$missing_file"
# pmxcfs (/etc/pve) is served from this SQLite DB with pve-cluster
# running. A plain rsync of the raw file can catch it mid-WAL
# checkpoint. sqlite3's `.backup` is the canonical way to grab a
# consistent snapshot with the DB in use, matching Proxmox's own
# documented advice. The raw file is also kept as `.raw-fallback`
# for environments without sqlite3.
if [[ -f /var/lib/pve-cluster/config.db ]]; then
mkdir -p "$staging_root/rootfs/var/lib/pve-cluster"
if command -v sqlite3 >/dev/null 2>&1; then
if sqlite3 /var/lib/pve-cluster/config.db \
".backup '$staging_root/rootfs/var/lib/pve-cluster/config.db'" 2>/dev/null; then
echo "pmxcfs_config_db=sqlite_backup" >> "$staging_root/metadata/run_info.env.tmp"
else
cp -a /var/lib/pve-cluster/config.db \
"$staging_root/rootfs/var/lib/pve-cluster/config.db.raw-fallback" 2>/dev/null || true
echo "pmxcfs_config_db=raw_fallback" >> "$staging_root/metadata/run_info.env.tmp"
fi
else
cp -a /var/lib/pve-cluster/config.db \
"$staging_root/rootfs/var/lib/pve-cluster/config.db.raw-fallback" 2>/dev/null || true
echo "pmxcfs_config_db=raw_fallback" >> "$staging_root/metadata/run_info.env.tmp"
fi
fi
local p rel target
for p in "${paths[@]}"; do
rel="${p#/}"
@@ -541,6 +565,19 @@ hb_prepare_staging() {
--exclude "*.log"
)
# /var/lib/pve-cluster: skip the raw config.db and its WAL/SHM
# sidecars — they were already captured atomically above via
# sqlite3 .backup (or as raw-fallback when sqlite3 isn't
# available). Everything else in the directory (backup subdir,
# auxiliary state) is safe to rsync live.
if [[ "$rel" == "var/lib/pve-cluster" || "$rel" == "var/lib/pve-cluster/"* ]]; then
rsync_opts+=(
--exclude "config.db"
--exclude "config.db-wal"
--exclude "config.db-shm"
)
fi
# /root is included by default for easier recovery, but avoid volatile/sensitive noise.
if [[ "$rel" == "root" || "$rel" == "root/"* ]]; then
rsync_opts+=(
@@ -588,7 +625,11 @@ hb_prepare_staging() {
echo "generated_at=$(date -Iseconds)"
echo "hostname=$(hostname)"
echo "kernel=$(uname -r)"
if [[ -f "$meta/run_info.env.tmp" ]]; then
cat "$meta/run_info.env.tmp"
fi
} > "$meta/run_info.env"
rm -f "$meta/run_info.env.tmp"
command -v pveversion >/dev/null 2>&1 && pveversion -v > "$meta/pveversion.txt" 2>&1 || true
command -v lsblk >/dev/null 2>&1 && lsblk -f > "$meta/lsblk.txt" 2>&1 || true
command -v qm >/dev/null 2>&1 && qm list > "$meta/qm-list.txt" 2>&1 || true