<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
	<id>https://wiki.openvz.org/api.php?action=feedcontributions&amp;feedformat=atom&amp;user=Mkocustos</id>
	<title>OpenVZ Virtuozzo Containers Wiki - User contributions [en]</title>
	<link rel="self" type="application/atom+xml" href="https://wiki.openvz.org/api.php?action=feedcontributions&amp;feedformat=atom&amp;user=Mkocustos"/>
	<link rel="alternate" type="text/html" href="https://wiki.openvz.org/Special:Contributions/Mkocustos"/>
	<updated>2026-06-13T20:00:21Z</updated>
	<subtitle>User contributions</subtitle>
	<generator>MediaWiki 1.31.1</generator>
	<entry>
		<id>https://wiki.openvz.org/index.php?title=Ploop/Backup&amp;diff=14686</id>
		<title>Ploop/Backup</title>
		<link rel="alternate" type="text/html" href="https://wiki.openvz.org/index.php?title=Ploop/Backup&amp;diff=14686"/>
		<updated>2013-10-09T09:16:40Z</updated>

		<summary type="html">&lt;p&gt;Mkocustos: /* Image-based backup */ The sorting of files was wrong. Now it lists the folders by date not by name.&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;[[File:Ploop-backup.png|300px|right|thumb|How backup via snapshot is done]]&lt;br /&gt;
This article explains how to do consistent backups for [[ploop]] containers, using ploop snapshot feature.&lt;br /&gt;
&lt;br /&gt;
== Backup types ==&lt;br /&gt;
There are two ways of doing backups, both have their pros and cons.&lt;br /&gt;
&lt;br /&gt;
* 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).&lt;br /&gt;
&lt;br /&gt;
* 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).&lt;br /&gt;
&lt;br /&gt;
The following table summarizes pros and cons of both approaches.&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
! Characteristic&lt;br /&gt;
! Image&lt;br /&gt;
! File&lt;br /&gt;
|-&lt;br /&gt;
|| Incremental backups&lt;br /&gt;
| {{Yes}} || {{Yes-No}}{{H:title|Requires tools such as rsnapshot|&amp;lt;sup&amp;gt;*&amp;lt;/sup&amp;gt;}}&lt;br /&gt;
|-&lt;br /&gt;
|| Selective backups&lt;br /&gt;
| {{No}} || {{Yes}}&lt;br /&gt;
|-&lt;br /&gt;
|| Faster full backup and restore&lt;br /&gt;
| {{Yes}} || {{No}}&lt;br /&gt;
|-&lt;br /&gt;
| Preserve filesystem properties&lt;br /&gt;
| {{Yes}} || {{No}}&lt;br /&gt;
|-&lt;br /&gt;
|| Compatible with pre-ploop backups&lt;br /&gt;
| {{No}} || {{Yes}}&lt;br /&gt;
|-&lt;br /&gt;
|| Restore individual files&lt;br /&gt;
| {{Yes}} || {{Yes}}&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
== Image-based backup ==&lt;br /&gt;
&lt;br /&gt;
Assuming you have a running container identified by &amp;lt;code&amp;gt;$CTID&amp;lt;/code&amp;gt;. The following needs to be done:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
# Known snapshot ID&lt;br /&gt;
ID=$(uuidgen)&lt;br /&gt;
VE_PRIVATE=$(VEID=$CTID; source /etc/vz/vz.conf; source /etc/vz/conf/$CTID.conf; echo $VE_PRIVATE)&lt;br /&gt;
&lt;br /&gt;
# Take a snapshot without suspending a CT and saving its config&lt;br /&gt;
vzctl snapshot $CTID --id $ID --skip-suspend --skip-config&lt;br /&gt;
&lt;br /&gt;
# Perform a backup using your favorite backup tool&lt;br /&gt;
# (cp is just an example)&lt;br /&gt;
cp $VE_PRIVATE/root.hdd/* /backup/destination&lt;br /&gt;
&lt;br /&gt;
# Delete (merge) the snapshot&lt;br /&gt;
vzctl snapshot-delete $CTID --id $ID&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The following script implements the commands above and allows - when stored as &amp;lt;code&amp;gt;vzbackup&amp;lt;/code&amp;gt; - to backup your container by executing the script in the following way:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;./vzbackup 101 /backup/destination/&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The script removes older backups and keeps only the latest four backups. You can change the number of backups kept by changing the four in &amp;lt;code&amp;gt;head -n-4&amp;lt;/code&amp;gt; to the number of backups you would like to keep.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
#!/bin/bash&lt;br /&gt;
if [ -z $1 -o -z $2 ]&lt;br /&gt;
then&lt;br /&gt;
	echo &amp;quot;Usage: vzbackup CTID BACKUP-PATH&amp;quot;&lt;br /&gt;
	exit 1&lt;br /&gt;
fi&lt;br /&gt;
&lt;br /&gt;
CTID=$1&lt;br /&gt;
FOLDER=$2&lt;br /&gt;
BACKUPPATH=$FOLDER/$CTID-$( date +%F_%H_%M )&lt;br /&gt;
&lt;br /&gt;
#create BACKUP-PATH&lt;br /&gt;
mkdir -p $BACKUPPATH&lt;br /&gt;
&lt;br /&gt;
# Known snapshot ID&lt;br /&gt;
ID=$(uuidgen)&lt;br /&gt;
VE_PRIVATE=$(VEID=$CTID; source /etc/vz/vz.conf; source /etc/vz/conf/$CTID.conf; echo $VE_PRIVATE)&lt;br /&gt;
 &lt;br /&gt;
# Take a snapshot without suspending a CT and saving its config&lt;br /&gt;
vzctl snapshot $CTID --id $ID --skip-suspend --skip-config&lt;br /&gt;
 &lt;br /&gt;
# Perform a backup using your favorite backup tool&lt;br /&gt;
# (cp is just an example)&lt;br /&gt;
cp $VE_PRIVATE/root.hdd/* $BACKUPPATH/&lt;br /&gt;
 &lt;br /&gt;
# Delete (merge) the snapshot&lt;br /&gt;
vzctl snapshot-delete $CTID --id $ID&lt;br /&gt;
&lt;br /&gt;
# remove old backups&lt;br /&gt;
rm -rf $( find $FOLDER -type d -name &amp;quot;$CTID*&amp;quot; -exec ls -d1rt &amp;quot;{}&amp;quot; + | head -n-4  )&lt;br /&gt;
&lt;br /&gt;
echo &amp;quot;BACKUP FINISHED.&amp;quot;&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== File-based backup ==&lt;br /&gt;
&lt;br /&gt;
Assuming you have a running container identified by &amp;lt;code&amp;gt;$CTID&amp;lt;/code&amp;gt;. The following needs to be done:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
# Known snapshot ID&lt;br /&gt;
ID=$(uuidgen)&lt;br /&gt;
&lt;br /&gt;
# Directory used to mount a snapshot&lt;br /&gt;
MNTDIR=./mnt&lt;br /&gt;
mkdir $MNTDIR&lt;br /&gt;
&lt;br /&gt;
# Take a snapshot without suspending a CT and saving its config&lt;br /&gt;
vzctl snapshot $CTID --id $ID --skip-suspend --skip-config&lt;br /&gt;
&lt;br /&gt;
# Mount the snapshot taken&lt;br /&gt;
vzctl snapshot-mount $CTID --id $ID --target $MNTDIR&lt;br /&gt;
&lt;br /&gt;
# Perform a backup using your favorite backup tool&lt;br /&gt;
# (tar is just an example)&lt;br /&gt;
tar cf backup.tar.xz $MNTDIR&lt;br /&gt;
&lt;br /&gt;
# Unmount the snapshot&lt;br /&gt;
vzctl snapshot-umount $CTID --id $ID&lt;br /&gt;
&lt;br /&gt;
# Delete (merge) the snapshot&lt;br /&gt;
vzctl snapshot-delete $CTID --id $ID&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== See also ==&lt;br /&gt;
&lt;br /&gt;
* [[Man/vzctl.8#Snapshotting|vzctl(8), section Snapshotting]].&lt;br /&gt;
&lt;br /&gt;
[[Category:ploop]]&lt;br /&gt;
[[Category:HOWTO]]&lt;/div&gt;</summary>
		<author><name>Mkocustos</name></author>
		
	</entry>
	<entry>
		<id>https://wiki.openvz.org/index.php?title=Ploop/Backup&amp;diff=14623</id>
		<title>Ploop/Backup</title>
		<link rel="alternate" type="text/html" href="https://wiki.openvz.org/index.php?title=Ploop/Backup&amp;diff=14623"/>
		<updated>2013-09-27T10:10:52Z</updated>

		<summary type="html">&lt;p&gt;Mkocustos: /* Image-based backup */ I added a new script.&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;[[File:Ploop-backup.png|300px|right|thumb|How backup via snapshot is done]]&lt;br /&gt;
This article explains how to do consistent backups for [[ploop]] containers, using ploop snapshot feature.&lt;br /&gt;
&lt;br /&gt;
== Backup types ==&lt;br /&gt;
There are two ways of doing backups, both have their pros and cons.&lt;br /&gt;
&lt;br /&gt;
* 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).&lt;br /&gt;
&lt;br /&gt;
* 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).&lt;br /&gt;
&lt;br /&gt;
The following table summarizes pros and cons of both approaches.&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
! Characteristic&lt;br /&gt;
! Image&lt;br /&gt;
! File&lt;br /&gt;
|-&lt;br /&gt;
|| Incremental backups&lt;br /&gt;
| {{Yes}} || {{Yes-No}}{{H:title|Requires tools such as rsnapshot|&amp;lt;sup&amp;gt;*&amp;lt;/sup&amp;gt;}}&lt;br /&gt;
|-&lt;br /&gt;
|| Selective backups&lt;br /&gt;
| {{No}} || {{Yes}}&lt;br /&gt;
|-&lt;br /&gt;
|| Faster full backup and restore&lt;br /&gt;
| {{Yes}} || {{No}}&lt;br /&gt;
|-&lt;br /&gt;
| Preserve filesystem properties&lt;br /&gt;
| {{Yes}} || {{No}}&lt;br /&gt;
|-&lt;br /&gt;
|| Compatible with pre-ploop backups&lt;br /&gt;
| {{No}} || {{Yes}}&lt;br /&gt;
|-&lt;br /&gt;
|| Restore individual files&lt;br /&gt;
| {{Yes}} || {{Yes}}&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
== Image-based backup ==&lt;br /&gt;
&lt;br /&gt;
Assuming you have a running container identified by &amp;lt;code&amp;gt;$CTID&amp;lt;/code&amp;gt;. The following needs to be done:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
# Known snapshot ID&lt;br /&gt;
ID=$(uuidgen)&lt;br /&gt;
VE_PRIVATE=$(VEID=$CTID; source /etc/vz/vz.conf; source /etc/vz/conf/$CTID.conf; echo $VE_PRIVATE)&lt;br /&gt;
&lt;br /&gt;
# Take a snapshot without suspending a CT and saving its config&lt;br /&gt;
vzctl snapshot $CTID --id $ID --skip-suspend --skip-config&lt;br /&gt;
&lt;br /&gt;
# Perform a backup using your favorite backup tool&lt;br /&gt;
# (cp is just an example)&lt;br /&gt;
cp $VE_PRIVATE/root.hdd/* /backup/destination&lt;br /&gt;
&lt;br /&gt;
# Delete (merge) the snapshot&lt;br /&gt;
vzctl snapshot-delete $CTID --id $ID&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The following script implements the commands above and allows - when stored as &amp;lt;code&amp;gt;vzbackup&amp;lt;/code&amp;gt; - to backup your container by executing the script in the following way:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;./vzbackup 101 /backup/destination/&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The script removes older backups and keeps only the latest four backups. You can change the number of backups kept by changing the four in &amp;lt;code&amp;gt;head -n-4&amp;lt;/code&amp;gt; to the number of backups you would like to keep.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
#!/bin/bash&lt;br /&gt;
if [ -z $1 -o -z $2 ]&lt;br /&gt;
then&lt;br /&gt;
        echo &amp;quot;Usage: vzbackup CTID BACKUP-PATH&amp;quot;&lt;br /&gt;
        exit 1&lt;br /&gt;
fi&lt;br /&gt;
&lt;br /&gt;
CTID=$1&lt;br /&gt;
FOLDER=$2&lt;br /&gt;
BACKUPPATH=$FOLDER/$CTID-$( date +%F_%H_%M )&lt;br /&gt;
&lt;br /&gt;
#create BACKUP-PATH&lt;br /&gt;
mkdir -p $BACKUPPATH&lt;br /&gt;
&lt;br /&gt;
# Known snapshot ID&lt;br /&gt;
ID=$(uuidgen)&lt;br /&gt;
VE_PRIVATE=$(VEID=$CTID; source /etc/vz/vz.conf; source /etc/vz/conf/$CTID.conf; echo $VE_PRIVATE)&lt;br /&gt;
&lt;br /&gt;
# Take a snapshot without suspending a CT and saving its config&lt;br /&gt;
vzctl snapshot $CTID --id $ID --skip-suspend --skip-config&lt;br /&gt;
&lt;br /&gt;
# Perform a backup using your favorite backup tool&lt;br /&gt;
# (cp is just an example)&lt;br /&gt;
cp $VE_PRIVATE/root.hdd/* $BACKUPPATH/&lt;br /&gt;
&lt;br /&gt;
# Delete (merge) the snapshot&lt;br /&gt;
vzctl snapshot-delete $CTID --id $ID&lt;br /&gt;
&lt;br /&gt;
# remove old backups&lt;br /&gt;
rm -rf $( find $FOLDER -type d -name &amp;quot;$CTID*&amp;quot; | head -n-4  )&lt;br /&gt;
&lt;br /&gt;
echo &amp;quot;BACKUP FINISHED.&amp;quot;&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== File-based backup ==&lt;br /&gt;
&lt;br /&gt;
Assuming you have a running container identified by &amp;lt;code&amp;gt;$CTID&amp;lt;/code&amp;gt;. The following needs to be done:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
# Known snapshot ID&lt;br /&gt;
ID=$(uuidgen)&lt;br /&gt;
&lt;br /&gt;
# Directory used to mount a snapshot&lt;br /&gt;
MNTDIR=./mnt&lt;br /&gt;
mkdir $MNTDIR&lt;br /&gt;
&lt;br /&gt;
# Take a snapshot without suspending a CT and saving its config&lt;br /&gt;
vzctl snapshot $CTID --id $ID --skip-suspend --skip-config&lt;br /&gt;
&lt;br /&gt;
# Mount the snapshot taken&lt;br /&gt;
vzctl snapshot-mount $CTID --id $ID --target $MNTDIR&lt;br /&gt;
&lt;br /&gt;
# Perform a backup using your favorite backup tool&lt;br /&gt;
# (tar is just an example)&lt;br /&gt;
tar cf backup.tar.xz $MNTDIR&lt;br /&gt;
&lt;br /&gt;
# Unmount the snapshot&lt;br /&gt;
vzctl snapshot-umount $CTID --id $ID&lt;br /&gt;
&lt;br /&gt;
# Delete (merge) the snapshot&lt;br /&gt;
vzctl snapshot-delete $CTID --id $ID&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== See also ==&lt;br /&gt;
&lt;br /&gt;
* [[Man/vzctl.8#Snapshotting|vzctl(8), section Snapshotting]].&lt;br /&gt;
&lt;br /&gt;
[[Category:ploop]]&lt;br /&gt;
[[Category:HOWTO]]&lt;/div&gt;</summary>
		<author><name>Mkocustos</name></author>
		
	</entry>
</feed>