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 ***

-- vserver_snapshot_create.sh -- cut here


  1. !/bin/bash
  2. Creates vserver snapshots with rsync - 02/08/2006 - abruce at @ at virtuaserver.com.br
  3. http://www.virtuaserver.com.br
  4. Run:
  5. vserver_snapshot_create.sh vserver_name
  6. Purpose: Create a snapshot from a vserver and allow its owner to download it.
  7. * USE IT AT YOUR OWN RISK *
  8. Todo: Restore snapshot
  9. Todo: Resize snapshot
  10. Configuration
  11. Where are snapshots going to be mounted?
SNAPSHOT_MOUNT_DIR=/tmp/
  1. Where are snapshots going to be stored?
SNAPSHOT_DIR=/tmp/snapshots
  1. Vserver
VSERVER_DIR=/vservers/
  1. 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

  1. 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

  1. 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

  1. Creating directory to mount this snapshot
mkdir $SNAPSHOT_MOUNT_DIR/$1
  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

  1. Syncing snapshot with vserver (better to do when vserver not running)
echo "Rsyncing ..."

rsync -avz --delete $VSERVER_DIR/$1/ $SNAPSHOT_MOUNT_DIR/$1

  1. Umounting snapshot image
echo "Umounting snapshot image"

umount $SNAPSHOT_MOUNT_DIR/$1

  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"

-- vserver_snapshot_create.sh -- cut here