Integration of LXD with third party backups software for complete erase and restore

Firstly thanks for all the work on LXD, it’s looking really nice with some of the recent features which have been added…

I’m using lxd alongside various other systems (e.g. third party hosting, VMs, and bare metal), and I’d like to be able to keep the same backup solutions across all systems if possible. Individual file restore with LXD containers works just the same as it would with anything else, but the functionality I’m finding awkward is carrying out complete restores.

I realise that lxd has internal backup mechanisms, but it’s useful to have deduplication (e.g. Restic, BackupPC et al), and keep things consistent across system types.

What I’m doing at the moment is:

  • Destroy container
  • Recreate container from original OS image
  • Restore e.g. pipe a tar type backuppc restore into lxc exec container -- tar --acls --xattrs -xplf -

This feels a bit messy, and it’d be nicer to be able to e.g.:

  • Execute a command on the host which is somehow “placed into”, or otherwise has filesytem access to the container (perhaps a “restore” container or chroot, which has access to the main container root filesystem)
  • rsync into the container root filesystem from the lxd host (whilst somehow taking care of UID mappings) - this latter functionality is also useful for e.g. forensics for compromised systems

Does any of the functionality exist already e.g. some functionality of the lxc command that I’m missing, or perhaps an add-on utility with some functionality like lxd-p2c - or could this be reasonably easily added? I think a few simple primitives would be all that’s necessary to script / implement the functionality for multiple 3rd party backup systems…