Сделайте резервную копию контейнера и установите его на другом сервере
Say you have a container called “blah”. For backup as an image tarball, you’d do:
To restore and create a container from it, you can then do:
$ nano backup_lxd.sh
#!/usr/bin/env bash
set -ex
BACKUP_DIR=~/backup
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
Сохранить.
$ sh backup_lxd.sh
+ date +%Y-%m-%d
+ BACKUP_NAME=ud1804-2019-11-10
+ lxc snapshot ud1804 auto-backup
+ lxc publish ud1804/auto-backup --alias ud1804-2019-11-10
Контейнер публикуется с отпечатком: b900ce0db69f0a57afd52af682f8a47229b5ea8fcdfa2a566af2034a6f6766a2
+ lxc image export ud1804-2019-11-10 /home/user/backup/ud1804-2019-11-10.tar.gz
Image exported successfully!
+ lxc image delete ud1804-2019-11-10
+ lxc delete ud1804/auto-backup
Восстановление на другом компьютере:
$ lxc image import ud1804-2019-11-10.tar.gz.tar.gz --alias ud1804-backup
Образ, импортирован с снимком: b900ce0db69f0a57afd52af682f8a47229b5ea8fcdfa2a566af2034a6f6766a2
$ lxc launch ud1804-backup ud1804
#lxc image delete ud1804-backup
Say you have a container called “blah”. For backup as an image tarball, you’d do:
- lxc snapshot blah backup
- lxc publish blah/backup --alias blah-backup
- lxc image export blah-backup .
- lxc image delete blah-backup
To restore and create a container from it, you can then do:
- lxc image import TARBALL-NAME --alias blah-backup
- lxc launch blah-backup some-container-name
- lxc image delete blah-backup
$ nano backup_lxd.sh
#!/usr/bin/env bash
set -ex
BACKUP_DIR=~/backup
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
Сохранить.
$ sh backup_lxd.sh
+ date +%Y-%m-%d
+ BACKUP_NAME=ud1804-2019-11-10
+ lxc snapshot ud1804 auto-backup
+ lxc publish ud1804/auto-backup --alias ud1804-2019-11-10
Контейнер публикуется с отпечатком: b900ce0db69f0a57afd52af682f8a47229b5ea8fcdfa2a566af2034a6f6766a2
+ lxc image export ud1804-2019-11-10 /home/user/backup/ud1804-2019-11-10.tar.gz
Image exported successfully!
+ lxc image delete ud1804-2019-11-10
+ lxc delete ud1804/auto-backup
Восстановление на другом компьютере:
$ lxc image import ud1804-2019-11-10.tar.gz.tar.gz --alias ud1804-backup
Образ, импортирован с снимком: b900ce0db69f0a57afd52af682f8a47229b5ea8fcdfa2a566af2034a6f6766a2
$ lxc launch ud1804-backup ud1804
#lxc image delete ud1804-backup
Комментариев нет:
Отправить комментарий