
VM Backup Several Times a Day on Synology: A Script for Free VMM
10 min read
- View as Markdown Open this page as plain Markdown (opens in a new tab)
- Open in ChatGPT Ask questions about this page (opens in a new tab)
- Open in Claude Ask questions about this page (opens in a new tab)
- Open in Google AI Studio Ask questions about this page (Google account required) (opens in a new tab)
A VM backup that runs once a day can lose almost a full day of orders, mail or records. Virtual Machine Manager (VMM) on a Synology NAS lets you schedule an export daily, weekly or monthly, and nothing more often than that. On 3 December 2026 we set up a spare NAS with no VMM Pro license and tested another route: calling the same export function from a script, as often as we like, while the virtual machine keeps running. It worked. This article covers how that VM backup behaves: what we measured, the script, how to schedule it, and the traps we hit on the way.
SynoPower Club Point: Our store runs inside Virtual Machine Manager, and one export a day always felt thin for a shop that takes orders around the clock. I wanted a second and third copy without buying more hardware. The test took one afternoon on a single spare unit. The surprise was not that it worked, it was how much the script has to check for itself, because VMM will happily start a new export on top of one that is still running.
What Limits a VM Backup in VMM? #
The built-in VM backup option lives under Action, Export, Scheduled. You pick a destination folder, an export mode, the days and one start time. The list of days offers Daily, Weekly and Monthly. There is no hourly choice, and no way to add a second time.

A manual VM backup has no such limit, but someone has to click it. Our script does that click for you.
VM Backup: Snapshots or Exports? #
Before adding exports, decide what you are protecting against. Snapshots are fast and can run often, but they stay on the same volume as the guest. If the NAS or the volume fails, they go with it. An export is a separate OVA file that you can copy somewhere else.
| Method | How often | Survives a failed volume? |
|---|---|---|
| VMM snapshot | Very often, low cost | No |
| Scheduled export in VMM | Once a day at most | Only if copied elsewhere |
| Scripted export | As often as the export time allows | Only if copied elsewhere |
If you only want closer restore points, snapshots are the cheaper answer. If you want a portable VM backup several times a day, keep reading.
What We Tested for This VM Backup #
The VM backup test unit was a Synology FS1018 on DSM 7.4.1 with Virtual Machine Manager 2.8.0-13004, one host, no VMM Pro license. The guest was a small Ubuntu 24.04 machine with a 10 GB virtual disk, about 2.4 GB in use, and the QEMU Guest Agent installed.
| Test | Result |
|---|---|
| Export while the guest is running | Works on the free edition |
| Time per export | 115 to 140 seconds |
| File size | About 814 million bytes (776 MB in File Station) |
| Custom file name through the export call | Ignored, the file is named after the guest |
| Same file name already present | Kept, new file gets (1), (2) |
| Second export started while one is running | Accepted, both run at once |
These VM backup numbers belong to a very small guest. Measure your own before you pick an interval.
Is a Running VM Backup Consistent? #
With the QEMU Guest Agent installed, VMM labels the export as file system consistent. The agent pauses file system writes for a moment while the copy point is taken. We checked inside the guest: every scripted run left one guest-fsfreeze entry in the agent log.

File system consistent is not the same as application consistent. A busy database can still hold transactions in memory, so keep a database dump as well. Without a guest agent, expect a weaker state, similar to the machine losing power.
How to Run a VM Backup in 4 Steps #
You need an administrator account with SSH access, a shared folder for the files, and free space for several copies of the guest.
Prepare the folder and the guest #
Create a shared folder for the export files, for example vmexp. Install the QEMU Guest Agent or the Synology Guest Tool inside the virtual machine.
Install the script #
Save the script below as vm-export.sh in a folder that only root can write to, outside any web folder, then restrict its permissions.
Run it once by hand #
Over SSH, run the script as root with the virtual machine name, the shared folder name and the number of copies to keep. Wait for the OK line.
Schedule it #
In Control Panel, open Task Scheduler, create a user-defined script owned by root, and set it to repeat within the day.
The script takes three arguments:
sudo bash /volume1/@vm-export/vm-export.sh exptest vmexp 7
The VM Backup Script #
The VM backup script starts the export, waits until VMM has removed its temporary copy, checks that the archive can be listed, renames it with a timestamp, and only then deletes the oldest files of that guest. A failed run exits with an error and deletes nothing.
#!/bin/bash
# Export one VM while it runs, give the file a timestamped name,
# and keep only the newest KEEP copies. Run as root.
# Tested on VMM 2.8.0-13004. It uses internal APIs: retest after upgrades.
# usage: vm-export.sh VM_NAME SHARE_NAME KEEP
NAME=$1; SHARE=$2; KEEP=$3
[ -n "$NAME" ] && [ -n "$SHARE" ] && [ "$KEEP" -ge 1 ] 2>/dev/null || { echo "usage: $0 vm_name share_name keep"; exit 2; }
DIR=$(/usr/syno/sbin/synoshare --get "$SHARE" | sed -n 's/.*Path.*\[\(.*\)\].*/\1/p')
[ -d "$DIR" ] || { echo "share not found: $SHARE"; exit 2; }
BASE=$(dirname "$0"); LOG="$BASE/vm-export.log"
log(){ echo "$(date '+%F %T') [$NAME] $*" | tee -a "$LOG"; }
api(){ /usr/syno/bin/synowebapi --exec "$@" 2>/dev/null; }
# one export at a time on this NAS
exec 9>"$BASE/.lock"; flock -n 9 || { log "SKIP: previous run still active"; exit 0; }
# prints: guest_id, number of temporary export guests still present
state(){ api api=SYNO.Virtualization.Guest method=list version=1 | python3 -c '
import json,sys
g=json.load(sys.stdin)["data"]["guests"]
ids=[x["guest_id"] for x in g if x["name"]==sys.argv[1]]
tmp=sum(x.get("birth_info",{}).get("method")=="online_export" for x in g)
print(ids[0] if ids else "-", tmp)' "$NAME"; }
read -r ID TMP < <(state)
[ -n "$ID" ] && [ "$ID" != "-" ] || { log "FAIL: VM not found"; exit 1; }
[ "$TMP" = 0 ] || { log "SKIP: VMM is still exporting"; exit 0; }
OUT="$DIR/$NAME.ova"
[ -e "$OUT" ] && { log "FAIL: $OUT already exists, move it first"; exit 1; }
# running guest: online_export, powered-off guest: export
M=online_export
api api=SYNO.Virtualization.Guest method=list version=1 | python3 -c 'import json,sys;sys.exit(0 if [x for x in json.load(sys.stdin)["data"]["guests"] if x["guest_id"]==sys.argv[1]][0]["status"]=="running" else 1)' "$ID" || M=export
R=$(api api=SYNO.Virtualization.Guest.Action method=$M version=1 guest_id="\"$ID\"" target_ova_path="\"/$SHARE\"" ova_mode=0 name="\"$NAME\"")
echo "$R" | grep -q '"success" : true' || { log "FAIL: API refused $(echo $R)"; exit 1; }
log "start $M"; T0=$(date +%s)
while :; do
sleep 15
read -r _ TMP < <(state)
[ "$TMP" = 0 ] && [ -s "$OUT" ] && tar -tf "$OUT" >/dev/null 2>&1 && break
[ $(($(date +%s)-T0)) -gt 14400 ] && { log "FAIL: not finished after 4 hours"; exit 1; }
done
NEW="$DIR/$NAME-$(date '+%Y-%m-%d %H-%M-%S').ova"
mv "$OUT" "$NEW" || { log "FAIL: rename failed"; exit 1; }
log "OK $(($(date +%s)-T0))s $(stat -c %s "$NEW") bytes ${NEW##*/}"
# prune only after success, only this VM's timestamped files
ls -1 "$DIR" | grep -E '\-[0-9]{4}-[0-9]{2}-[0-9]{2} [0-9]{2}-[0-9]{2}-[0-9]{2}\.ova$' \
| awk -v p="$NAME-" 'index($0,p)==1 && length($0)==length(p)+23' | sort -r | tail -n +$((KEEP+1)) \
| while IFS= read -r f; do rm -f -- "$DIR/$f" && log "removed $f"; done
The script is also on GitHub under the MIT license: synology-vm-backup.
Two limits matter. The lock is shared by the whole NAS, so if two guests are scheduled for the same minute, the second one is skipped and only the log says so. Run several guests one after another in one task, or give them different times. And if a plain file named after the guest is already in the folder, the script stops and asks you to move it.
It also relies on internal calls that the VMM interface uses. In version 2.8.0-13004 the public Virtualization API on this unit offered power and clone actions but no export, so retest after every VMM update.
Scheduling the VM Backup Every 6 Hours #
DSM Task Scheduler can repeat a task within the same day, from every hour upward. We chose every 6 hours, with the last run at 18:00, which gives four copies a day.

On the Task Settings tab, enter the command and turn on email details for abnormal termination. DSM needs email notification set up before it can send anything.

To be clear about scope: we ran the script by hand four times in a row, including an overlapping start. We filled in this task form for the screenshots but did not leave it running on a schedule.
Where Do the Files Go Next? #

A VM backup on the same NAS as the guest protects you from mistakes, not from a dead box. Copy the files to another NAS or to cloud storage. The script writes names without colons, which matters because colon timestamps stopped our Cloud Sync uploads before, as described in VMM Backup to Google Drive.
One caution: while an export is still being written, a file named after the guest can already appear in the share, at zero bytes. A sync tool watching that folder might pick up an unfinished file. We have not tested Cloud Sync with this script.
Plan the space too. Our small guest at four runs a day and seven copies kept needs under 6 GB. A 7 GB export with 28 copies, one week at that pace, needs close to 200 GB.
Can You Restore This VM Backup? #
A VM backup is only real once you have restored it. We unpacked the first OVA, built a new virtual machine from the disk inside it, and booted it. The marker file written before the export was there. A line added after the export was not, which is exactly right.
The new machine had no network at first. The Ubuntu cloud image ties its network settings to the old MAC address, and a rebuilt machine gets a new one. If the original machine is gone, you can set the old MAC address on the restored one in its network settings. VMM refuses while another virtual machine still holds that address.
We did not test the Import wizard in the VMM interface, or a Virtual DSM guest. Test your own restore path before you rely on it.
More Official Resources and Related Reading #
- Synology: import and export virtual machines
- Synology Help: Virtual Machine
- Synology Help: Task Scheduler
- Virtual Machine Manager release notes
- QEMU Guest Agent documentation
On this site, see Virtual Machine Manager vs VMM Pro for what the free edition already does, and our three-node cluster for a production setup with replication.
The free edition is enough for everything in this article. Replication to a second host and high availability are VMM Pro features. SynoPower Club sells genuine licenses, with keys delivered by email.
FAQ #
Can a VM backup run more than once a day? #
Yes. The VMM schedule stops at daily, but a script run by DSM Task Scheduler can start an export several times a day.
Do I need VMM Pro for this? #
No. We tested on a single host without a VMM Pro license.
Does the virtual machine shut down? #
No. It stays running. With a guest agent, file system writes pause briefly.
How long does a VM backup take? #
Our small test guest took 115 to 140 seconds. Larger guests take longer, so measure yours.
Can two exports run at the same time? #
VMM allows it, even for the same guest. The script blocks this with a lock.
Are old files deleted automatically? #
The script keeps the newest number you choose, only for that guest, and only after a successful run.
What happens after a VMM update? #
The script uses internal calls, so run it by hand and test a restore after each update.
Is a local copy enough? #
No. Copy the files off the NAS, or one hardware failure can take both the guest and the copies.






