Instantly share code, notes, and snippets.

Embed
What would you like to do?
Simple script to backup LXC containers
#!/usr/bin/env bash
set -ex
BACKUP_DIR=/path/to/where/backups/should/live
HOSTS=($(lxc list -c n --format csv))
for HOST in "${HOSTS[@]}"
do
BACKUP_NAME=${HOST}-$(date +"%Y-%m-%d")
lxc snapshot ${HOST} auto-backup
lxc publish ${HOST}/auto-backup --alias ${BACKUP_NAME}
lxc image export ${BACKUP_NAME} ${BACKUP_DIR}/${BACKUP_NAME}.tar.gz
lxc image delete ${BACKUP_NAME}
lxc delete ${HOST}/auto-backup
done
@bmullan

This comment has been minimized.

bmullan commented Nov 26, 2018

Drew...

You might consider adding the compliment of this lxc-backup.sh script that does the "restore".

Brian

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment