Container backup (no official info) [message #52532] |
Wed, 17 August 2016 19:37 |
petr.holik
Messages: 2 Registered: August 2016 Location: Czech Republic
|
Junior Member |
|
|
#prlctl backup zimbra
Backing up the CT zimbra
Failed to backed up the CT: Unimplemented. This feature is not implemented yet.
# prlctl --version
prlctl version 7.0.0 internal build
# cat /etc/virtuozzo-release
OpenVZ release 7.0.0 (3515)
I've checked out git the repo containing prlctl and there is version 7.0.82 which seem to support creating backups.
I also found the https://help.virtuozzo.com/customer/en/portal/articles/2352873
My question is:
1) Is there any solution how to create consistent backup of running container?
2) if not, is there any time estimate when it will be added?
3) Why there is no section about creating backups in manual?
P.S. I am able to create backup with some magic with ploop and editing XML disk descriptors by hand, but its solution which I don't prefer to use in production.
Petr Holik
|
|
|
|
|
|
|
Re: Container backup (no official info) [message #52630 is a reply to message #52532] |
Wed, 16 November 2016 08:53 |
nebbian
Messages: 3 Registered: November 2016 Location: Western Australia
|
Junior Member |
|
|
I've come across this issue today. Here's how I did it (based on how it was done in previous versions of OpenVZ).
1) Create /usr/local/bin/vzbackup:
#!/bin/bash
if [ -z $1 -o -z $2 ]
then
echo "Usage: vzbackup CTID BACKUP-PATH"
exit 1
fi
CTID=$1
FOLDER=$2
BACKUPPATH=$FOLDER/$CTID-$(date +%F_%H_%M)
#create BACKUP-PATH
mkdir -p $BACKUPPATH
# Known snapshot ID
ID=$(uuidgen)
VE_PRIVATE=$(vzlist -H -o private $CTID)
# Take a snapshot without suspending a CT and saving its config
vzctl snapshot $CTID --id $ID
# Perform a backup using your favorite backup tool
# (cp is just an example)
cp -r $VE_PRIVATE/root.hdd/* $BACKUPPATH/
# Delete (merge) the snapshot
vzctl snapshot-delete $CTID --id $ID
# remove old backups
rm -rf $( find $FOLDER -type d -name "$CTID*" -exec ls -d1rt "{}" + | head -n-4 )
echo "BACKUP FINISHED."
2) Run this periodically, passing in the container ID and the backup location, eg:
/usr/local/bin/vzbackup MyCT /backup/openvz/current/
Restoring from this backup
1) Create a new container, eg:
prlctl create Test --vmtype ct --ostemplate centos-7-x86_64
2) Determine the UUID of your new container, eg:
prlctl list -a
3) Copy all files in your latest backup directory to /vz/private/{UUID}/root.hdd/, overwriting all the existing hard disk files in there
4) Start the new container, eg:
prlctl start Test
This appears to be working for me. I'm sure that this isn't the best way to do things, but in my case, at least it's A way to back up my containers. I tried using snapshots, but I don't think that these restore the file system (which seems a bit odd to me).
Maybe it will work for someone. Or maybe I'm deluding myself into thinking that this is a valid backup technique.
|
|
|
|