I’m looking for a way to automatically create backups of my instances and custom volumes or a tool that will synchronize the snapshots created with incus to an external drive or a remote server.
It should also do a cleanup of the snapshots on the external drive or the remoteserver.
Does anybody have a working and reliable solution for that?
Conceptually, what I do is go over all instances, run incus export $INSTANCE $INSTANCE-backup.tar.gz, and then feed that tarball to BorgBackup with borg import-tar $BORG_ARCHIVE $INSTANCE-backup.tar.gz, where $BORG_ARCHIVE is the name of the BorgBackup archive that I want to create.
That has the advantage of making both individual files in the archive accessible (at least for containers, where the contents of the root disk is stored as individual files - for VMs, the archive just contains the VM image as a blob), and allows easy restoration of an entire VM/Container by getting the exported tar file back with borg export-tar ... and then running incus import ... on the result.
In reality, things are a bit more complicated, unfortunately - incus export ... can’t stream the tar file but insists on creating an intermediate file on disk (which can get huge for bigger VMs or containers, and also is quite slow), and it can’t (at least to my knowledge) create a consistent export of a running VM or container that is backed by ceph storage. So what I’m actually doing for the backup is run a (messy) script that takes ceph snaphots of the underlying storage, mounts those snapshots in a structure that resembles the structure of the archive that incus export would create, assemble the contents of the index.yaml in that archive (that’s the messy part of the script) and run borg create directly on that structure…
thank you very much for your answer. now that i have thought about it a bit, i think a solution with replication of the zfs dataset would be better.
i used to use znapzenz, but i don’t think i can suppress the creation of snapshots here. Of course, it would be an advantage if the snapshots created by incus itself could be used. (I create these once a day).
I came across sanoid or syncnoid and now want to test it out.
if anyone has experience with it or with another tool, i look forward to recommendations
Most of the functionality of sanoid/syncoid is already built into incus, using scheduled snapshots and incus copy --refresh or incus storage volume copy --refresh. The target server must also be an incus server, also with a zfs storage pool, but it doesn’t have to be in the same cluster.
All you need to do is to schedule the appropriate copy commands to run periodically for each container. I don’t know if anyone has wrapped that up into a tidy little script yet.
More info (including links to the relevant documentation sections) in this post: