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:

 /vservers/<yourvserver>/proc
 /vservers/<yourvserver>/var/run
 /vservers/<yourvserver>/var/lock

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

#!/bin/bash

VPSNAME="${1}"
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

EOF

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 <[EMAIL PROTECTED]>
Gentoo Linux Developer - vserver

Attachment: pgp2Fi85wIdJ2.pgp
Description: PGP signature

_______________________________________________
Vserver mailing list
[email protected]
http://list.linux-vserver.org/mailman/listinfo/vserver

Reply via email to