Backup/restore qube metadata?

Is there a way to backup/restore qube metadata by itself? That is, make a backup of a qube but without the contents of its volumes? I’m looking for any method at all, whether it’s a tool, or series of system commands, or some sort of API calls.

1 Like

Nothing native. You can look in /usr/lib/python3.13/site-packages/qubesadmin
and dig at backup/core3.py and associated files, or roll your own from
prefs,features,tags,firewall etc

I never presume to speak for the Qubes team.
When I comment in the Forum I speak for myself.

3 Likes

I’ve also often wanted to have some kind of qvm-backup(-restore) --metadata-only mode.

Backing up the metadata is easy enough to do manually, by making a copy of /var/lib/qubes/qubes.xml and /var/lib/qubes/*/*/firewall.xml. That’s basically what qvm-backup does.

But how to restore qubes.xml… Not so easy if only some VMs should be restored, or if restoring to a newer Qubes OS release.

4 Likes

That’s why it’s easier to use the native tools. Then you can create a new
qube and push the relevant features on to it. (Unless you want something
different from this?)

1 Like

IMO it’s better not to try and reimplement the backup/restore logic at all, because especially the restore side (dealing with dependencies etc.) is super tricky.

If someone wants to explore this, the logic that handles non-save_on_stop volumes looks promising. Maybe extending it to all volumes if a global metadata-only flag is active would be enough.

2 Likes

That^ worked, as far as I can tell. In case someone desperately needs an experimental VM metadata backup/restore system right now:

I changed the condition in /usr/lib/python*/site-packages/qubes/backup.py to if True:, then ran systemctl restart qubesd and qvm-backup --exclude=dom0. It took around 5 minutes to back up the metadata of ~ 100 VMs and resulted in a 1 MB backup file; some room for improvement. There were a few minor UI glitches too, such as finishing at 433% progress.

Made the same change in /usr/lib/python*/site-packages/qubesadmin/backup/restore.py; no qubesd restart needed for that one. qvm-backup-restore of one test VM appeared to restore it faithfully, except that its (empty) restored volumes had the default size instead of the original size that was correctly recorded in the backup file. Doesn’t bother me (cause afterwards I’d be restoring the volume contents out-of-band anyway), but I think I see how to fix that.

(Don’t forget to undo your changes before doing a regular backup or restore again!)

2 Likes