My LXD Backups are too BIG!

LXD Backups are performed with the “export” command or from the “Backups” tab in LXD Dashboard.

lxc export myapp  myapp.tar.gz

If you get an error that says that “read/write closed on pipe” this in an indication that the root file system might be running out of space. You can check the free space on your root file system with:

df /

The “lxc export” command performs two operations. The first is to store the container data from the container and the second is to write the file out to the file name that you specified.

The first operation uses scratch space on your root (/) device during the backup operation that is deleted afterwards.

If the root device is filling up, you can create a storage pool on another disk and use it for your backups.

In the following command, I create a storage pool named “backup” and I point it to the mount point of a larger disk.

lxc storage create backup dir source=/mnt/bigdisk 

Next, create a storage volume in the new storage pool.

lxc storage volume create backup backup-volume 

Tell LXD to use this new area for the intermediate storage while creating all backups.

lxc config set storage.backups_volume=backup/backup-volume 

Now you can perform another backup.

lxc export myapp  myapp.tar.gz

This time, the scratch space will not be on the root device and instead will be in the “/mnt/bigdisk” location.