Next Previous Contents

29. Tape Backups: Backing up your box minimum files to floppy and using BRU)

Once you get your system up and running, it's only a matter of time before you make a serious mistake, you get HD corruption, or a HD dies all together. COUNT ON IT!

What can you do? At -=*LEAST*=- backup your core files onto a floppy disk and, better yet, get a tape drive and backup your machine to Tape, CD, etc.

29.1 Using Floppies for the absolute CRITICAL files

Copying files to floppies is EASY. All you need to do is:

- Format the floppy diskette:

- Mount the floppy

mount -t ext2 /dev/fd0 /mnt/floppy

- Copy at least the following files to the floppy:

- I would also recommend to record a full file listing of your system as well:


                                ls -laR / | gzip -9 > /mnt/floppy/file-list-`date +'%b%d'`.lst.gz

- Another GREAT idea comes from the Config-HOWTO to make a backup of your HD's Master Boot Record (MBR). So, instead of manually having to recreate it from your updated details in Section 4, simply copy the MBR to a file:

Example:

this will backup /dev/hda's table:


                                                dd if=/dev/hda of=/mnt/floppy/MBR bs=512 count=1

Use this to restore the table:


                                                dd if=/mnt/floppy/MBR of=/dev/hda bs=446 count=1

** You will need to redo this backup every time you:

29.2 Full backups using a Tape drive:

        +-----------------------------------------------------------------------------+
        | //// Prerequisites: \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\|
        +-----------------------------------------------------------------------------+
        |                                                                             |
        |   + Bru (tape software is installed).  Check by using this command:         |
        |                                                                             |
        |       whereis bru                                                           |
        |                                                                             |
        |                                                                             |
        |   + Compiled a kernel to either support (at MINIMUM).  Please see the       |
        |     Kernel Compiling Section for more details on how to do the following:   |
        |                                                                             |
        |   * IDE tape drives                                                         |
        |                                                                             |
        |   Enhanced IDE/MFM/RLL disk/cdrom/tape/floppy support (CONFIG_BLK_DEV_IDE)  |
        |   Include IDE/ATAPI TAPE support (CONFIG_BLK_DEV_IDETAPE)                   |
        |                                                                             |
        |              or                                                             |
        |                                                                             |
        |   * your specific SCSI controller with SCSI tape support                    |
        |                                                                             |
        |     SCSI support (CONFIG_SCSI)                                              |
        |     SCSI tape support (CONFIG_CHR_DEV_ST)                                   |
        |     Verbose SCSI error reporting (kernel size +=12K) (CONFIG_SCSI_CONSTANTS)|
        |                                                                             |
        |   .....and for example, the Adaptec 1522 SCSI controller:                   |
        |   Adaptec AHA152X/2825 support (CONFIG_SCSI_AHA152X)                        |
        |                                                                             |
        |                                                                             |
        |   + A properly installed IDE (master/slave) or a SCSI tape drive            |
        |     (with proper SCSI IDs and termination)                                  |
        |                                                                             |
        |                                                                             |
        |   + Files created/edited:                                                   |
        |                                                                             |
        |       /usr/local/sbin/bru-fullbackup                                        |
        |       /etc/brutab                                                           |
        |       /etc/bruxpa                                                           |
        |                                                                             |
        +-----------------------------------------------------------------------------+

(Bru isn't free if you don't install Redhat or Caldera but it's the best Linux backup software out there. This is one place you just CAN'T skimp!) If you don't want to use Bru, at least use CPIO instead of TAR. Tar does work fine UNTIL you hit an error on the tape. After that, tar will shutdown and you'll be screwed since it can't do data recovery. CPIO on the other hand can at least skip the bad file.

NOTE: I've noticed that the behavior of BRU between v14.3 and 15.0 (Bru2000) is quite different. Still works though!)

                +-----------------------------------------------------+
                | All the BRU documentation is available at:          |
                |                                                     |
                |         http://www.estinc.com/brumanual/toc.html    |
                +-----------------------------------------------------+

**NOTE**: This is ONLY for users running anything LESS than Glibc-2.0.7-19:

- To check , run "rpm -q glibc"

- Edit /etc/profile and add your appropriate time zone above the "export" command (this is for the Pacific time zone):

TZ=PDT

Next, find the line that starts with "export" and add "TZ" to the end of it. Here is my "export" line:

export PATH PS1 HOSTNAME HISTSIZE HISTFILESIZE USER LOGNAME MAIL NNTPSERVER TZ

Next, you need to setup BRU to understand your tape drive. Personally, I would recommend to use ESTINC's setups at:

http://www.estinc.com/brutabs.html

Or, startup Xwindows and run "bruconfig" and configure it this way.


        --< /etc/brutab START>--
        # BRUTAB Globals
        #+MAXWRITES=1000
        #+RAWZBUFSIZE=500
        #+RECYCLEDAYS=0
        #+OVERWRITEPROTECT=YES
        #+ZBUFSIZE=5M
        #
        # Changed Zbufsize from 500k to 2M
        # Changes size from 4000MT to 8000MT
        # Changed bufsize from 32k to 64k

        #### NOTE!!!  BRU tracks the size of uncompressed files by design.  
        ####
        ####          So, when using either software or hardware compression, simply set 
        ####              the tape drive capacity size to ZERO in /etc/brutab (size=0).

        # Devices
        /dev/st0 devname="NS-8 Drive, 8GB, rewind" \
             size=0MT bufsize=16k \
             shmseg=10 shmmax=200k \
             rawtape tape shmcopy rewind autoscan \
             fmtcmd="mt -f /dev/st0 erase" \
             rfmcmd="mt -f /dev/st0 fsf" \
             bfmcmd="mt -f /dev/st0 bsf" \
             retencmd="mt -f /dev/st0 reten" \
             rewindcmd="mt -f /dev/st0 rewind" \
             eodcmd="mt -f /dev/st0 seod" \
        
        /dev/nst0 devname="NS-8 Drive, 4GB, norewind" \
             size=0MT bufsize=16k \
             shmseg=10 shmmax=200k \
             rawtape tape shmcopy norewind noautoscan # # # # # # \
             fmtcmd="mt -f /dev/st0 erase" \
             rfmcmd="mt -f /dev/nst0 fsf 1" \
             bfmcmd="mt -f /dev/nst0 bsf 1" \
             retencmd="mt -f /dev/st0 retension" \
             rewindcmd="mt -f /dev/st0 rewind" \
             eodcmd="mt -f /dev/nst0 eod" \

        # /dev/null device, useful for testing
        /dev/null devname="Bit Bucket" \
             size=0 bufsize=20k \
             norewind noautoscan

        - devname="stdin/stdout" \
             size=0 bufsize=20k \
             norewind noautoscan
        
        --< /etc/brutab END>--

Now we need to setup an exclude file so you don't backup things like CD-ROM drives or compress ZIP files, etc. First, backup the original file by doing "mv /etc/bruxpat /etc/bruxpat.orig" and then create this file and edit it to fit your needs:


        --< /etc/bruxpat Start>--
        # Updated 03/09/99 to change the tape drive capacity to "0" for compression reasons
        # Updated 11/25/98 to add no compression of RAR files --dranch
        # Updated 7/23/98 to add Cdrom2-8 exclusion  --dranch
        # Updated 6/14/98 to add [aA] for the ARJ multivolume stuff --dranch
        #
        # This file is used by -X option to provide an inclusion/exclusion
        # list.  For each pathname of a file selected for backup, each line
        # of this file is examined for a pattern, and that pattern is applied
        # to the pathname.  If the pattern matches, the appropriate action
        # is taken (the pathname is accepted or rejected).  If the pathname
        # makes it through all the patterns it is accepted. 
        #
        # These patterns will ONLY be applied to filenames that are part
        # of directories that are specified on the bru command line (or
        # the current directory, if none are specified).
        # 
        #
        # Each command line in the bruxpat file (the file you are now reading)
        # consists of a control field and a pattern.  The pattern
        # is separated from the control field by whitespace.  Control field
        # characters are:
        #
        #       i       Include this pathname if pattern matches.  The
        #               pathname is accepted and no further patterns are
        #               applied.
        #                               *** NOTE ****
        #               It stops trying on the first pattern match found
        #               and passes the filename.  Since it scans patterns
        #               in the order listed, "include" patterns normally
        #               should be listed before any "exclude" patterns.
        #
        #       x       Exclude this pathname if pattern matches.  The
        #               pathname is rejected and no further patterns are
        #               applied.
        #
        #       z       Exclude this pathname from compression if pattern
        #               matches (if the -Z option is specified).
        #
        #       s       The pattern is a shell style wildcard pattern except
        #               that '/' characters are not treated as special characters.
        #
        #       r       The pattern is a regular expression (same as used by the "grep"
        #               command).
        #
        #       l       The pattern is a literal string.
        #

        # Exclude all core files
        xs      */core
        xs      core
        
        # Don't try to get the stuff in /proc
        xs      /proc/*
        xs      ./proc/*
        
        # Don't backup the CD-Rom
        xs      /home/hpe/CDROMs/Cdrom0/* 
        xs      ./home/hpe/CDROMs/Cdrom0/* 
        xs      /home/hpe/CDROMs/Cdrom1/* 
        xs      ./home/hpe/CDROMs/Cdrom1/* 
        xs      /home/hpe/CDROMs/Cdrom2/* 
        xs      ./home/hpe/CDROMs/Cdrom2/* 
        xs      /home/hpe/CDROMs/Cdrom2/* 
        xs      ./home/hpe/CDROMs/Cdrom2/* 
        xs      /home/hpe/CDROMs/Cdrom3/* 
        xs      ./home/hpe/CDROMs/Cdrom3/* 
        xs      /home/hpe/CDROMs/Cdrom4/* 
        xs      ./home/hpe/CDROMs/Cdrom4/* 
        xs      /home/hpe/CDROMs/Cdrom5/* 
        xs      ./home/hpe/CDROMs/Cdrom5/* 
        xs      /home/hpe/CDROMs/Cdrom6/* 
        xs      ./home/hpe/CDROMs/Cdrom6/* 
        xs      /home/hpe/CDROMs/Cdrom7/* 
        xs      ./home/hpe/CDROMs/Cdrom7/* 

        # Exclude all files and subdirectories in the temporary directories.
        # Handle files specified with relative and absolute pathnames
        #
        #   -- NOTE --  the actual directory names will still be backed up,
        #               only the files within the directories will be
        #               excluded.
        #xs     ./usr/tmp/*
        #xs     /usr/tmp/*
        #xs     ./tmp/*
        #xs     /tmp/*
        
        # Don't compress files that end in ".z" or ".Z"
        zs      *.[Zz]
        zs *.zip
        zs *.ZIP
        zs *.arj
        zs *.ARJ
        zs *.[Aa][0-9][0-9]
        zs *.[Rr][Aa][Rr]
        zs *.[Ra][0-9][0-9]
        zs *.[0-99]
        zs *.gz
        zs *.GZ
        zs *.gzip
        zs *.GZIP
        zs *.bz2
        zs *.BZ2
        zs *.tgz
        zs *.TGZ
        zs *.tar.gz
        zs *.tar.bz2
        zs *.rpm
        zs *.RPM
        zs *.iso
        zs *.ISO
        zs *.mp3
        zs *.MP3
        zs *.asf
        zs *.ASF
        zs *.[Gg][Ii][Ff]
        zs *.[Jj][Pp][Gg]
        zs *.[Mm][Pp][Gg]
        --

Create the file /usr/local/sbin/bru-fullbackup with the following in it. NOTE: You might want to change the label field to your tape drive and proper date


        --< /usr/local/sbin/bru-fullbackup >--
        #!/bin/sh
        clear

        # Edited 08/25/98

        #HP TR4 SCSI Internal, 2.0.36, 486/160Mz/40MB, 4)IDE 3)RAID0, AHA1542 SCSI
        #------------------------------------------------------------------------
        #02/09/99: wrote        (3904000 KBytes), 3:28:00, 330 Kb/sec (effective)
        #02/09/99: autoscan     (3904000 kbytes), 2:16:54, 475 Kb/sec

        echo "Setting environment vars"
        export BUFSIZE=16k
        export BRUTMPDIR=/tmp
        export BRUMAXWARNINGS=20000
        

        #Only needed for old Glibc users
        #export TZ=PDT

        echo "Compressing old log files.  This might take a while.."
        mv /var/log/bruexeclog /var/log/bruexeclog.`date +'%b%d'`
        mv /var/log/bru-log /var/log/bru-log.`date +'%b%d'`
        bzip2 -9f /var/log/bru-log.`date +'%b%d'`

        echo "Starting BRU full backup with exclusions, compression, user intervention"
        # Do not use -j, -m, 
        bru -c -vvvv -V -X -Z -G -L "Hp Tr4 11/27/98 - FULL" -f /dev/st0 / > /var/log/bru-log

        #Only needed for old Glibc users
        #export TZ=PST8PDT

        # v8.8.98
        #               See /etc/bruhelp for A LOT of more details
        #
        # Defaults to backing up "/"
        #
        # -c    : create (autoscan verification on by default)
        #       : - if you specify  -i or -d, autoverify is disabled 
        #
        # -d    : file comparison  (normal)
        # -dd    : file comparison access mod, lengths, symlinks, ID groups
        # -dddd : file comparison - hard core
        #
        # -e    : Estimate archive size
        #
        # -f    : select regular input device (same as -r)
        #
        # -g    : Read : Dumps the header block                                      
        # -gg   : Read : Generates ted cmd line, label, date, time, release,
        #
        # -h    : Print this help information
        #
        # -i    : inspect a archive *checksum of a directory)
        #       : Not needed with "-v"
        #
        # -r    : Backup a raw partition
        #
        # -t    : List archive table of contents for files
        #
        # -u - use selected files    
        #       a - all files
        #       b - block special files
        #       c - character (special files)
        #       d - dirs
        #       l -  syms
        #       p - fifos
        #       r - reg
        #
        # -vvvv : Level 4 verbosity
        #
        # -w    : confirmation of each file
        #
        #       : wildcard expantion [must be placed in double quotes]
        # -x    : restore
        #
        # -G    : Write a archive list (header block) at beginning of 
        # -L    : Label the tape
        # -B    : disabled user intervention
        # -D    : Enabled double buffering for faster throughput
        # -Z    : compression
        # -V      : execution summary w/o volume 
        # -X    : Exclude specific files
        #
        # bru -gg -f /dev/st0   : Display archive contents if written
        #
        #bru -vv -t -f /dev/st0 : Display entire contents of archive tape
        #
        #bru -x -vvvv /user/dranch/*  
        #
        # Also, these environment variables are available in /etc/brutab
        #
        # Global BRU settings
        #
        #+OVERWRITEPROTECT=YES
        #+RECYCLEDAYS=180
        #+MAXWRITES=200
        #+ZBUFSIZE=512k
        #+SHELL=/bin/sh
        #+BRUTABONLY=no
        #+DEVNAMECHECK=no
        #+MATCHLEVEL=2
        #+MAXFILENAMELEN=255
        #+READCHECKLEVEL=1
        #+BRUHELP=/bru/bruhelp
        #+BRUMAXWARNINGS=1000
        #+BRUMAXERRORS=500
        #+BRUXPAT=/etc/bruxpat
        #+BRURAW=/etc/bruraw
        #+BRUSMARTREST=/etc/brusmartrest
        #+BRUREMOVELOG=/var/adm/bruremovelog
        #+BRUTMPDIR=/tmp
        --< /usr/local/sbin/bru-fullbackup End.>

- Ok, go ahead and insert a tape in the tape drive and run


                        "/usr/local/sbin/bru-fullbackup"

I usually also run "tail -f /var/log/bru-log" in another TTY to watch the progress of the backup.

- Once your backup is completed, you need to verify that you can read the files OFF the tape, restore files to different places, and also restore files back to their ORIGINAL location:

-- Based on an email from the BRU mailing list:

The techniques differ depending on how the backup was created (absolute [/] or relative [.]). If you used "I" use "/" as a backup point, we are using absolute paths so (assuming you have a tape with full backups as well):

- Restore the /etc/passwd file to a different location (/tmp):


                                        cd /tmp
                                        bru  -xvf  /dev/st0  -PA  /etc/passwd

* the trick is "-PA" which translates absolute to relative

Now test that the files are the same:


                                        diff /etc/passwd /tmp/passwd

- Restore the /bin/fullbru file to the same location (/bin):


                                        mv  /bin/fullbru  /bin/fullbru.save
                                        bru  -xvf  /dev/st0  /bin/fullbru

- Now test that the files are the same:


                                        diff /bin/fullbru.save /bin/fullbru

- Once you are convinced that you have a good backup, now its time to create a rescue diskette.

- Download the BRU rescue diskette from:

ftp://ftp.estinc.com/pub/linux/Bootkit-1.01.tar.gz

- Here are a few other scripts that I find useful with Bru:


                --< /usr/local/sbin/bru-viewtape >--
                #!/bin/sh
                clear

                #echo "Starting BRU to view tape contents"
                bru -gg -f /dev/st0 > /var/log/bru-tape-contents.`date +'%b%d'` 2>&1

                --<end.>--


                --< /usr/local/sbin/bru-find-changes >--
                #!/bin/sh
                clear

                # Edited 01/06/99

                echo "Setting environment vars"
                export BUFSIZE=16k
                export BRUTMPDIR=/tmp
                export BRUMAXWARNINGS=20000
                #export TZ=PDT
                
                echo "Starting BRU to find all changed/missing files between tape and disk.."
                bru -dd -f /dev/st0 / > /var/log/bru-diff-del-find-log.`date +'%b%d'` 2>&1

                --<end.>--


                --< /usr/local/sbin/bru-restore >--
                #!/bin/sh
                clear

                # Edited 03/09/99
                #
                # NOTE:  This script is run as:  "/usr/local/sbin/bru-restore /home/username"
                #          where the "/home/username" is the path and/or the full path and filename
                #          of the data you want to restore.  Bru will then find this data on the
                #          tape and restore it to its original location.  If you want to restore
                #          the file to a DIFFERENT location, please consult the manual for
                #          "absolute to relative path translation"
                #
                
                echo "Setting environment vars"
                export BUFSIZE=16k
                export BRUTMPDIR=/tmp
                export BRUMAXWARNINGS=20000
                #export TZ=PDT
                
                echo "Compressing old log files.  This might take a while.."
                mv /var/log/bru-restore-log /var/log/bru-restore-log.`date +'%b%d'` 
                mv /var/log/bruexeclog /var/log/bruexeclog.`date +'%b%d'` 
                bzip2 -9f /var/log/bru-restore-log.`date +'%b%d'`
                
                echo "Starting BRU partial restore "
                # Do not use -j, -m, 
                bru -x -vvvv -f /dev/st0 $1 > /var/log/bru-restore-log
                --<end.>--

29.3 Using a CD-R or CD-R/W drive

See Section 39 for full details.


Next Previous Contents