]> git.wh0rd.org - dump.git/blame - examples/howto/ultra-mini-howto
Added howto from Patrick Walsh
[dump.git] / examples / howto / ultra-mini-howto
CommitLineData
d37187a4
SP
1Stelian,
2
3 I just got dump running on my system backing up a handful of unix
4servers and at the end of it I wrote a quick and dirty document that lays
5out the answers to some of the questions that I had. I don't want to
6maintain it or get a flood of e-mail from people asking for help on it, so I
7signed it, but intentionally didn't put an e-mail address.
8
9 You are welcome to make this prettier, totally discard it, or put it up
10on the web page. I hope it is accurate and relieves some of the common
11questions from the list.
12
13..Patrick
14
15
16
17
18Dump/Restore Ultra-Mini-FAQ
19
20Disclaimer: I am not an expert in dump/restore. In fact,
21I'm a newbie. But I've been picking things up as I
22implement it here and I wanted to pass some of those
23things along in the form of a very basic HOWTO.
24
25-Patrick Walsh
26
271) Introduction/ Non-rewinding device
282) Dump command line
293) Sending 2 or more filesystems to a tape
304) Compressing dumps on the fly
315) The "nodump" file and directory attribute.
326) Restoring your dumps (including compressed).
337) How to confirm a backup
348) Example backup script
35
36 1) Introduction/ Non-rewinding device
37
38You use dump to backup to a file or a tape device. If
39you're backing up to a tape device, then the first thing
40you need to understand is that there are two devices
41that refer to your tape drive. There is the "rewinding"
42device and the "non-rewinding" device.
43
44I wish I could tell you an easy way to figure out what
45your device names are, but I don't know one. On my
46local box I had a /dev/tape device that linked to
47/dev/st0. It turns out that /dev/st0 is my "rewinding"
48tape drive. If I write to this device it will always
49rewind before starting to write. This means that if
50you try to dump two filesystems, only the second one
51will be stored. If your tape device is /dev/st0, like
52mine, then your non-rewinding tape device is probably
53/dev/nst0.
54
55Anyway, through the rest of this I will refer to $TAPE
56and $RWTAPE. $TAPE is the non-rewinding device (in my
57case /dev/nst0) and $RWTAPE is the rewinding tape (in my
58case /dev/st0 and /dev/tape). $FS is the filesystem you
59are backing up, such as /dev/hda1.
60
61 2) What options should I use?
62
63Use the man page to figure out what options to send
64to dump. I use "dump 0uanf $TAPE $FS".
65
66 u=update /etc/dumpdates after a successful dump
67 a=auto-size -- bypass all tape length calculations and
68 write until eof
69 n=notify 'operators' group when dump needs attention
70 f=backup to file or device specified, or - for stdout
71
72 3) You want to send two or more filesystems to the tape.
73
74OK, rewind using the mt command, then dump multiple times
75to the non-rewinding device, and you're done:
76
77mt -f $TAPE rewind
78dump 0uanf $TAPE $FS1
79dump 0uanf $TAPE $FS2
80etc.
81
82Check the man page of mt if you want to know how to eject
83the tape or retension it or anything.
84
85 4) You want to compress your dumps on the fly. No
86problem. Send your backup to STDOUT and manipulate it
87from there. It's easier if you're sending your output to
88the hard drive:
89
90dump 0uanf - $FS | gzip -c > /backup/outfile.dump.gz
91
92You want that to be written to the tape on the fly? Try
93this:
94
95mt -f $TAPE rewind
96dump 0uanf - $FS |gzip -c |dd if=- of=$TAPE
97
98[ You can also use the -z or -J options of dump in the
99 recent versions to enable internal compression - stelian ]
100
101 5) You read the man page and you're wondering what the
102heck a "nodump" flag is. For example, how can you get
103dump to stop backing up /tmp or ~/.netscape/cache. You
104have two options: either exclude the inode in your dump
105command, or flag the files and directories with the
106"nodump" flag. To flag /tmp, for example, do this:
107
108chattr -R +d /tmp
109
110Want more details? Try 'man chattr' and 'man lsattr'.
111
112 6) You want to know how to restore your backup.
113
114Read the restore man page. But barring that, the easy way
115is to use restore in interactive mode. If you have three
116filesystems on one tape and you want to restore files from
117the second one, you need to do this:
118
119mt -f $TAPE rewind
120mt -f $TAPE fsf 1 # skip forward one file
121restore -if $TAPE
122
123OK, suppose now that you used the commands in section 4 to
124compress the dump file before it was written to disk. Use
125this command:
126
127mt -f $TAPE rewind
128mt -f $TAPE fsf 1
129dd if=$TAPE of=- |gzip -dc |restore -rf -
130
131Obviously if you dumped to a file instead of a tape it is
132much easier:
133
134gzip -dc $filename |restore -rf -
135
136 7) How to confirm your backup
137
138 Check out the restore man page and read up on the -C option.
139
140 8) That about sums up my knowledge on the matter, but
141I feel better having written something for other people to
142look at so it doesn't take them quite so long to learn the
143things I did. I've included my backup script below.
144There are much better ones floating around, so go find
145someone else's and use theirs if mine won't work for you
146or you don't understand it.
147
148
149#!/bin/csh
150# System backup script for NARNIA
151
152# This is a script that will backup the entire hard drive
153# to the NT server (not my choice) \\fs1.
154#
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
158# before.
159# Each full backup will be sent to the local tape as well as to the
160# NT machine.
161#
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.
165
166# Dump options:
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
171
172# Set variables that control the script.
173setenv MOUNTPOINT '/root/fs1backup'
174setenv OUTDIR '/root/fs1backup/narnia'
175setenv TAPE '/dev/nst0' # non-rewinding tape
176
177# Auto-set variable that determines level of backup.
178setenv DAY `date +'%w'`
179
180# Mount the backup partition to /root/fs1backup
181/usr/bin/smbmount \\\\fs1\\backup $MOUNTPOINT -o
182"username=uname,password=pword"
183
184# Delete files created on this day last week
185rm -f $OUTDIR/*$DAY.dump.gz
186
187# Do the actual backing up, one filesystem at a time.
188
189# /dev/hda1 = /boot
190/sbin/dump $DAY'uanf' - /dev/hda1 | gzip -c >$OUTDIR/boot-$DAY.dump.gz
191
192# /dev/hda2 = /
193/sbin/dump $DAY'uanf' - /dev/hda2 | gzip -c >$OUTDIR/root-$DAY.dump.gz
194
195# /dev/hda3 = /usr
196/sbin/dump $DAY'uanf' - /dev/hda3 | gzip -c >$OUTDIR/usr-$DAY.dump.gz
197
198# /dev/hdb2 = /u1
199/sbin/dump $DAY'uanf' - /dev/hdb2 | gzip -c >$OUTDIR/u1-$DAY.dump.gz
200
201
202# OK, presumably everything is now backed up to \\fs1. On level 0
203# dumps, lets backup to the local drive too.
204if ($DAY == 0) then
205 mt -f $TAPE retension
206 foreach i ($OUTDIR/*0.dump.gz)
207 dd if=$i of=$TAPE
208 end
209 mt -f $TAPE rewind
210endif
211
212
213# Unmount the backup partition, not needed outside of script
214umount /root/fs1backup
215
216# Explicitly free up the temporary variables
217unsetenv DAY
218unsetenv MOUNTPOINT
219unsetenv OUTDIR
220unsetenv TAPE
221
222
223# RESTORE DIRECTIONS:
224# If from tape:
225# dd if=$TAPE of=- | gzip -dc | restore -rf -
226# or dd if=$TAPE |gzip -dc |restore -rf -
227#
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
232#
233# Use mt to skip between them:
234# mt -f $TAPE rewind
235# restore -if $TAPE #now restoring /boot, probably
236# mt -f $TAPE fsf 1
237# restore -if $TAPE #now restoring /
238# mt -f $TAPE fsf 1
239# restore -if $TAPE #now restoring /usr
240# #etc.
241#
242# Otherwise:
243# gzip -dc $filename | restore -rf -
244