Tarsnap on Parallels Cloud Server

jesse's picture

This is a quick setup for Tarsnap on Parallels Cloud Server 6. See my other post for general Tarsnap on CentOS setup.

Hardware Node

Here we're concerned with backing up the hardware node itself, not the container and virtual machine data in cloud storage (pstorage).

Exclusions

PCS uses /pstorage/ for all it's MDS and CS device mount points, as well as the client pstorage mount; we want to backup all the directories themselves, but nothing under those.

Container mount points are under /vz/root/, which we'll exclude.

Backups get put in /vz/backups/, which we'll also exclude here.

Templates are kept under /vz/template, which you may not want to backup. Certainly if the same templates are maintained across all your hardware nodes, you don't need to back that up everywhere.

Tarsnap install

# install build environment
yum install -y openssl-devel zlib-devel e2fsprogs-devel gcc
 
# download and build tarsnap
cd /root
wget https://www.tarsnap.com/download/tarsnap-autoconf-1.0.35.tgz
sha256sum tarsnap-autoconf-1.0.35.tgz
tar xzf tarsnap-autoconf-1.0.35.tgz 
cd tarsnap-autoconf-1.0.35/
./configure
make; make install; make clean
 
# setup tarsnap.conf
cp /usr/local/etc/tarsnap.conf.sample /usr/local/etc/tarsnap.conf
sed -i 's|^keyfile .*|keyfile /etc/tarsnap.key|' /usr/local/etc/tarsnap.conf
echo 'exclude var/cache/*' >> /usr/local/etc/tarsnap.conf
echo 'exclude var/tmp/*' >> /usr/local/etc/tarsnap.conf
echo 'exclude tmp/*' >> /usr/local/etc/tarsnap.conf
echo 'exclude pstorage/*/*' >> /usr/local/etc/tarsnap.conf
echo 'exclude vz/root/*' >> /usr/local/etc/tarsnap.conf
echo 'exclude vz/backups/*' >> /usr/local/etc/tarsnap.conf
 
# generate tarsnap private key (use your username here)
tarsnap-keygen --keyfile /etc/tarsnap.key --user your@domain.com --machine `hostname -f`
 
# save a copy of that key somewhere safe!
uuencode /etc/tarsnap.key `hostname -f`-tarsnap.key | mail -s "tarsnap key for `hostname -f`" your@domain.com

Tarsnap install

# install/configure tarsnap-cron
cd /usr/local/bin
wget https://github.com/jnorell/tarsnap-cron/raw/master/tarsnap-archive.sh
wget https://github.com/jnorell/tarsnap-cron/raw/master/tarsnap-prune.sh
chmod +x tarsnap-{archive,prune}.sh
wget -O /etc/tarsnap-cron.conf https://github.com/jnorell/tarsnap-cron/raw/master/tarsnap-cron.conf.sample
wget -O /etc/cron.d/tarsnap-cron https://github.com/jnorell/tarsnap-cron/raw/master/tarsnap.cron.d.sample
 
# adjust these as needed
sed -i 's|home=/home|vz=/vz|' /etc/tarsnap-cron.conf 
sed -i 's|# PRESERVE_PATH=true|PRESERVE_PATH=true|' /etc/tarsnap-cron.conf 
sed -i 's|^BANDWIDTH=.*$|BANDWIDTH=85000000|' /etc/tarsnap-cron.conf 
sed -i 's|^EXTRA_PARAMETERS=.*$|EXTRA_PARAMETERS="--maxbw-rate-up $BANDWIDTH --exclude '"'/pstorage/*/*'"' --exclude '"'/vz/root/*'"' --exclude '"'/vz/backups/*'"'" |' /etc/tarsnap-cron.conf

That should be enough to backup the hardware node itself, though a clean install may be nearly as fast to setup. If you like, kick off a daily backup now:

/usr/local/bin/tarsnap-archive.sh daily

Now to backup the containers and virtual machines.

Virtual Environments

More to come...

Tags: 

Add new comment

Filtered HTML

  • Web page addresses and e-mail addresses turn into links automatically.
  • Allowed HTML tags: <a> <em> <strong> <cite> <blockquote> <code> <ul> <ol> <li> <dl> <dt> <dd>
  • Lines and paragraphs break automatically.

Plain text

  • No HTML tags allowed.
  • Web page addresses and e-mail addresses turn into links automatically.
  • Lines and paragraphs break automatically.