SUMMARY: Scripts for Backup with Data Compression

From: Renan Martins Baptista (renan@cenpes.petrobras.gov.br)
Date: Thu Dec 05 1996 - 10:38:43 CST


SUMMARY: Scripts for Backup with Data Compression

QUESTION:

I submitted the following message:

I have a network which is growing much faster than my mass
storage peripherals acquisition. The obvious consequence,
is the need of backups with compression procedures.

I have a mixed network with solaris 2.4, solaris 2.5 and,
(it couldn't be different) all flavors of SunOS 4.1.x.

I would like to have some suggestions of scripts to perform
backups with data compression. Would you help me?

REMARKS:

It seems to be a very interesting and still challanging discussion,
where one have to decide among comercial dedicated software, Public
Domain Software or home made scripts. I still don't have my position,
but I think it shall be contributive to post the answers I got. Any
contributional infortion is, more than ever, still welcome.

THANKS:

azhang@ect.enron.com
foster@bial1.ucsd.edu
rsm@idc.tandem.com (R.SrinivasaMoorthy)
gibian@stars1.hanscom.af.mil (Marc S. Gibian)

Thank you all.

SOLUTION:

1. Using Public Domain software, the best solutions is to try
   AMANDA software. It can be found in:
  ( http://www.cs.umd.edu/projects/amanda/index.html )

2. Using comercial software, there are lots of options, among then
   Solstice Backup, which is a Sun Software product for Solaris.

3. Some personal scripts I got:

3.1 Dave Foster, foster@bial1.ucsd.edu, suggested:

I've attached a script that I wrote and use to back up our systems.
If you download GNU's tar, you can use the -z option to use gzip
to compress the backup.

Dave Foster

#! /bin/csh
#
# SYSTEM_BACKUP_2GB
#
# Script to backup system directories using tar. Use GNU tar.
# Backup device is expected to be 2GB 4mm tape drive.
# When run on empty tapes for the first time, you must
# backup all partitions prompted!
#
# Backups are performed in the following order:
#
# /, /usr, /var, /usr/openwin, /opt, /export/home

# Remote host where 4mm tape drive lives

set RHOST = bial5
set DEVICE = /dev/rmt/0n

set GET_HOSTNAME = /usr/ucb/hostname

set quiet = 0
if ( $#argv > 0 ) then
        if ( $argv[1] == "quiet" ) then
                set quiet = 1
        else if ( $argv[1] == "-h" ) then
                echo " "
                echo " Usage: system_backup_2GB [quiet]"
                echo " "
                exit 1
        endif
endif
if ( $quiet == 0 ) then
        set LOCAL_OPTIONS = cvlf
        set REMOTE_OPTIONS = cvlfb
else
        set LOCAL_OPTIONS = clf
        set REMOTE_OPTIONS = clfb
endif

if ( `/usr/ucb/whoami` != "root" ) then
        echo " Must be super-user to run this script"
        exit 1
else

        set OPTION = Junk
        while ( $OPTION == "Junk" )
                echo " "
                echo " You can backup [All] or [Individual] partitions..."
                echo " "
                echo -n " Choose backup option [A/I]: "
                set line = $<
                switch( $line )
                        case [aA]:
                                set OPTION = All
                                breaksw
                        case [iI]:
                                set OPTION = Individual
                                breaksw
                        case default:
                                set OPTION = Junk
                                breaksw
                endsw
        end

        # If local host and RHOST are equivalent then local backup

        if ( `${GET_HOSTNAME}` == $RHOST ) then
                set LOCATION = Local
        else
                set LOCATION = Remote
        endif

        pushd / > /dev/null
        if ( $LOCATION == "Local" ) then
                mt -f $DEVICE rewind
        else
                rsh $RHOST mt -f $DEVICE rewind
        endif

        if ( $OPTION == "Individual" ) then
                echo -n " Backup these partitions {/,/usr,/var} [y/n]: "
                set line = $<
        else
                echo " "
                echo " Backing up {/,/usr,/var}..."
                set line = Y
        endif
        switch ( $line )
                case [yY]:
                        if ( $LOCATION == "Remote" ) then
                                tar $REMOTE_OPTIONS - 20 . | rsh $RHOST dd
of=$DEVICE obs=20b
                                cd /usr
                                tar $REMOTE_OPTIONS - 20 . | rsh $RHOST dd
of=$DEVICE obs=20b
                                cd /var
                                tar $REMOTE_OPTIONS - 20 . | rsh $RHOST dd
of=$DEVICE obs=20b
                        else
                                tar $LOCAL_OPTIONS $DEVICE
--ignore-failed-read .
                                cd /usr
                                tar $LOCAL_OPTIONS $DEVICE
--ignore-failed-read .
                                cd /var
                                tar $LOCAL_OPTIONS $DEVICE
--ignore-failed-read .
                        endif
                        breaksw
                case default:
                        echo " "
                        mt fsf 3
                        breaksw
        endsw

        echo " "
        if ( $OPTION == "Individual" ) then
                echo -n " Backup these partitions {/usr/openwin} [y/n]: "
                set line = $<
        else
                echo " "
                echo " Backing up {/usr/openwin}..."
                set line = Y
        endif
        switch ( $line )
                case [yY]:
                        cd /usr/openwin
                        if ( $LOCATION == "Remote" ) then
                                tar $REMOTE_OPTIONS - 20 . | rsh $RHOST dd
of=$DEVICE obs=20b
                        else
                                tar $LOCAL_OPTIONS $DEVICE
--ignore-failed-read .
                        endif
                        breaksw
                case default:
                        echo " "
                        mt fsf 1
                        breaksw
        endsw

        echo " "
        if ( $OPTION == "Individual" ) then
                echo -n " Backup these partitions {/opt} [y/n]: "
                set line = $<
        else
                echo " "
                echo " Backing up {/opt}..."
                set line = Y
        endif
        switch ( $line )
                case [yY]:
                        cd /opt
                        if ( $LOCATION == "Remote" ) then
                                tar $REMOTE_OPTIONS - 20 . | rsh $RHOST dd
of=$DEVICE obs=20b
                        else
                                tar $LOCAL_OPTIONS $DEVICE
--ignore-failed-read .
                        endif
                        breaksw
                case default:
                        echo " "
                        mt fsf 1
                        breaksw
        endsw

        echo " "
        if ( $OPTION == "Individual" ) then
                echo -n " Backup these partitions {/export/home} [y/n]: "
                set line = $<
        else
                echo " "
                echo " Backing up {/export/home}..."
                set line = Y
        endif
        switch ( $line )
                case [yY]:
                        cd /export/home
                        if ( $LOCATION == "Remote" ) then
                                tar $REMOTE_OPTIONS - 20 . | rsh $RHOST dd
of=$DEVICE obs=20b
                        else
                                tar $LOCAL_OPTIONS $DEVICE
--ignore-failed-read .
                        endif
                        breaksw
                case default:
                        echo " "
                        mt fsf 1
                        breaksw
        endsw

        if ( $LOCATION == "Local" ) then
                mt -f $DEVICE rewind
        else
                rsh $RHOST mt -f $DEVICE rewind
        endif

        echo " "
        echo " System backup complete"
        echo " "
        popd > /dev/null

endif

3.2 Srinivasa Moorthy, rsm@idc.tandem.com, suggested:

Hi,

        You could do something like this.

        From the system you can issue commands(in a script!!) to the target
        system as

rsh <target system> /usr/etc/dump 0udsbf 216000 8000 126 - <filesystem> 2>>
$LOGFILE | /usr/local/bin/gzip | dd of=/dev/nrst8 bs=1024

        I found the above very usefull. The only problem is that it takes
        longer time to backup, because it has to compress!!.

        Try this out..

        Thanks
        Srinivasa Moorthy

                                \\|//
                                (0~0)
----------------------------oooO-(_)-Oooo----------------------------
 Renan Martins Baptista PETROBRAS R & D Centre
 Petroleum Engineer Cidade Universitaria, qd 07
 Phone: (+55 21) 598-6556/6935 Ilha do Fundao, Rio de Janeiro,
 Fax : (+55 21) 598-6796/6795 RJ, BRAZIL - 21949-900
 E-mail: renan@cenpes.petrobras.gov.br
____________________________________Oooo.____________________________
                           .oooO ( )
 "Friends come and go ( ) ) /
  Enemies Accumulate" \ ( (_/
                              \_)



This archive was generated by hypermail 2.1.2 : Fri Sep 28 2001 - 23:11:17 CDT