I was experimenting with using a lxc copy --refresh as a poor man’s HA cluster and realized that every lxc copy --refresh leaves the @migration snapshots on the zfs filesystem by default, probably rightfully so as it can not assume that one has only one destination that one is "copy --refresh"ing to. This is quite dangerous for someone that isn’t aware of it, as I’ve learned the hard way by running out of disk space
However, that does not happen if one copies within the same host (or maybe storage pool?). Not sure what was the thinking here, that it is cheap enough to do a full copy all the time? Or is it a bug?
That being said, maybe it would be a nice feature to add, actually two features:
- add a --id option (or construct one automatically from e.g. the destination remote or nodename) and use that as part of the snapshot name and then clean up all but the last snapshot after successful lxc copy --refresh
- add a --zfs-bookmark option that would create a bookmark after the copy --refresh and clean up all the snapshots with the same id on the source, so that they don’t waste the disk space.
default remote is a cluster, alexsv is my local single instance
~$ lxc launch u20 migtest --target lxd12
Creating migtest
Starting migtest
~$ ssh lxd12 zfs list lxd12/lxd/containers/migtest -r -t all
NAME USED AVAIL REFER MOUNTPOINT
lxd12/lxd/containers/migtest 10.3M 14.4G 645M legacy
~$ lxc copy --refresh migtest alexsv:
~$ ssh lxd12 zfs list lxd12/lxd/containers/migtest -r -t all
NAME USED AVAIL REFER MOUNTPOINT
lxd12/lxd/containers/migtest 10.3M 14.4G 645M legacy
~$ lxc copy --refresh migtest alexsv:
~$ ssh lxd12 zfs list lxd12/lxd/containers/migtest -r -t all
NAME USED AVAIL REFER MOUNTPOINT
lxd12/lxd/containers/migtest 10.6M 14.4G 645M legacy
lxd12/lxd/containers/migtest@migration-b893e86b-66e6-407f-85d7-d4dab43ce20c 304K - 645M -
however:
~$ lxc copy --refresh migtest migtest-copy --target lxd11
~$ ssh lxd12 zfs list lxd12/lxd/containers/migtest -r -t all
NAME USED AVAIL REFER MOUNTPOINT
lxd12/lxd/containers/migtest 10.6M 14.4G 645M legacy
lxd12/lxd/containers/migtest@migration-b893e86b-66e6-407f-85d7-d4dab43ce20c 304K - 645M -
lxd12/lxd/containers/migtest@migration-1372dc3c-9d2f-4a73-b0a6-88d5507754b9 0B - 645M -
~$ lxc copy --refresh migtest migtest-copy2 --target lxd12
~$ ssh lxd12 zfs list lxd12/lxd/containers/migtest -r -t all
NAME USED AVAIL REFER MOUNTPOINT
lxd12/lxd/containers/migtest 10.6M 14.4G 645M legacy
lxd12/lxd/containers/migtest@migration-b893e86b-66e6-407f-85d7-d4dab43ce20c 304K - 645M -
lxd12/lxd/containers/migtest@migration-1372dc3c-9d2f-4a73-b0a6-88d5507754b9 0B - 645M -
lxd12/lxd/containers/migtest@copy-6e776fcc-8a89-410d-a360-143c10e2cba2 0B - 645M -
~$ ssh lxd12 zfs list lxd12/lxd/containers/migtest -r -t all
NAME USED AVAIL REFER MOUNTPOINT
lxd12/lxd/containers/migtest 10.6M 14.4G 645M legacy
lxd12/lxd/containers/migtest@migration-b893e86b-66e6-407f-85d7-d4dab43ce20c 304K - 645M -
lxd12/lxd/containers/migtest@migration-1372dc3c-9d2f-4a73-b0a6-88d5507754b9 0B - 645M -
lxd12/lxd/containers/migtest@copy-6e776fcc-8a89-410d-a360-143c10e2cba2 0B - 645M -
~$ lxc copy --refresh migtest migtest-copy2 --target lxd12
~$ ssh lxd12 zfs list lxd12/lxd/containers/migtest -r -t all
NAME USED AVAIL REFER MOUNTPOINT
lxd12/lxd/containers/migtest 10.7M 14.4G 645M legacy
lxd12/lxd/containers/migtest@migration-b893e86b-66e6-407f-85d7-d4dab43ce20c 304K - 645M -
lxd12/lxd/containers/migtest@migration-1372dc3c-9d2f-4a73-b0a6-88d5507754b9 68K - 645M -
lxd12/lxd/containers/migtest@copy-d84426b1-61d2-4a23-b88c-b4d66631afa3 0B - 645M -
~$ lxc copy --refresh migtest migtest-copy --target lxd11
~$ ssh lxd12 zfs list lxd12/lxd/containers/migtest -r -t all
NAME USED AVAIL REFER MOUNTPOINT
lxd12/lxd/containers/migtest 10.7M 14.4G 645M legacy
lxd12/lxd/containers/migtest@migration-b893e86b-66e6-407f-85d7-d4dab43ce20c 304K - 645M -
lxd12/lxd/containers/migtest@migration-1372dc3c-9d2f-4a73-b0a6-88d5507754b9 68K - 645M -
lxd12/lxd/containers/migtest@copy-d84426b1-61d2-4a23-b88c-b4d66631afa3 0B - 645M -
lxd12/lxd/containers/migtest@migration-47a33898-8170-43bb-85bf-445bdf0d656b 0B - 645M -