notes & tips in backups
Welcome to notes & tips on backups



This page is meant for misc. notes on set ups that are used for backup it is relevent to Debian 2.2, Red Hat 5.2/6.2/7.0 and Solaris 6/7 (tested platforms).

Tar

Tape ARchiver.

Single file/directory backup

Common tar flag options, (see man tar for more)

t = list
c = collect
v = verbose
f = file
S = treat zero length files efficiently
z = compress
p = preserve permissions
x = extract

For a manual command the tar command is quite simple,

tar zcvf /dev/st0 /dir will back up the directory contents and those sub dir's below it to the first detected scsi tape device (st0). The file will be compressed as "z" has been used. Do not attempt to use this command from / as the tar will abort!

To backup a complete system create a script (called say tarback) as follows,

#!/bin/bash
#21/6/01
#tar script to backup this box

tar Spcvvf /dev/st0 /boot /bin /etc /home /lib /root /sbin \
/usr /var

Now change the script to executable with chmod 0744 tarback

Now type ./tarback

You could add this as a cron job to run at a set time.

To verify the backup file use the command tar ztvf /dev/st0 If you didnt compress then use tar tvf /dev/st0 (lots of DLT's can be set to hardware compress so use this if possible).

If you dont have a tape device but want to backup to another disk partition subsitute the device (dev/st0) with path/filename.tar.gz ./*

Whole filesystem backup

Linux

Now suppose you want to backup your entire file system but leave out certain directories like /dev and /proc using the above command from the root partition sounds sensible, however it usually barfs. So instead try this command, tar -l -Spzcf /dev/st0 /usr /bin /sbin /home /etc /root /boot /var /home/share Now do a ls -al from root to make sure all the dir's here are included. Note /home/share, this is another partition mounted onto the /home/share/ mount point, therefore the tar command I give here will not span partitions this is why I specify /home/share explicitly.

Solaris

You can use similar commands on solaris except solaris's tar does not support -l, z ie compression or S ie efficient handling of zero length files, and the device is /dev/rmt/0eg.

tar cvfp /dev/rmt/0 /boot /bin /etc /export /kernel /Mail /net /opt /platform /sbin /shlib /usr /var /vol /xfn

Detecting tape drives on solaris

Solaris allows hot adding of devices to the scsi chain ie to mount a tape drive after the sun machine has booted install it physically and then run,

/usr/sbin/drvconfig

/usr/sbin/devlinks

/usr/sbin/tapes (or disks for HDrives)

/usr/ucb/ucb/links (NB sparc platform only, Intel doesnt seem to need it)

then to check the tape is discovered,

mt -f /dev/rmt/0 status (also works on Linux as /dev/st0)

mt -f /devrmt/0 rewind will rewind the tape (also works on Linux as /dev/st0)

If you want to use a tape but not to rewind then use the n option eg, tar cvfp /dev/rmt/0n /boot /bin /etc (or /dev/nst0 in Linux)

ufsdump on Solaris

First look at /etc/vfstab

device to mount		device to fsck			FS	mount point		fsck pass	mount point		option
/dev/dsk/c0t0d0s0   /dev/rdsk/c0t0d0s0 		ufs		/           	1  		yes  			-
/dev/dsk/c0t0d0s2   /dev/rdsk/c0t0d0s2 		ufs		/usr        	1  		yes  			-
/dev/dsk/c0t0d0s4   /dev/rdsk/c0t0d0s4 		ufs		/var        	1  		yes  			-
/dev/dsk/c0t0d0s7   /dev/rdsk/c0t0d0s7 		ufs		/localopt   	2  		yes  			-
fd					/dev/fd					fd		-				no		-
/proc				/proc					proc	-				no		-				-
swap				-						tmpfs	/tmp			-		yes				-

The columns in this file list:

1)The device special file to mount ie the 6th slice (s6) of drive 0 (d0) of lun 0 (t0) of controller 0 (c0), this indicates a scsi drive.
2)The device on which to run fsck (usually the corresponding raw device).
3)The file system type
4)The mount point to mount the slice/partition on.
5)A flag for fsck specifying the order in which the partition should be checked
5)Whether to mount at boot time
6)Any options to mount for this partition

Notice that vfstab on solaris and fstab on Linux are similar.

Here is a neat script written by Wray Smart which queries /etc/vfstab on a solaris box (2.6) and backs up the system to a scsi tape drive.

put it in u silly sod!!! doh lost need to find it....

dump & restore on Linux

lets first look at /etc/fstab as dump uses this file to decide which partitions to dump.

# /etc/fstab: static file system information.
#
# < file system > < mount point > < type > < options >              < dump > < pass >
   /dev/hda1            /           ext2   defaults,errors=remount-ro 0      1
   /dev/hda3            none        swap   sw                         0      0
   /proc                /proc       proc   defaults                   0      0
   /dev/hdb1            /home       ext2   defaults                   0      2
   /dev/hdc1            /var        ext2   defaults                   0      2
The number in the backup column is used by the dump program to decide if a filesystem should be backed up (1 means yes, 0 means no). The number in the Check? column tells the system whether to run fsck to validate the filesystem at boot time. The root partition is always given number 1. Other filesystems to be checked get number 2, this sets the order of the check.

Amanda

Amanda is a network backup system useful for a site with many machines and one large scsi tape drive. (NB I'm working on a silo < grin >)

Amanda consists of a server and a client, it also works best if there is a dedicated empty hard drive/partiton to allow the backup to be dumped to before transferring to tape.

Amanda Client

This is the easiest to setup, start by downloading the package by typing apt-get install amanda-client, this should also bring down the package amanda-common.

The default user for amanda on Debian is backup, create this user with a home directory of /var/backups, disable the user by putting backup in /etc/ftpusers. You may well need to su from root to backup so leave the shell in /etc/passwd active for now but change /bin/sh (or /bin/bash) to /dev/null later.

The client file needed is /var/backups/.amandahosts, in here goes the FQDN of the tape server and the user eg,

kascha.thing.dyndns.org backup

Thats it for the client side!

Amanda Server

You will want the server package, and possibly the client package so the server can back itself up so type,
apt-get install amanda-client amanda-server watch that the amanda-common package comes down as well.

The client is set up as before except the /var/backups/.amandahost file has 2 lines,

localhost backup
kascha root

The second line is needed for amrecover, it might be needed on ALL clients, I have not tested it yet on a remote client only on the tape-server.

Create a holding partition of say 1~3gig for data before it is backed up to tape, mine is called /backup-space and its 3.5 Gig.
amanda.conf

Here is my amanda.conf, there is a defalut one install, therefore backup this up then edit it to suit your needs.


#ssj 24/3/01 - working
# amanda.conf - sample Amanda configuration file.  
#
# If your configuration is called, say, "DailySet1", then this file
# normally goes in /etc/amanda/DailySet1/amanda.conf.
# 
# for explanation of the parameters refer to amanda(8) and
# /usr/doc/amanda/WHATS.NEW.gz 

org "DailySet1"         # your organization name for reports
mailto "root@thing.dyndns.org"  # space separated list of mail ssj
#12
dumpuser "backup"       # the user to run dumps under

dumpcycle 1   #ssj added

#tapedev /dev/nst0 #ssj added disabled as per man page

inparallel 4            # maximum dumpers that will run in parallel
netusage  6000          # maximum net bandwidth for Amanda, in KB persec

# a filesystem is due for a full backup once every < dumpcycle > days
#ssj dumpcycle 4 weeks  # the number of days in the normal dump cycle
tapecycle 10 tapes      # the number of tapes in rotation
#25
bumpsize 20 MB          # minimum savings (threshold) to bump level 1 - > 2
bumpdays     1          # minimum days at each level
bumpmult     4          # threshold = bumpsize * (level-1)**bumpmult

#runtapes     9         # explained in WHATS.NEW
#tpchanger "no-changer" # the tape-changer glue script, see TAPE.CHANGERS
tapedev "/dev/nst0"     # Linux @ tuck, important: norewinding
# tapedev "/dev/nrst8"  # or use the (no-rewind!) tape device directly

tapetype DEC-DAT        # ssj what kind of tape it is (seetapetypesbelow)
labelstr "^kaitlin[0-9][0-9]*$" # label constraint regex: all tapes

diskdir "/backup_space"         # where the holding disk is
disksize 3500 MB                        # how much space can we use on
#40
#diskdir "/dumps/amanda/work"   # additionaly holding disks can be specified
#diskdir "/mnt/disk4"
#disksize 1000 MB               #       they are used round-robin


# Amanda needs a few MB of diskspace for the log and debug files,
# as well as a database.  This stuff can grow large, so the conf directory
# isn't usually appropriate.

infofile "/var/lib/amanda/DailySet1/curinfo"    # database filename
logfile  "/var/log/amanda/DailySet1/log"        # log filename

# where the index files live
indexdir "/var/lib/amanda/DailySet1/index"
#55
#strategy "noinc" #ssj wrong place see below

#ssj faulty compress server best  #ssj

#program GNUTAR #ssj wrong place see below
#61


# tapetypes
#
# Define the type of tape you use here, and use it in "tapetype" above.
# Some typical types of tapes are included here.  The tapetype tells amanda
# how many MB will fit on the tape, how big the filemarks are, and how
# fast the tape device is.
#
# For completeness Amanda should calculate the inter-record gaps too, but it
# doesn't.  For EXABYTE and DAT tapes this is ok.  Anyone using 9 tracks for
# amanda and need IRG calculations?  Drop me a note if so.
#74

#126 ssj my dlt 20/40gig amstor
define tapetype DEC-DAT {
    comment "DAT tape drives - tk88"
    length 25000 mbytes         # these numbers are not accurate
    filemark 100 kbytes         # but you get the idea
    speed 500 kbytes
}

# dumptypes
#
# These are referred to by the disklist file.  The dumptype specifies
# certain "options" for dumping including:
#       index           - keep an index of the files backed up
#       compress-fast   - (default) compress on the client using fast algorithm
#       compress-best   - compress using the best (and slowww) algorithm
#       no-compress     - don't compress the dump output
#       srvcompress     - Compress dumps on the tape host instead of client
#                         machines.  This may be useful when a fast tape host
#                         is backing up slow clients.
#       record          - (default) record the dump in /etc/dumpdates
#       no-record       - don't record the dump, for testing
#       no-hold         - don't go to the holding disk, good for dumping
#                         the holding disk partition itself.
#       skip-full       - Skip the disk when a level 0 is due, to allow
#                         full backups outside Amanda, eg when the machine
#                         is in single-user mode.
#       skip-incr       - Skip the disk when the level 0 is NOT due.  This
#                         is used in archive configurations, where only full
#                         dumps are done and the tapes saved.
#       no-full         - Do a level 1 every night.  This can be used, for
#                         example, for small root filesystems that only change
#                         slightly relative to a site-wide prototype.  Amanda
#                         then backs up just the changes.
#
# Also, the dumptype specifies the priority level, where "low", "medium" and
# "high" are the allowed levels.  These are only really used when Amanda has
# no tape to write to because of some error.  In that "degraded mode", as
# many incrementals as will fit on the holding disk are done, higher priority
# first, to insure the important disks are dumped first.

define dumptype always-full {
    comment "Full dump of this filesystem always"
    options no-compress
    priority high
    dumpcycle 0
    maxcycle 0
}
#ssj my option for linux boxes
define dumptype gnutar-full {
    program "GNUTAR"
    comment "Full dump of this filesystem always"
    options compress-fast
    priority high
    dumpcycle 0
    maxcycle 0
    index yes
}

Index yes is needed if you want to use amrecover, it does have an overhead though (read filesize).

Tapelist

This is normally empty, however it will fill up as below as it does the daily backup.

20010413 kaitlin08 reuse
20010412 kaitlin07 reuse
20010412 kaitlin11 reuse
20010331 kaitlin06 reuse
20010330 kaitlin05 reuse
20010329 kaitlin04 reuse
20010329 kaitlin03 reuse
20010328 kaitlin02 reuse
20010328 kaitlin01 reuse
20010328 kaitlin09 reuse

Disklist

Here you list the hosts and the partition or filesystem to backup.

#ssj below here

#start with kascha the tape-server

#kascha sda1 gnutar-full
#kascha sdb1 gnutar-full
#kascha sdb2 gnutar-full
 
localhost /root gnutar-full
localhost /bin  gnutar-full
localhost /boot gnutar-full
localhost /etc  gnutar-full
localhost /lib  gnutar-full
localhost /sbin gnutar-full
localhost  sdb1 gnutar-full
localhost  sdb2 gnutar-full
localhost  sdb3 gnutar-full
localhost  sdc1 gnutar-full

#kaipan first remote machine as a test

#kaipan    /root gnutar-full
#kaipan    /bin         gnutar-full
#kaipan    /boot gnutar-full
#kaipan    /etc  gnutar-full
#kaipan    /lib  gnutar-full
#kaipan    /sbin gnutar-full
#kaipan    /home gnutar-full
#kaipan   /usr  gnutar-full

#kaitlin the fileserver

kaitlin    /dev/hda1 gnutar-full
kaitlin    /dev/hda5 gnutar-full
kaitlin    /dev/hda6 gnutar-full
kaitlin    /dev/hdd2 gnutar-full
kaitlin    /home/share  gnutar-full

As you can see you can either specify the mount point or the partition or mix them.

Cron

Amanda is normally run from a cronjob by the user "backup" (maybe another user on another OS eg Red Hat uses "operator"?)

So set up 2 crontabs, one as a check before you go home and another for the actual backup job. Type crontab -u backup -e

45 15 * * 1-6 /usr/sbin/amcheck -m DailySet1
00 21 * * 1-6 /usr/sbin/amdump DailySet1

amcheck should mail you if it finds problems, and amdump will mail you on completion.

Known Bugs

Version 2.4.1p1 & 2.4.2 have amrecover bugs that stop a remote linux host recovering data, upgrade to 2.4.2p2 to fix this issue.



Copyright Thing 25/4/2001 to be used freely without restriction, however if this page is copied to your own web site please drop me a line with the URL - thanks.