OpenVz VPS Backup mount to node

1) Create backup mount script template at /etc/sysconfig/vz-scripts/new.mount
——–backup mount script——–

#!/bin/bash
#
# if one of these files does not exist then something is really broken
[ -f /etc/sysconfig/vz ] || exit 1
[ -f $VE_CONFFILE ] || exit 1
[ -f /etc/sysconfig/vz-scripts/$VEID.conf ] || exit 1
# Source configuration files to access $VE_ROOT
. /etc/sysconfig/vz
. $VE_CONFFILE
[ -e /backup/$VEID ] || mkdir /backup/$VEID
mount –bind /backup/$VEID $VE_ROOT/backup

2) Create backup unmount script template at /etc/sysconfig/vz-scripts/new.umount

—————–backup unmount script———————

#!/bin/bash
# if one of these files does not exist then something is really broken
[ -f /etc/sysconfig/vz ] || exit 1
[ -f $VE_CONFFILE ] || exit 1
# Source configuration files to access $VE_ROOT
. /etc/sysconfig/vz
. $VE_CONFFILE
# Unmount shared directory
if grep “/vz/root/$VEID/backup” /proc/mounts >/dev/null; then
umount $VE_ROOT/backup
fi
—————————————————-

3) Add a function “vzbackupsetup” in /etc/vz/dists/scripts/postcreate.sh to create backup mount scripts for newly creating VEs.

———-

function vzbackupsetup()
{

VEID=`basename $VE_ROOT`

cp /etc/sysconfig/vz-scripts/new.mount /etc/sysconfig/vz-scripts/$VEID.mount
cp /etc/sysconfig/vz-scripts/new.umount /etc/sysconfig/vz-scripts/$VEID.umount

chmod 755 /etc/sysconfig/vz-scripts/$VEID.mount
chmod 755 /etc/sysconfig/vz-scripts/$VEID.umount
mkdir /vz/root/$VEID/backup

}
vzbackupsetup
————————–

Advertisements
  1. No trackbacks yet.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: