]>
Commit | Line | Data |
---|---|---|
d37187a4 SP |
1 | Stelian, |
2 | ||
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. | |
8 | ||
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. | |
12 | ||
13 | ..Patrick | |
14 | ||
15 | ||
16 | ||
17 | ||
18 | Dump/Restore Ultra-Mini-FAQ | |
19 | ||
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. | |
24 | ||
25 | -Patrick Walsh | |
26 | ||
27 | 1) Introduction/ Non-rewinding device | |
28 | 2) Dump command line | |
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 | |
35 | ||
36 | 1) Introduction/ Non-rewinding device | |
37 | ||
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. | |
43 | ||
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 | |
53 | /dev/nst0. | |
54 | ||
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. | |
60 | ||
61 | 2) What options should I use? | |
62 | ||
63 | Use the man page to figure out what options to send | |
64 | to 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 | ||
74 | OK, rewind using the mt command, then dump multiple times | |
75 | to the non-rewinding device, and you're done: | |
76 | ||
77 | mt -f $TAPE rewind | |
78 | dump 0uanf $TAPE $FS1 | |
79 | dump 0uanf $TAPE $FS2 | |
80 | etc. | |
81 | ||
82 | Check the man page of mt if you want to know how to eject | |
83 | the tape or retension it or anything. | |
84 | ||
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 | |
88 | the hard drive: | |
89 | ||
90 | dump 0uanf - $FS | gzip -c > /backup/outfile.dump.gz | |
91 | ||
92 | You want that to be written to the tape on the fly? Try | |
93 | this: | |
94 | ||
95 | mt -f $TAPE rewind | |
96 | dump 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 | |
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: | |
107 | ||
108 | chattr -R +d /tmp | |
109 | ||
110 | Want more details? Try 'man chattr' and 'man lsattr'. | |
111 | ||
112 | 6) You want to know how to restore your backup. | |
113 | ||
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: | |
118 | ||
119 | mt -f $TAPE rewind | |
120 | mt -f $TAPE fsf 1 # skip forward one file | |
121 | restore -if $TAPE | |
122 | ||
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 | |
125 | this command: | |
126 | ||
127 | mt -f $TAPE rewind | |
128 | mt -f $TAPE fsf 1 | |
129 | dd if=$TAPE of=- |gzip -dc |restore -rf - | |
130 | ||
131 | Obviously if you dumped to a file instead of a tape it is | |
132 | much easier: | |
133 | ||
134 | gzip -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 | |
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. | |
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. | |
173 | setenv MOUNTPOINT '/root/fs1backup' | |
174 | setenv OUTDIR '/root/fs1backup/narnia' | |
175 | setenv TAPE '/dev/nst0' # non-rewinding tape | |
176 | ||
177 | # Auto-set variable that determines level of backup. | |
178 | setenv 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 | |
185 | rm -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. | |
204 | if ($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 | |
210 | endif | |
211 | ||
212 | ||
213 | # Unmount the backup partition, not needed outside of script | |
214 | umount /root/fs1backup | |
215 | ||
216 | # Explicitly free up the temporary variables | |
217 | unsetenv DAY | |
218 | unsetenv MOUNTPOINT | |
219 | unsetenv OUTDIR | |
220 | unsetenv 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 |