Skip to content

Commit 484caa7

Browse files
authored
Merge pull request #258 from regnare/master
feat: Make backup mode configurable (support for HA clusters)
2 parents 36d48f4 + c2e5cd8 commit 484caa7

File tree

2 files changed

+16
-4
lines changed

2 files changed

+16
-4
lines changed

update.conf

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,13 @@ BACKUP="false"
9898
# On some setups, snapshot is not possible if mount points are used
9999
# If you want to make a backup instead of a snapshot, set this to true
100100
BACKUP_LXC_MP="true"
101+
# Backup Mode
102+
# Choose the mode for the backup: "stop", "suspend", or "snapshot".
103+
# "stop" = Stops the VM/CT (Highest consistency, causes downtime). NOT compatible with HA.
104+
# "suspend" = Suspends the VM/CT (Good consistency, minimal downtime). Compatible with HA.
105+
# "snapshot" = Live backup (Lowest consistency, no downtime). Requires supported storage (e.g., LVM-Thin, ZFS, Ceph).
106+
# Default: stop
107+
BACKUP_MODE="stop"
101108

102109
┌──────────────────────────────────────────────┐
103110
│ Extra Updates │
@@ -141,4 +148,4 @@ CHECK_RUNNING_VM="true"
141148
└──────────────────────────────────────────────┘
142149

143150
ONLY_UPDATE_CHECK="check-only" # `check-only` is an example Tag
144-
EXCLUDE_UPDATE_CHECK="check-exclude" # `check-exclude` is an example Tag
151+
EXCLUDE_UPDATE_CHECK="check-exclude" # `check-exclude` is an example Tag

update.sh

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -417,6 +417,7 @@ READ_CONFIG () {
417417
KEEP_SNAPSHOT=$(awk -F'"' '/^KEEP_SNAPSHOT/ {print $2}' "$CONFIG_FILE")
418418
BACKUP=$(awk -F'"' '/^BACKUP=/ {print $2}' "$CONFIG_FILE")
419419
BACKUP_LXC_MP=$(awk -F'"' '/^BACKUP_LXC_MP=/ {print $2}' "$CONFIG_FILE")
420+
BACKUP_MODE=$(awk -F'"' '/^BACKUP_MODE=/ {print $2}' "$CONFIG_FILE")
420421
LXC_START_DELAY=$(awk -F'"' '/^LXC_START_DELAY=/ {print $2}' "$CONFIG_FILE")
421422
VM_START_DELAY=$(awk -F'"' '/^VM_START_DELAY=/ {print $2}' "$CONFIG_FILE")
422423
EXTRA_GLOBAL=$(awk -F'"' '/^EXTRA_GLOBAL=/ {print $2}' "$CONFIG_FILE")
@@ -453,8 +454,10 @@ CONTAINER_BACKUP () {
453454
fi
454455
fi
455456
if [[ "$BACKUP" == true ]]; then
457+
# Use BACKUP_MODE from config, default to 'stop' if not set
458+
MODE=${BACKUP_MODE:-stop}
456459
echo -e "💾${OR:-} Create a backup for LXC (this will take some time - please wait)${CL:-}"
457-
vzdump "$CONTAINER" --mode stop --notes-template "{{guestname}} - Ultimate-Updater" --storage "$(pvesm status -content backup | grep -m 1 -v ^Name | cut -d ' ' -f1)" --compress zstd
460+
vzdump "$CONTAINER" --mode "$MODE" --notes-template "{{guestname}} - Ultimate-Updater" --storage "$(pvesm status -content backup | grep -m 1 -v ^Name | cut -d ' ' -f1)" --compress zstd
458461
echo -e "${GN:-} Backup created${CL:-}\n"
459462
if [[ $BACKUP_RESET == true ]]; then
460463
BACKUP=$(awk -F'"' '/^BACKUP=/ {print $2}' "$CONFIG_FILE")
@@ -481,8 +484,10 @@ VM_BACKUP () {
481484
fi
482485
fi
483486
if [[ "$BACKUP" == true ]]; then
487+
# Use BACKUP_MODE from config, default to 'stop' if not set
488+
MODE=${BACKUP_MODE:-stop}
484489
echo -e "💾${OR:-} Create a backup for the VM (this will take some time - please wait)${CL:-}"
485-
vzdump "$VM" --mode stop --storage "$(pvesm status -content backup | grep -m 1 -v ^Name | cut -d ' ' -f1)" --compress zstd
490+
vzdump "$VM" --mode "$MODE" --storage "$(pvesm status -content backup | grep -m 1 -v ^Name | cut -d ' ' -f1)" --compress zstd
486491
echo -e "${GN:-} Backup created${CL:-}"
487492
fi
488493
else
@@ -1343,4 +1348,4 @@ if [[ "$COMMAND" != true ]]; then
13431348
fi
13441349
fi
13451350

1346-
exit 0
1351+
exit 0

0 commit comments

Comments
 (0)