Perform this process on lxd-primary. First thing you need to do is create a script that will run by a cron in /usr/local/sbin called "refresh-containers" :
sudo vi /usr/local/sbin/refreshcontainers.sh
The script is pretty minimal:
#!/bin/bash
# This script is for doing an lxc copy --refresh against each container, copying
# and updating them to the snapshot server.
for x in $(/var/lib/snapd/snap/bin/lxc ls -c n --format csv)
do echo "Refreshing $x"
/var/lib/snapd/snap/bin/lxc copy --refresh $x lxd-snapshot:$x
done
This will create a log in lxdadmin's home directory called "refreshlog" which will give you knowledge of whether your process worked or not. Very important!
The automated procedure will fail sometimes. This generally happens when a particular container fails to refresh. You can manually re-run the refresh with the following command (assuming rockylinux-test-9 here, is our container):