fork stop container

This commit is contained in:
2024-01-28 20:50:55 +01:00
parent 02bbcc3878
commit 1fb20e7f88
7 changed files with 835 additions and 39 deletions

View File

@@ -3,29 +3,27 @@
## Backup and restore LXD config ##
## Today's date ##
if [[ $1 = '' ]]
then
if [[ $1 != 'virtual-machine' ]] && [[ $1 != 'container' ]]; then
echo "use $0 virtual-machine|container"
exit
fi
NOW=$(date +'%m-%d-%Y')
echo $(date) "Starting backup of LXD ..."
## Dump LXD server config ##
echo $(date) "Making backup of lxd.config ..."
lxd init --dump > "/nfs/nas/LXD-Backup/lxd.config.${NOW}"
lxd init --dump >"/nfs/nas/LXD-Backup/lxd.config.${NOW}"
## Dump all instances list ##
echo $(date) "Making backup of lxd.instances.list ..."
lxc list > "/nfs/nas/LXD-Backup/lxd.instances.list.${NOW}"
lxc list >"/nfs/nas/LXD-Backup/lxd.instances.list.${NOW}"
## Make sure we know LXD version too ##
echo $(date) "Making backup of lxd.version ..."
snap list lxd > "/nfs/nas/LXD-Backup/lxd-version.${NOW}"
snap list lxd >"/nfs/nas/LXD-Backup/lxd-version.${NOW}"
## Backup all container Instances
for i in $(lxc list type=$1 -c n --format csv)
do
for i in $(lxc list type=$1 -c n --format csv); do
echo $(date) "Making backup of ${i} ..."
lxc export "${i}" "/nfs/nas/LXD-Backup/${i}-backup-$(date +'%m-%d-%Y').tar.xz" --optimized-storage
done