On Wed, 2006-01-04 at 18:40 +0100, Michele Virgilio wrote:
> Thanks for our replies, so can anyone give me a script to automate this
> process?

Here's a script to look at your current vpopmail area and write the
commands needed to recreate that area. Just redirect the output from the
script to a file and that file now contains the commands needed to
recreate your environment.

#!/bin/bash 

cd /home/vpopmail/domains
find . -maxdepth 1 -mindepth 1 -type d | sed 's#\./##'|while read x; do 
   password="$(grep postmaster $x/vpasswd  | sed 's/^.*://')" 
   echo '/home/vpopmail/bin/vadddomain ' \'$x\' \'$password\'
   sed "s/:.*:/:/;s#^#/home/vpopmail/bin/vadduser #;s/:/@$x '/;s/$/'/"
$x/vpasswd|grep -v postmaster
done


Grabbing the users .qmail files, and any existing mail can be done as
follows:

#!/bin/bash

cd /home/vpopmail/domains
find . -name .qmail* | tar -c -T - >/root/q.tar
find . -type d -name 'Maildir'|sed 's#$#/new#'|tar -c -T - >/root/M.tar


If you want to grab the /var/qmail/control area, just tar it as in :

tar -c /var/qmail/control >/root/c.tar


I find that taking real backups of things via tape backup, rsync, etc
although useful at times, isn't exactly that useful when I want to
create a new server. 

When I want a new box, its got a newer O/S, newer versions of vpopmail,
newer qmail (patches), newer clamav, etc, and trying to tar dump an old
environment into a new one isn't trivial.

Therefore, I prefer to create the commands needed to recreate the
environment from scratch which assumes I've had a catastrophic failure,
and was forced to create a new box up to the point where I want to add
domains and users. Then the info from the scripts above comes into play.

We rsync the entire box to a spare drive in a different box every night.
>From that spare drive, we can extract whatever info we want even after
the real box has died, got stolen (it happened), whatever.

This isn't everything you need to do, but its a start to get you
thinking.

-- 
Bill Gradwohl


Reply via email to