Create a "importable" backup with a snapX folder as source

is it possible to just store (tar -cf …) a snapshot folder like (/var/snap/lxd/common/lxd/storage-pools/default/containers-snapshots/c2/snap0) and import it as an backup?

I try some more or less dirty tricks, like:

  • create an container, make a snapshot and replace the files.
  • use lxc image import and create a container from the image.

Both ways “worked” but it doesn’t feel right. But with just copy the snap0 folder, it would be posible to stream directly the archive to an remote borg repo (or anything else)

Currently, I create uncompressed (borg is compressing later) “instance-only” tar’s and stream them. But that need some additional time and space I want to avoid.

Hi @qupfer,
Have you ever examined that link?

Hi @cemzafer and thanks for your answer.
And yes, I already know that link but I think you misunderstood what I mean.

I want to store snapshots of an instance directly without lxc export [...] to avoid lot of disk wirtes on the lxd host.
Basicly, I want just send a snap0 folder of an instance and import it as an instance later.

lxc export (or lxc storage volume export) put all together in an temp. folder and create from there a (compressed) tar archive.
If my container is 10GB, this will write 10 GB to the temp folder and again <10GB (depending of compression) to the final tar-archiv. And as I want an uncompressed tar as input for borg, this would mean:
Backup of a 10 GB container need 20 GB diskwrite.

I also tried lxc export --compression=none --instance-only c2 - | dd of=dd_will_be_replaced_with_brog.tar to avoid at least writing of the full tar-archive but
thats created not a valid tar file.

However, this peace of dirty bash scripting seems working :smiley:



lxc snapshot "$container_name"  "$snapshot_name" --reuse

prefix=$(cat <<-EOF
name: $container_name
backend: btrfs
pool: default
optimized: false
optimized_header: false
type: container
container_info=$(sed 's/^/  /' "$snapshot_path/$container_name/$snapshot_name/backup.yaml")

printf "${prefix}\n${container_info}" >  /tmp/index.yaml

tar -c -O  -C "$snapshot_path/$container_name/"  --transform "s/$snapshot_name/backup\/container/" "$snapshot_name" -C /tmp --transform "s/^index.yaml/backup\/index.yaml/" index.yaml | dd bs=1M of=/tmp/dd_will_be_replaced_with_brog.tar

1 Like

Humm, i see. Glad you did it. :+1:

I believe you can copy a snapshot to another instance, and then export that, e.g.

lxc copy c1/snap0 c2
lxc export c2 c2.tar.gz