We currently migrate to MediaWiki from our old installation, but not all content has been migrated yet. Take a look at the Wiki Team page for instructions how to help or browse through our new wiki at wiki.linux-vserver.org to find the information already migrated.

We have been talking on IRC about creating snapshots and letting users download it. I've created a small script that creates and sync snapshots. It is not well tested. Let me know if it worked for you or if you have ideas.

  • USE IT AT YOUR OWN RISK **
#!/bin/bash
# Creates vserver snapshots with rsync - 02/08/2006 - abruce at @ at virtuaserver.com.br
# http://www.virtuaserver.com.br
#
# Run:
# vserver_snapshot_create.sh vserver_name
#
# Purpose: Create a snapshot from a vserver and allow its owner to download it.
# *** USE IT AT YOUR OWN RISK ***
#
# Todo: Restore snapshot
# Todo: Resize snapshot
#
# Configuration
#
# Where are snapshots going to be mounted?
SNAPSHOT_MOUNT_DIR=/tmp/
# Where are snapshots going to be stored?
SNAPSHOT_DIR=/tmp/snapshots
# Vserver
VSERVER_DIR=/vservers/

# Checking arguments
if [ $# -ne 2 ]; then
	echo 1>&2 Usage: $0 vserver_name size_in_megabytes
	exit 0
fi

VSERVER=$1
VSERVER_SIZE=$2

SNAPSHOT_FILE=$SNAPSHOT_DIR/$1.img

# Checking if directories exist
if [ ! -d $SNAPSHOT_MOUNT_DIR ]
then
	echo "SNAPSHOT_MOUNT_DIR $SNAPSHOT_MOUNT_DIR does not exist"
	exit  1
fi

if [ ! -d $SNAPSHOT_DIR ]
then
	echo "SNAPSHOT_DIR $SNAPSHOT_DIR does not exist"
	exit 1
fi

# Checking if snapshot file already exists
if [ ! -e $SNAPSHOT_FILE ]
then
	echo "Creating image file $SNAPSHOT_FILE with $VSERVER_SIZE megabytes."
	dd if=/dev/zero of=$SNAPSHOT_FILE bs=1048576 count=$VSERVER_SIZE
	echo "Formating Image"
	mkfs.ext2 $SNAPSHOT_FILE
fi

# Creating directory to mount this snapshot
mkdir $SNAPSHOT_MOUNT_DIR/$1

# Mounting snapshot (old one or the image we just created
echo "Mounting $SNAPSHOT_FILE at $SNAPSHOT_MOUNT_DIR/$1"
mount -t ext2 $SNAPSHOT_FILE $SNAPSHOT_MOUNT_DIR/$1 -o loop
# Syncing snapshot with vserver (better to do when vserver not running)
echo "Rsyncing ..."
rsync -avz --delete $VSERVER_DIR/$1/ $SNAPSHOT_MOUNT_DIR/$1
# Umounting snapshot image
echo "Umounting snapshot image"
umount $SNAPSHOT_MOUNT_DIR/$1

# Removing directory that was created to mount this snapshot
rmdir $SNAPSHOT_MOUNT_DIR/$1

echo "If there were not any errors, your snapshot is probrably ready at $SNAPSHOT_FILE"

And to restore a snapshot... do:

#!/bin/bash
# [by MarkS AKA Skram; mark@SentienSystems.com
# Restores VServer snapshots which were made with brc_ (Bruce)'s vserver_snapshot_create.sh AKA vserver-snapmake
#
# Run: vserver-snaprestore vserver_name
#
# Purpose: Restore a snapshot of a VServer
#
# *** PLEASE USE THIS AT YOUR OWN RISK ***
#
# Configuration files:
# Where are snapshots going to be mounted?
SNAPSHOT_MOUNT_DIR=/tmp/snapshots_mounted
# Where are snapshots going to be stored?
SNAPSHOT_DIR=/nas/1/vserver-snapshots
# Vserver
VSERVER_DIR=/vservers/

# Checking arguments
if [ $# -ne 1 ]; then
        echo 1>&2 Usage: $0 vserver_name
        exit 0
fi

VSERVER=$1

SNAPSHOT_FILE=$SNAPSHOT_DIR/$1.img

# Checking if directories exist
if [ ! -d $SNAPSHOT_MOUNT_DIR ]
then
        echo "SNAPSHOT_MOUNT_DIR $SNAPSHOT_MOUNT_DIR does not exist"
        exit  1
fi

if [ ! -d $SNAPSHOT_DIR ]
then
        echo "SNAPSHOT_DIR $SNAPSHOT_DIR does not exist"
        exit 1
fi

# Checking if snapshot file already exists
if [ ! -e $SNAPSHOT_FILE ]
#       if it doesnt.. make it!
then
        echo "$SNAPSHOT_DIR/$VSERVER.img doesn't exist; use 'vserver-snapmake $VSERVER SIZE_IN_MB' to create it"
fi

# Restoring Snapshot...
mkdir $SNAPSHOT_MOUNT_DIR/$VSERVER

mount $SNAPSHOT_DIR/$1.img $SNAPSHOT_MOUNT_DIR/$VSERVER -o loop
rsync $SNAPSHOT_MOUNT_DIR $VSERVER_DIR/$VSERVER
umount $SNAPSHOT_MOUNT_DIR/$VSERVER



echo "If there were not any errors, your snapshot is probrably restored at $VSERVER/$1/"