Re: [Vserver] recommended way to backup vserver guests with nightly cron job?

From: Christian Heim <>
Date: Tue 20 Dec 2005 - 09:59:14 GMT
Message-Id: <>

On Tuesday 20 December 2005 10:30, Gerhard Hofmann wrote:
> Hi list,
> I'm a newbie to vserver and I wonder how to backup my vserver guests
> with a cron job run by the vserver host.
> I think it should be something like that:
> vserver myvserver stop
> ...compress /etc/vserver to a tgz file and save on external storage...
> vserver myvserver start
> Have I forgotten something important here?

Why stop the vserver ?! AFAIK that ain't necessary.

Just tar up /etc/vservers/<yourvserver> (if you're going to backup your
configuration). If you want to backup the guests itself, you'll have to tar
up /vservers/<yourvserver>, while excluding the following:


If you have some sort of external storage inside the guest, you probably want
to exclude that too.

> Myvserver will run mysql and apache (TYPO3 content management system),
> so I think it won't hurt to run a mysqldump before shutting down and
> backing up myvserver.
> What is the best way to invoke the mysqldump command within myvserver? A
> separate cron job within the guest?

Or just write a script for the backup process like the following


DATE="$( date +'%Y%m%d' )"

# Do the database dump
/usr/sbin/vserver exec $VPSNAME '/usr/bin/mysqldump ${WHATEVER}
> /tmp/mysqldump-${DATE}'

# Now start the tar
tar --exclude=/vservers/$VPSNAME/proc --exclude=/vservers/$VPSNAME/var/run \
     --exclude=/vservers/$VPSNAME/var/lock \
     -cpf /backup/vserver-$VPSNAME-$DATE.tar.bz2 \
     /etc/vservers/$VPSNAME /vservers/$VPSNAME


After that just call that script from your crontab, and everything should be
fine :)

But, please! Test it before you run this on a production system, it's untested
and direct from my memory.

Christian Heim <>
Gentoo Linux Developer - vserver

Vserver mailing list

Received on Tue Dec 20 09:59:43 2005
[Next/Previous Months] [Main vserver Project Homepage] [Howto Subscribe/Unsubscribe] [Paul Sladen's vserver stuff]
Generated on Tue 20 Dec 2005 - 09:59:47 GMT by hypermail 2.1.8