Difference between revisions of "Ploop/Backup"
< Ploop
(add pic) |
(add image-based backup and comparison) |
||
Line 1: | Line 1: | ||
[[File:Ploop-backup.png|300px|right|thumb|How backup via snapshot is done]] | [[File:Ploop-backup.png|300px|right|thumb|How backup via snapshot is done]] | ||
This article explains how to do consistent file-based backups for [[ploop]] containers, using ploop snapshot feature. | This article explains how to do consistent file-based backups for [[ploop]] containers, using ploop snapshot feature. | ||
+ | |||
+ | == Types of backup == | ||
+ | There are two ways of doing backups, both have their pros and cons. | ||
+ | |||
+ | * When doing an '''image backup''', one copies ploop image files directly. There can be only one big file, or maybe a few relatively big files. Copying a few big files (rather than a lot of small files) is faster because there's not too much metadata (file info) to be copied). Also, filesystem properties are fully preserving (since images containing the filesystem are copied). | ||
+ | |||
+ | * When doing a '''file backup''', one copies individual container' files. This is more suitable if you want selective backups (such as only some directories/files). | ||
+ | |||
+ | The following table summarizes pros and cons of both approaches. | ||
+ | |||
+ | {| class="wikitable" | ||
+ | ! Characteristic | ||
+ | ! Image | ||
+ | ! File | ||
+ | |- | ||
+ | || Incremental backups | ||
+ | | {{Yes}} || {{Yes-No}}{{H:title|Requires tools such as rsnapshot|<sup>*</sup>}} | ||
+ | |- | ||
+ | || Selective backups | ||
+ | | {{No}} || {{Yes}} | ||
+ | |- | ||
+ | || Faster full backup and restore | ||
+ | | {{Yes}} || {{No}} | ||
+ | |- | ||
+ | | Preserve filesystem properties | ||
+ | | {{Yes}} || {{No}} | ||
+ | |- | ||
+ | || Compatible with pre-ploop backups | ||
+ | | {{No}} || {{Yes}} | ||
+ | |- | ||
+ | || Restore individual files | ||
+ | | {{Yes}} || {{Yes}} | ||
+ | |} | ||
+ | |||
+ | == Image-based backups == | ||
+ | |||
+ | Assuming you have a running container identified by <code>$CTID</code>. The following needs to be done: | ||
+ | |||
+ | <source lang="bash"> | ||
+ | # Known snapshot ID | ||
+ | ID=$(uuidgen) | ||
+ | VE_PRIVATE=$(VEID=$CTID; source /etc/vz/vz.conf; source /etc/vz/conf/$CTID.conf; echo $VE_PRIVATE) | ||
+ | |||
+ | # Take a snapshot without suspending a CT and saving its config | ||
+ | vzctl snapshot $CTID --id $ID --skip-suspend --skip-config | ||
+ | |||
+ | # Perform a backup using your favorite backup tool | ||
+ | # (cp is just an example) | ||
+ | cp $VE_PRIVATE/root.hdd/* /backup/destination | ||
+ | |||
+ | # Delete (merge) the snapshot | ||
+ | vzctl snapshot-delete $CTID --id $ID | ||
+ | </source> | ||
+ | |||
+ | == File-based backup == | ||
Assuming you have a running container identified by <code>$CTID</code>. The following needs to be done: | Assuming you have a running container identified by <code>$CTID</code>. The following needs to be done: | ||
Line 29: | Line 84: | ||
</source> | </source> | ||
− | + | == See also == | |
+ | |||
+ | * [[Man/vzctl.8#Snapshotting|vzctl(8), section Snapshotting]]. | ||
[[Category:ploop]] | [[Category:ploop]] | ||
[[Category:HOWTO]] | [[Category:HOWTO]] |
Revision as of 23:12, 13 June 2013
This article explains how to do consistent file-based backups for ploop containers, using ploop snapshot feature.
Types of backup
There are two ways of doing backups, both have their pros and cons.
- When doing an image backup, one copies ploop image files directly. There can be only one big file, or maybe a few relatively big files. Copying a few big files (rather than a lot of small files) is faster because there's not too much metadata (file info) to be copied). Also, filesystem properties are fully preserving (since images containing the filesystem are copied).
- When doing a file backup, one copies individual container' files. This is more suitable if you want selective backups (such as only some directories/files).
The following table summarizes pros and cons of both approaches.
Characteristic | Image | File |
---|---|---|
Incremental backups | Yes | Yes/No* |
Selective backups | No | Yes |
Faster full backup and restore | Yes | No |
Preserve filesystem properties | Yes | No |
Compatible with pre-ploop backups | No | Yes |
Restore individual files | Yes | Yes |
Image-based backups
Assuming you have a running container identified by $CTID
. The following needs to be done:
# Known snapshot ID
ID=$(uuidgen)
VE_PRIVATE=$(VEID=$CTID; source /etc/vz/vz.conf; source /etc/vz/conf/$CTID.conf; echo $VE_PRIVATE)
# Take a snapshot without suspending a CT and saving its config
vzctl snapshot $CTID --id $ID --skip-suspend --skip-config
# Perform a backup using your favorite backup tool
# (cp is just an example)
cp $VE_PRIVATE/root.hdd/* /backup/destination
# Delete (merge) the snapshot
vzctl snapshot-delete $CTID --id $ID
File-based backup
Assuming you have a running container identified by $CTID
. The following needs to be done:
# Known snapshot ID
ID=$(uuidgen)
# Directory used to mount a snapshot
MNTDIR=./mnt
mkdir $MNTDIR
# Take a snapshot without suspending a CT and saving its config
vzctl snapshot $CTID --id $ID --skip-suspend --skip-config
# Mount the snapshot taken
vzctl snapshot-mount $CTID --id $ID --target $MNTDIR
# Perform a backup using your favorite backup tool
# (tar is just an example)
tar cf backup.tar.xz $MNTDIR
# Unmount the snapshot
vzctl snapshot-umount $CTID --id $ID
# Delete (merge) the snapshot
vzctl snapshot-delete $CTID --id $ID