Perl scripts to backup and restore a Men&Mice data set

These scripts work together to backup and restore the Men&Mice data. It can backup the Men&Mice database but the database needs to be copied to a secure location away from the Central Server.

These script were designed to work with version 5.6 and 5.6.1 of the Men&Mice suite.

They were tested on a Fedora 16 server.

backup:

First is a shell script that serves as a driver to backup up multiple Men&Mice severs, such as production internal, production external, test, Disaster Recovery sets, etc. you must modify the scrpt to add a function for each environment. Some basic shell scripting skills are needed for this. But Its nothing too terribly difficult. If you are responsible for a Men&Mice installation, it’s a safe bet that you have basic scripting skills or the talent to acquire them.

You must invoke the script as

mm_backup.sh [password]

This script will in turn call mm_util.pl with all the appropriate command line options.

You may have to edit some of the variables that hold location information.

This is the help output for mm_util.pl

./mm_util.pl
Usage:
./mm_util.pl:   -h -d -p password -m master-server -z zone_name -s server -s server ..
where:
    -u user   default: Administrator
    -p password to M&M Central
    -m Master server  default:
    -c central server default:
    -z print the data in a zone and exit.
    -r print all the records from all the zones
    -a print a list of zones from the master server and exit
    -o execute one of the following command
        compare - compares zones against what is on the master.
    -i server information
    -b backup the men and mice database
    -t [backup_dir] directory to backup the men and mice database to default:
    -l i[1|2] mmcmd command-line
       1: /home/share/mm/mmcmd : default version 5.6 or whatever one has installed.
       2: /home/share/mm/mmcmd_5.6.1
    -d debug mode
    -h this message

Obviously you will have to experiment with the -l switch. The -l switch is three when you have two different version of men&mice running in your environment.

Restore:

The restore script is a two step process.

first you have to break up the files created by the backup script. The backup script places all he zones and records into one large file. to do this we use the following script. It will create a directory called restore under the default  $restore_dir. The -t option allows you to set the directory target.

./mm_restore_files.pl
Usage:
./mm_restore_files.pl:   -h -d -f [file] -a -t [restore-dir]
      where:
    -f monolithic-backup-file.
    -a print a list of zones from  datafile  and  exit.
    -t [restore_dir] directory to restore the men and mice data to default: /home/share/mm/restore
           also create  the zoneopt files and a named.conf file.
    -d debug mode
    -h this message

Once the files are restored you can copy them to a Men&Mice DNS server and try to restart the server and reload the data base with all the files in place. This method is still untested. I have managed to have success with this method but your mileage may vary. the following script will use the men and mice command line interface to recreate the zones. But this method is slow. It is a variation of the addzone script and still retains the addzone scripts ability to add a new zone.

./mm_addzone_restore.pl
Usage:
./mm_addzone_restore.pl:   -h -d -m master-server -u user -p password -z zone_name -r "comment"
      where:
    -c central server default=
    -m Master server  default:
        -u user default: Administrator
          -p password to M&M Central
        -f file containing list of zones, one per line
    -k comment - this is necessary default comment: initial addition of zone
        -s show the zone specified in -z and exit
        -z select a zone to display or process
        -t template file 

        -g restore directory where the zone files are kept, requires -f
        -r restore the zone files from the -g option 

    -d debug mode
    -h this message

By default the zone will be created on all the servers

example template file. The one shown is the default template:

$TTL 1D
@        IN    SOA    ns1.example.com.    hostmaster.example.com.    1    3h    1h    7d    3d
@        IN    NS    ns1.example.com.
@        IN    NS    ns2.example.com.
@        IN    NS    ns3.example.com.
@        IN    A    127.0.0.1
www      IN    CNAME    @

And here are the scripts

mm_backup.sh
mm_util.pl
mm_restore_files.pl
mm_addzone_restore.pl

CVS revision numbers:

mm_backup.sh:           # $Revision: 1.4 $
mm_util.pl:             # $Revision: 1.3 $
mm_restore_files.pl:    # $Revision: 1.3 $
mm_addzone_restore.pl:  # $Revision: 1.3 $

Leave a Reply