I often feature LXD Dashboard on the channel as an excellent GUI interface to manage LXD containers on multiple LXD hosts. In my video tutorials, I demonstrate the installation of LXD Dashboard in a LXD container.
This is a best practice rather than installing LXD Dashboard directly on a LXD host. The possible downside is that container backups (exports) performed from inside of the GUI end up being stored inside of the container.
To me, that is not a best practice since backups should be accessible from outside LXD. In addition, in my initial tutorials, I show how to add a LXD server by using the host IP address and giving it a proxy name.
The downside to this approach is that backups are stored inside of the /var/lxdware/backups folder and a folder named by the IP address of the LXD server is created. Inside it is a folder named for the storage pool (example “default”) and inside it is created a folder with the name of the LXD container. The actual exported backups are contained inside of that folder.
There is a better way.
Initially, my LXD Dashboard had the servers added by IP address.
As mentioned above, this makes the backup folders named by the IP address.
The thing that I was unaware of is that LXD containers by default do not resolve local DNS for some odd reason. So, I installed and configured resolvconf inside of my LXD Container where I have LXD Dashboard running. Now my local DNS resolves and I deleted my server entries and added them again with DNS names rather than addresses.
Inside of your LXD Dashboard container you can add local DNS resolution assuming you have local DNS on your network:
sudo apt install resolvconf
Edit the file containing the DNS server entries:
sudo nano /etc/resolvconf/resolv.conf.d/head
I added two of my local DNS’s.
Next, shutdown and restart your LXD-Dashboard LXD container and you should have a working local DNS.
I then deleted all of my LXD Host entries from LXD Dashboard and added them again, but with the local DNS names. Here is how it looks now.
Now when I do backups, they are stored in a directory structure with the dns name of the server rather than an IP address. In any event, with LXD Dashboard installed as a LXD container, we know that backups reside in /var/lxdware/backups.
I want my backup exports to be stored on the LXD host rather than in the container and that makes sense. So I point my backup folder accordingly on my LXD Host. Adjust your source accordingly.
An important consideration is that all of the “lxc” commands are executed from the LXD Server and not from within any container. Also, in my following example, if you want to use a source folder named “/home/scott/LXDImages”. It must first exist. So, you might want to “mkdir -p /home/scott/LXDImages” first. Choose the naming that you want.
lxc config device add LXD-Dashboard lxdbackups disk source=/home/scott/LXDImages path=/var/lxdware/backups
So, this does have the effect of pointing the backups outside of the container and putting them on the LXD Host in /home/scott/LXDImages in my case.
However, we also need a privilege mapping for the user account to make the target writable. So, still on the LXD host where you have LXD Dashboard running:
echo "root:1000:1" | sudo tee -a /etc/subuid /etc/subgid
Then I needed to configure the LXD Dashboard container to use that mapping:
lxc config set LXD-Dashboard raw.idmap "both 1000 1001"
At this point, a backup of any container from LXD-Dashboard writes its backups in “/home/scott/LXDImages” on the LXD host where LXD backup is running using my example from above. In my case, that is the VMSMist host.
The other issue is that the storage on VMSMist is limited and so I use “/home/scott/LXDImages” as a mount point for an NFS export from a NAS I have with lots of storage.
I end up adding a mount for this in the fstab of VMSMist:
172.16.1.58:/LXDImages /home/scott/LXDImages nfs defaults 0 0
In this way, the LXD Backups from all five of my LXD Servers that you can see above store their exported backups on the NAS via NFS.