3 I just got dump running on my system backing up a handful of unix
4 servers and at the end of it I wrote a quick and dirty document that lays
5 out the answers to some of the questions that I had. I don't want to
6 maintain it or get a flood of e-mail from people asking for help on it, so I
7 signed it, but intentionally didn't put an e-mail address.
9 You are welcome to make this prettier, totally discard it, or put it up
10 on the web page. I hope it is accurate and relieves some of the common
11 questions from the list.
18 Dump/Restore Ultra-Mini-FAQ
20 Disclaimer: I am not an expert in dump/restore. In fact,
21 I'm a newbie. But I've been picking things up as I
22 implement it here and I wanted to pass some of those
23 things along in the form of a very basic HOWTO.
27 1) Introduction/ Non-rewinding device
29 3) Sending 2 or more filesystems to a tape
30 4) Compressing dumps on the fly
31 5) The "nodump" file and directory attribute.
32 6) Restoring your dumps (including compressed).
33 7) How to confirm a backup
34 8) Example backup script
36 1) Introduction/ Non-rewinding device
38 You use dump to backup to a file or a tape device. If
39 you're backing up to a tape device, then the first thing
40 you need to understand is that there are two devices
41 that refer to your tape drive. There is the "rewinding"
42 device and the "non-rewinding" device.
44 I wish I could tell you an easy way to figure out what
45 your device names are, but I don't know one. On my
46 local box I had a /dev/tape device that linked to
47 /dev/st0. It turns out that /dev/st0 is my "rewinding"
48 tape drive. If I write to this device it will always
49 rewind before starting to write. This means that if
50 you try to dump two filesystems, only the second one
51 will be stored. If your tape device is /dev/st0, like
52 mine, then your non-rewinding tape device is probably
55 Anyway, through the rest of this I will refer to $TAPE
56 and $RWTAPE. $TAPE is the non-rewinding device (in my
57 case /dev/nst0) and $RWTAPE is the rewinding tape (in my
58 case /dev/st0 and /dev/tape). $FS is the filesystem you
59 are backing up, such as /dev/hda1.
61 2) What options should I use?
63 Use the man page to figure out what options to send
64 to dump. I use "dump 0uanf $TAPE $FS".
66 u=update /etc/dumpdates after a successful dump
67 a=auto-size -- bypass all tape length calculations and
69 n=notify 'operators' group when dump needs attention
70 f=backup to file or device specified, or - for stdout
72 3) You want to send two or more filesystems to the tape.
74 OK, rewind using the mt command, then dump multiple times
75 to the non-rewinding device, and you're done:
82 Check the man page of mt if you want to know how to eject
83 the tape or retension it or anything.
85 4) You want to compress your dumps on the fly. No
86 problem. Send your backup to STDOUT and manipulate it
87 from there. It's easier if you're sending your output to
90 dump 0uanf - $FS | gzip -c > /backup/outfile.dump.gz
92 You want that to be written to the tape on the fly? Try
96 dump 0uanf - $FS |gzip -c |dd if=- of=$TAPE
98 [ You can also use the -z or -J options of dump in the
99 recent versions to enable internal compression - stelian ]
101 5) You read the man page and you're wondering what the
102 heck a "nodump" flag is. For example, how can you get
103 dump to stop backing up /tmp or ~/.netscape/cache. You
104 have two options: either exclude the inode in your dump
105 command, or flag the files and directories with the
106 "nodump" flag. To flag /tmp, for example, do this:
110 Want more details? Try 'man chattr' and 'man lsattr'.
112 6) You want to know how to restore your backup.
114 Read the restore man page. But barring that, the easy way
115 is to use restore in interactive mode. If you have three
116 filesystems on one tape and you want to restore files from
117 the second one, you need to do this:
120 mt -f $TAPE fsf 1 # skip forward one file
123 OK, suppose now that you used the commands in section 4 to
124 compress the dump file before it was written to disk. Use
129 dd if=$TAPE of=- |gzip -dc |restore -rf -
131 Obviously if you dumped to a file instead of a tape it is
134 gzip -dc $filename |restore -rf -
136 7) How to confirm your backup
138 Check out the restore man page and read up on the -C option.
140 8) That about sums up my knowledge on the matter, but
141 I feel better having written something for other people to
142 look at so it doesn't take them quite so long to learn the
143 things I did. I've included my backup script below.
144 There are much better ones floating around, so go find
145 someone else's and use theirs if mine won't work for you
146 or you don't understand it.
150 # System backup script for NARNIA
152 # This is a script that will backup the entire hard drive
153 # to the NT server (not my choice) \\fs1.
155 # On each Sunday night, a full backup will be made
156 # of the hard drive and each day of the week thereafter an incremental
157 # backup will be made that captures only those changes since the night
159 # Each full backup will be sent to the local tape as well as to the
162 # The files will be stored in partition-specific files with integer
163 # endings that specify the day of the week they were saved. Files
164 # with zero on the end will always be full backups.
167 # a=auto-size -- bypass all tape length calculations and write until eof
168 # f=write the backup to file or device specified or - for stdout
169 # n=notify operators group when dump needs attention
170 # u=update /etc/dumpdates after a successful dump
172 # Set variables that control the script.
173 setenv MOUNTPOINT '/root/fs1backup'
174 setenv OUTDIR '/root/fs1backup/narnia'
175 setenv TAPE '/dev/nst0' # non-rewinding tape
177 # Auto-set variable that determines level of backup.
178 setenv DAY `date +'%w'`
180 # Mount the backup partition to /root/fs1backup
181 /usr/bin/smbmount \\\\fs1\\backup $MOUNTPOINT -o
182 "username=uname,password=pword"
184 # Delete files created on this day last week
185 rm -f $OUTDIR/*$DAY.dump.gz
187 # Do the actual backing up, one filesystem at a time.
190 /sbin/dump $DAY'uanf' - /dev/hda1 | gzip -c >$OUTDIR/boot-$DAY.dump.gz
193 /sbin/dump $DAY'uanf' - /dev/hda2 | gzip -c >$OUTDIR/root-$DAY.dump.gz
196 /sbin/dump $DAY'uanf' - /dev/hda3 | gzip -c >$OUTDIR/usr-$DAY.dump.gz
199 /sbin/dump $DAY'uanf' - /dev/hdb2 | gzip -c >$OUTDIR/u1-$DAY.dump.gz
202 # OK, presumably everything is now backed up to \\fs1. On level 0
203 # dumps, lets backup to the local drive too.
205 mt -f $TAPE retension
206 foreach i ($OUTDIR/*0.dump.gz)
213 # Unmount the backup partition, not needed outside of script
214 umount /root/fs1backup
216 # Explicitly free up the temporary variables
223 # RESTORE DIRECTIONS:
225 # dd if=$TAPE of=- | gzip -dc | restore -rf -
226 # or dd if=$TAPE |gzip -dc |restore -rf -
228 # Note: must queue tape to proper position first. This
229 # is done by first rewinding then advancing to the proper
230 # file. The order that files are written to tape is
231 # *probably* 0=/boot 1=/ 2=/usr 3=/u1
233 # Use mt to skip between them:
235 # restore -if $TAPE #now restoring /boot, probably
237 # restore -if $TAPE #now restoring /
239 # restore -if $TAPE #now restoring /usr
243 # gzip -dc $filename | restore -rf -