paul_venezia
Senior Contributing Editor

The Art of Migration

analysis
Jul 31, 20033 mins

There are days that things just work the way they're supposed to. I really like those days. The task was to migrate four RedHat 7.1-7.3 servers to new hardware and RedHat 9. The servers performed myriad tasks including: DHCP Services DNS Services Three BBS systems using vBBS MySQL databases for the BBSs Mailling list server, with searchable archives and automatic list creation/removal/archival/indexing. Network

There are days that things just work the way they’re supposed to. I really like those days.

The task was to migrate four RedHat 7.1-7.3 servers to new hardware and RedHat 9. The servers performed myriad tasks including:

  • DHCP Services

  • DNS Services

  • Three BBS systems using vBBS

  • MySQL databases for the BBSs

  • Mailling list server, with searchable archives and automatic list creation/removal/archival/indexing.

  • Network monitoring tasks such as BigBrother and MRTG.

  • Mail relay and SpamAssassin

    The network was a university with several thousand students. The new hardware was ready to go. Following a fresh installation of RH9 on the new hardware, almost all the migration tasks could be summed up in one line: rsync -az -e ssh oldserver:/some/path /some/path

    All the MySQL databases moved cleanly, all the web docroots moved with no problems. Majordomo moved over just fine, odd permissions and all. The only really time-intensive part was the manual migration from Apache 1.3.x to 2.0.x, since some httpd.conf mods were needed. All told, it was a walk in the park with no noticeable downtime to the user community. The longest service outage was about 30 seconds.

    Since I had some time left over, I built a quick live backup scheme between the servers. One server had a RAID5 array, while the others simply had mirrored disk. A directory structure, /usr/local/export/linuxbackups/ was created, /etc/exports was tweaked, /etc/auto.master and an automounter share file was created on each of the servers, and a quick script was put together to create an archived .tgz of all the relevant portions of that particular server on the automounted share. The result is that every Linux box has 14 days of critical file backups available at the drop of a hat, no muss, no fuss. Should a system completely fail, a fresh install and a `tar zxf -livebackup.0.tgz` from / should take care of most of the rebuild.

    This is hardly rocket science, but is a great example of simple, powerful tools.

    Examples:

    /etc/exports on the NFS server:

    /usr/local/export/linuxbackup/listserv listserv.playskool.edu(rw,no_root_squash)

    /etc/auto.master on another server:

    /mnt/nfsserver /etc/autofs/auto.nfsserver --timeout=60

    /etc/autofs/auto.nfsserver:

    linuxbackup -rw,soft,intr nfsserver.playskool.edu:/usr/local/export/linuxbackup/listserv

    and the livebackup.sh script:

    #!/bin/bash --noprofile # # # Script to perform backup of pertinent system config files. Sources /etc/livebackup.cfg # # Paul Venezia # CFGFILE=/etc/livebackup.cfg DATE=`date +%m%d%Y` HOSTNAME=`hostname | cut -d'.' -f 1`

    if [ -f $CFGFILE ]; then . $CFGFILE

    else echo "$CFGFILE not found. Exiting." exit fi

    TARFILE=`(echo -n $HOSTNAME-; basename $OUTFILE | sed -e s/.tgz//)` TARDIR=`dirname $OUTFILE`

    echo -n "Shuffling archives..." for i in 13 12 11 10 9 8 7 6 5 4 3 2 1 0; do

    if [ -f $TARDIR/$TARFILE.$i.tgz ]; then F=`expr $i + 1` /bin/mv $TARDIR/$TARFILE.$i.tgz $TARDIR/$TARFILE.$F.tgz echo -n " $TARFILE.$i.tgz" fi done echo

    echo "Creating and compressing backup tarball $TARDIR/$TARFILE.0.tgz..." tar zcpf $TARDIR/$TARFILE.0.tgz $DIRS > $LOGFILE 2>&1

    if [ $? -eq 0 ]; then echo "Backup completed" echo "livebackup.sh successful: $DATE" >> /var/log/livebackup.log rm $LOGFILE exit else echo "Error encountered. See $LOGFILE and /var/log/livebackup.log" echo "livebackup.sh FAILED: $DATE" >> /var/log/livebackup.log exit fi

    Which references the config file /etc/livebackup.cfg:

    # # # Config file for /usr/local/sbin/livebackup.sh # # # # Directories to be backed up DIRS="/etc /usr/local /var/www /boot"

    # Output file OUTFILE=/mnt/nfsserver/linuxbackup/livebackup.tgz

    # Logfile LOGFILE=/tmp/livebackup.$$

    What could be simpler?