aboutsummaryrefslogtreecommitdiff
path: root/en_US.ISO8859-1/books/handbook/backups/chapter.sgml
blob: b6c5c3c2928137f1e6c6d2559268402eb28e6066 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
<!--
     The FreeBSD Documentation Project

     $FreeBSD: doc/en_US.ISO_8859-1/books/handbook/backups/chapter.sgml,v 1.22 2000/05/15 00:10:38 joe Exp $
-->

<chapter id="backups">
  <title>Backups</title>

  <sect1>
    <title>Synopsis</title>

    <para>The following chapter will cover methods of backing up data, and
      the programs used to create those backups.  If you would like to
      contribute something to this section, send it to the &a.doc;.</para>
  </sect1>

  <sect1 id="backups-tapebackups">
    <title>Tape Media</title>
    
    <para>The major tape media are the 4mm, 8mm, QIC, mini-cartridge and
      DLT.</para>
    
    <sect2 id="backups-tapebackups-4mm">
      <title>4mm (DDS: Digital Data Storage)</title>

      <para>4mm tapes are replacing QIC as the workstation backup media of
	choice.  This trend accelerated greatly when Conner purchased Archive,
	a leading manufacturer of QIC drives, and then stopped production of
	QIC drives.  4mm drives are small and quiet but do not have the
	reputation for reliability that is enjoyed by 8mm drives.  The
	cartridges are less expensive and smaller (3 x 2 x 0.5 inches, 76 x 51
	x 12 mm) than 8mm cartridges.  4mm, like 8mm, has comparatively short
	head life for the same reason, both use helical scan.</para>

      <para>Data thruput on these drives starts ~150kB/s, peaking at ~500kB/s.
	Data capacity starts at 1.3 GB and ends at 2.0 GB.  Hardware
	compression, available with most of these drives, approximately
	doubles the capacity.  Multi-drive tape library units can have 6
	drives in a single cabinet with automatic tape changing.  Library
	capacities reach 240 GB.</para>

      <para>The DDS-3 standard now supports tape capacities up to 12GB (or
	24GB compressed).</para>

      <para>4mm drives, like 8mm drives, use helical-scan.  All the benefits
	and drawbacks of helical-scan apply to both 4mm and 8mm drives.</para>

      <para>Tapes should be retired from use after 2,000 passes or 100 full
	backups.</para>
    </sect2>
    
    <sect2 id="backups-tapebackups-8mm">
      <title>8mm (Exabyte)</title>
      
      <para>8mm tapes are the most common SCSI tape drives; they are the best
	choice of exchanging tapes.  Nearly every site has an exabyte 2 GB 8mm
	tape drive.  8mm drives are reliable, convenient and quiet. Cartridges
	are inexpensive and small (4.8 x 3.3 x 0.6 inches; 122 x 84 x 15 mm).
	One downside of 8mm tape is relatively short head and tape life due to
	the high rate of relative motion of the tape across the heads.</para>

      <para>Data thruput ranges from ~250kB/s to ~500kB/s.  Data sizes start
	at 300 MB and go up to 7 GB.  Hardware compression, available with
	most of these drives, approximately doubles the capacity.  These
	drives are available as single units or multi-drive tape libraries
	with 6 drives and 120 tapes in a single cabinet.  Tapes are changed
	automatically by the unit.  Library capacities reach 840+ GB.</para>

      <para>The Exabyte <quote>Mammoth</quote> model supports 12GB on one tape
	(24MB with compression) and costs approximately twice as much as
	conventional tape drives.</para>

      <para>Data is recorded onto the tape using helical-scan, the heads are
	positioned at an angle to the media (approximately 6 degrees).  The
	tape wraps around 270 degrees of the spool that holds the heads.  The
	spool spins while the tape slides over the spool.  The result is a
	high density of data and closely packed tracks that angle across the
	tape from one edge to the other.</para>
    </sect2>
    
    <sect2 id="backups-tapebackups-qic">
      <title>QIC</title>
      
      <para>QIC-150 tapes and drives are, perhaps, the most common tape drive
	and media around.  QIC tape drives are the least expensive "serious"
	backup drives.  The downside is the cost of media.  QIC tapes are
	expensive compared to 8mm or 4mm tapes, up to 5 times the price per GB
	data storage.  But, if your needs can be satisfied with a half-dozen
	tapes, QIC may be the correct choice.  QIC is the
	<emphasis>most</emphasis> common tape drive.  Every site has a QIC
	drive of some density or another.  Therein lies the rub, QIC has a
	large number of densities on physically similar (sometimes identical)
	tapes.  QIC drives are not quiet.  These drives audibly seek before
	they begin to record data and are clearly audible whenever reading,
	writing or seeking.  QIC tapes measure (6 x 4 x 0.7 inches; 15.2 x
	10.2 x 1.7 mm).  <link
	  linkend="backups-tapebackups-mini">Mini-cartridges</link>, which
	also use 1/4" wide tape are discussed separately.  Tape libraries and
	changers are not available.</para>

      <para>Data thruput ranges from ~150kB/s to ~500kB/s.  Data capacity
	ranges from 40 MB to 15 GB.  Hardware compression is available on many
	of the newer QIC drives.  QIC drives are less frequently installed;
	they are being supplanted by DAT drives.</para>

      <para>Data is recorded onto the tape in tracks.  The tracks run along
	the long axis of the tape media from one end to the other.  The number
	of tracks, and therefore the width of a track, varies with the tape's
	capacity.  Most if not all newer drives provide backward-compatibility
	at least for reading (but often also for writing).  QIC has a good
	reputation regarding the safety of the data (the mechanics are simpler
	and more robust than for helical scan drives).</para>

      <para>Tapes should be retired from use after 5,000 backups.</para>
    </sect2>

<![ %not.published; [

    <sect2 id="backups-tapebackups-mini">
      <title>* Mini-Cartridge</title>
      
      <para></para>
    </sect2>
    
]]>
    
    <sect2 id="backups-tapebackups-dlt">
      <title>DLT</title>

      <para>DLT has the fastest data transfer rate of all the drive types
	listed here.  The 1/2" (12.5mm) tape is contained in a single spool
	cartridge (4 x 4 x 1 inches; 100 x 100 x 25 mm).  The cartridge has a
	swinging gate along one entire side of the cartridge.  The drive
	mechanism opens this gate to extract the tape leader.  The tape leader
	has an oval hole in it which the drive uses to "hook" the tape.  The
	take-up spool is located inside the tape drive.  All the other tape
	cartridges listed here (9 track tapes are the only exception) have
	both the supply and take-up spools located inside the tape cartridge
	itself.</para>

      <para>Data thruput is approximately 1.5MB/s, three times the thruput of
	4mm, 8mm, or QIC tape drives.  Data capacities range from 10GB to 20GB
	for a single drive.  Drives are available in both multi-tape changers
	and multi-tape, multi-drive tape libraries containing from 5 to 900
	tapes over 1 to 20 drives, providing from 50GB to 9TB of
	storage.</para>

      <para>With compression, DLT Type IV format supports up to 70GB
	capacity.</para>

      <para>Data is recorded onto the tape in tracks parallel to the direction
	of travel (just like QIC tapes).  Two tracks are written at once.
	Read/write head lifetimes are relatively long; once the tape stops
	moving, there is no relative motion between the heads and the
	tape.</para>
    </sect2>

    <sect2>
      <title id="backups-tapebackups-ait">AIT</title>

      <para>AIT is a new format from Sony, and can hold up to 50GB (with
	compression) per tape.  The tapes contain memory chips which retain an 
	index of the tape's contents.  This index can be rapidly read by the
	tape drive to determine the position of files on the tape, instead of
	the several minutes that would be required for other tapes.  Software
	such as SAMS:Alexandria can operate forty or more AIT tape libraries,
	communicating directly with the tape's memory chip to display the
	contents on screen, determine what files where backed up to which
	tape, locate the correct tape, load it, and restore the data from the
	tape.</para>

      <para>Libraries like this cost in the region of $20,000, pricing them a
	little out of the hobbyist market.</para>
    </sect2>
    
    <sect2>
      <title>Using a New Tape for the First Time</title>
      
      <para>The first time that you try to read or write a new, completely
	blank tape, the operation will fail.  The console messages should be
	similar to:</para>
      
      <screen>sa0(ncr1:4:0): NOT READY asc:4,1
sa0(ncr1:4:0):  Logical unit is in process of becoming ready</screen>
      
      <para>The tape does not contain an Identifier Block (block number 0).
	All QIC tape drives since the adoption of QIC-525 standard write an
	Identifier Block to the tape.  There are two solutions:</para>
      
      <para><command>mt fsf 1</command> causes the tape drive to write an
	Identifier Block to the tape.</para>
      
      <para>Use the front panel button to eject the tape.</para>
      
      <para>Re-insert the tape and &man.dump.8; data to the tape.</para>
      
      <para>&man.dump.8; will report <literal>DUMP: End of tape
	  detected</literal> and the console will show: <literal>HARDWARE
	  FAILURE info:280 asc:80,96</literal></para>
      
      <para>rewind the tape using: <command>mt rewind</command></para>
      
      <para>Subsequent tape operations are successful.</para>
    </sect2>
  </sect1>
  
  <sect1 id="backup-programs">
    <title>Backup Programs</title>
    
    <para>The three major programs are
	&man.dump.8;,
	&man.tar.1;,
      and
	&man.cpio.1;.</para>
    
    <sect2>
      <title>Dump and Restore</title>
      
      <para>&man.dump.8; and &man.restore.8; are the traditional Unix backup
	programs.  They operate on the drive as a collection of disk blocks,
	below the abstractions of files, links and directories that are
	created by the filesystems. &man.dump.8; backs up devices, entire
	filesystems, not parts of a filesystem and not directory trees that
	span more than one filesystem, using either soft links &man.ln.1; or
	mounting one filesystem onto another. &man.dump.8; does not write
	files and directories to tape, but rather writes the data blocks that
	are the building blocks of files and directories.  &man.dump.8; has
	quirks that remain from its early days in Version 6 of ATT Unix (circa
	1975).  The default parameters are suitable for 9-track tapes (6250
	bpi), not the high-density media available today (up to 62,182 ftpi).
	These defaults must be overridden on the command line to utilize the
	capacity of current tape drives.</para>
      
      <para>&man.rdump.8; and &man.rrestore.8; backup data across the network
	to a tape drive attached to another computer.  Both programs rely upon
	  &man.rcmd.3; and &man.ruserok.3; to access the remote tape drive.
	Therefore, the user performing the backup must have
	<literal>rhosts</literal> access to the remote computer.  The
	arguments to &man.rdump.8; and &man.rrestore.8; must suitable to use
	on the remote computer.  (e.g. When <command>rdump</command>'ing from
	a FreeBSD computer to an Exabyte tape drive connected to a Sun called
	<hostid>komodo</hostid>, use: <command>/sbin/rdump 0dsbfu 54000 13000
	  126 komodo:/dev/nrsa8 /dev/rda0a 2>&amp;1</command>) Beware: there
	are security implications to allowing <literal>rhosts</literal>
	commands.  Evaluate your situation carefully.</para>
    </sect2>

    <sect2>
      <title>Tar</title>
      
      <para>&man.tar.1; also dates back to Version 6 of ATT Unix (circa 1975).
	  &man.tar.1; operates in cooperation with the filesystem; &man.tar.1;
	writes files and directories to tape. &man.tar.1; does not support the
	full range of options that are available from &man.cpio.1;, but
	  &man.tar.1; does not require the unusual command pipeline that
	  &man.cpio.1; uses.</para>
      
      <para>Most versions of &man.tar.1; do not support backups across the
	network.  The GNU version of &man.tar.1;, which FreeBSD utilizes,
	supports remote devices using the same syntax as &man.rdump.8;.  To
	  &man.tar.1; to an Exabyte tape drive connected to a Sun called
	<hostid>komodo</hostid>, use: <command>/usr/bin/tar cf
	  komodo:/dev/nrsa8 . 2>&amp;1</command>.  For versions without remote
	device support, you can use a pipeline and &man.rsh.1; to send the
	data to a remote tape drive.</para>

      <screen>&prompt.root; <userinput>tar cf - . | rsh <replaceable>hostname</replaceable> dd of=<replaceable>tape-device</replaceable> obs=20b</userinput></screen>

      <para>If you're worried about the security of backing over a network
	you should use the &man.ssh.1; command instead of &man.rsh.1;.</para>
    </sect2>
    
    <sect2>
      <title>Cpio</title>
      
      <para>&man.cpio.1; is the original Unix file interchange tape program
	for magnetic media.  &man.cpio.1; has options (among many others) to
	perform byte-swapping, write a number of different archives format,
	and pipe the data to other programs.  This last feature makes
	  &man.cpio.1; and excellent choice for installation media.
	  &man.cpio.1; does not know how to walk the directory tree and a list
	of files must be provided through <filename>stdin</filename>.</para>
      
      <para>&man.cpio.1; does not support backups across the network.  You can
	use a pipeline and &man.rsh.1; to send the data to a remote tape
	drive.  (XXX add an example command)</para>
    </sect2>
    
    <sect2>
      <title>Pax</title>
      
      <para>&man.pax.1; is IEEE/POSIX's answer to &man.tar.1; and
	  &man.cpio.1;.  Over the years the various versions of &man.tar.1;
	and &man.cpio.1; have gotten slightly incompatible.  So rather than
	fight it out to fully standardize them, POSIX created a new archive
	utility. &man.pax.1; attempts to read and write many of the various
	  &man.cpio.1; and &man.tar.1; formats, plus new formats of its own.
	Its command set more resembles &man.cpio.1; than &man.tar.1;.</para>
      </sect2>

    <sect2 id="backups-programs-amanda">
      <title>Amanda</title>
      
      <para><ulink url="../ports/misc.html#amanda-2.4.0">Amanda</ulink>
	(Advanced Maryland Network Disk Archiver) is a client/server backup
	system, rather than a single program.  An Amanda server will backup to
	a single tape drive any number of computers that have Amanda clients
	and network communications with the Amanda server.  A common problem
	at locations with a number of large disks is the length of time
	required to backup to data directly to tape exceeds the amount of time
	available for the task.  Amanda solves this problem.  Amanda can use a
	"holding disk" to backup several filesystems at the same time.  Amanda
	creates "archive sets": a group of tapes used over a period of time to
	create full backups of all the filesystems listed in Amanda's
	configuration file.  The "archive set" also contains nightly
	incremental (or differential) backups of all the filesystems.
	Restoring a damaged filesystem requires the most recent full backup
	and the incremental backups.</para>

      <para>The configuration file provides fine control backups and the
	network traffic that Amanda generates.  Amanda will use any of the
	above backup programs to write the data to tape.  Amanda is available
	as either a port or a package, it is not installed by default.</para>
      </sect2>

    <sect2>
      <title>Do Nothing</title>
      
      <para><quote>Do nothing</quote> is not a computer program, but it is the
	most widely used backup strategy.  There are no initial costs.  There
	is no backup schedule to follow.  Just say no.  If something happens
	to your data, grin and bear it!</para>

      <para>If your time and your data is worth little to nothing, then
	<quote>Do nothing</quote> is the most suitable backup program for your
	computer.  But beware, Unix is a useful tool, you may find that within
	six months you have a collection of files that are valuable to
	you.</para>

      <para><quote>Do nothing</quote> is the correct backup method for
	<filename>/usr/obj</filename> and other directory trees that can be
	exactly recreated by your computer.  An example is the files that
	comprise these handbook pages-they have been generated from
	<acronym>SGML</acronym> input files.  Creating backups of these
	<acronym>HTML</acronym> files is not necessary.  The
	<acronym>SGML</acronym> source files are backed up regularly.</para>
    </sect2>
    
    <sect2>
      <title>Which Backup Program is Best?</title>
      
      <para>&man.dump.8; <emphasis>Period.</emphasis> Elizabeth D. Zwicky
	torture tested all the backup programs discussed here.  The clear
	choice for preserving all your data and all the peculiarities of Unix
	filesystems is &man.dump.8;.  Elizabeth created filesystems containing
	a large variety of unusual conditions (and some not so unusual ones)
	and tested each program by do a backup and restore of that
	filesystems.  The peculiarities included: files with holes, files with
	holes and a block of nulls, files with funny characters in their
	names, unreadable and unwritable files, devices, files that change
	size during the backup, files that are created/deleted during the
	backup and more.  She presented the results at LISA V in Oct. 1991.
	See <ulink
	  url="http://reality.sgi.com/zwicky_neu/testdump.doc.html">torture-testing
	  Backup and Archive Programs</ulink>.</para>
    </sect2>
    
    <sect2>
      <title>Emergency Restore Procedure</title>
      
      <sect3>
	<title>Before the Disaster</title>

	<para>There are only four steps that you need to perform in
	  preparation for any disaster that may occur.</para>
	    
	<para>First, print the disklabel from each of your disks
	  (<command>e.g. disklabel da0 | lpr</command>), your filesystem table
	  (<filename>/etc/fstab</filename>) and all boot messages,
	  two copies of
	  each.</para>

	<para>Second, determine that the boot and fixit floppies
	  (<filename>boot.flp</filename> and <filename>fixit.flp</filename>)
	  have all your devices.  The easiest way to check is to reboot your
	  machine with the boot floppy in the floppy drive and check the boot
	  messages.  If all your devices are listed and functional, skip on to
	  step three.</para>

	<para>Otherwise, you have to create two custom bootable floppies which
	  has a kernel that can mount your all of your disks and access your
	  tape drive.  These floppies must contain:
	  &man.fdisk.8;, &man.disklabel.8;, &man.newfs.8;, &man.mount.8;, and
	  whichever backup program you use.  These programs must be statically
	  linked.  If you use &man.dump.8;, the floppy must contain
	    &man.restore.8;.</para>

	<para>Third, create backup tapes regularly.  Any changes that you make
	  after your last backup may be irretrievably lost.  Write-protect the
	  backup tapes.</para>

	<para>Fourth, test the floppies (either <filename>boot.flp</filename>
	  and <filename>fixit.flp</filename> or the two custom bootable
	  floppies you made in step two.) and backup tapes.  Make notes of the
	  procedure.  Store these notes with the bootable floppy, the
	  printouts and the backup tapes.  You will be so distraught when
	  restoring that the notes may prevent you from destroying your backup
	  tapes (How? In place of <command>tar xvf /dev/rsa0</command>, you
	  might accidently type <command>tar cvf /dev/rsa0</command> and
	  over-write your backup tape).</para>

	<para>For an added measure of security, make bootable floppies and two
	  backup tapes each time.  Store one of each at a remote location.  A
	  remote location is NOT the basement of the same office building.  A
	  number of firms in the World Trade Center learned this lesson the
	  hard way.  A remote location should be physically separated from
	  your computers and disk drives by a significant distance.</para>

	<para>An example script for creating a bootable floppy:</para>
	  
	<programlisting>
<![ CDATA [#!/bin/sh
#
# create a restore floppy
#
# format the floppy
#
PATH=/bin:/sbin:/usr/sbin:/usr/bin

fdformat -q fd0
if [ $? -ne 0 ]
then
	 echo "Bad floppy, please use a new one"
	 exit 1
fi

# place boot blocks on the floppy
#
disklabel -w -B /dev/rfd0c fd1440

#
# newfs the one and only partition
#
newfs -t 2 -u 18 -l 1 -c 40 -i 5120 -m 5 -o space /dev/rfd0a

#
# mount the new floppy
#
mount /dev/fd0a /mnt

#
# create required directories 
#
mkdir /mnt/dev
mkdir /mnt/bin
mkdir /mnt/sbin
mkdir /mnt/etc
mkdir /mnt/root
mkdir /mnt/mnt			# for the root partition
mkdir /mnt/tmp
mkdir /mnt/var

#
# populate the directories
#
if [ ! -x /sys/compile/MINI/kernel ] 
then
	 cat << EOM
The MINI kernel does not exist, please create one.
Here is an example config file:
#
# MINI -- A kernel to get FreeBSD on onto a disk.
#
machine		"i386"
cpu		"I486_CPU"
ident		MINI
maxusers	5

options		INET			# needed for _tcp _icmpstat _ipstat
					 #            _udpstat _tcpstat _udb
options		FFS			#Berkeley Fast File System
options		FAT_CURSOR		#block cursor in syscons or pccons
options		SCSI_DELAY=15		#Be pessimistic about Joe SCSI device
options		NCONS=2		#1 virtual consoles
options		USERCONFIG		#Allow user configuration with -c XXX

config		kernel	root on da0 swap on da0 and da1 dumps on da0

controller	isa0
controller	pci0

controller	fdc0	at isa? port "IO_FD1" bio irq 6 drq 2 vector fdintr
disk		fd0	at fdc0 drive 0

controller	ncr0

controller	scbus0

device		sc0	at isa? port "IO_KBD" tty irq 1 vector scintr
device		npx0	at isa? port "IO_NPX" irq 13 vector npxintr

device		da0
device		da1
device		da2

device		sa0

pseudo-device	loop		# required by INET
pseudo-device	gzip		# Exec gzipped a.out's
EOM
	 exit 1
fi

cp -f /sys/compile/MINI/kernel /mnt

gzip -c -best /sbin/init > /mnt/sbin/init
gzip -c -best /sbin/fsck > /mnt/sbin/fsck
gzip -c -best /sbin/mount > /mnt/sbin/mount
gzip -c -best /sbin/halt > /mnt/sbin/halt
gzip -c -best /sbin/restore > /mnt/sbin/restore

gzip -c -best /bin/sh > /mnt/bin/sh
gzip -c -best /bin/sync > /mnt/bin/sync

cp /root/.profile /mnt/root

cp -f /dev/MAKEDEV /mnt/dev
chmod 755 /mnt/dev/MAKEDEV

chmod 500 /mnt/sbin/init
chmod 555 /mnt/sbin/fsck /mnt/sbin/mount /mnt/sbin/halt
chmod 555 /mnt/bin/sh /mnt/bin/sync
chmod 6555 /mnt/sbin/restore

#
# create the devices nodes 
#
cd /mnt/dev
./MAKEDEV std
./MAKEDEV da0
./MAKEDEV da1
./MAKEDEV da2
./MAKEDEV sa0
./MAKEDEV pty0
cd /

#
# create minimum filesystem table
#
cat > /mnt/etc/fstab <<EOM
/dev/fd0a	/	ufs	rw 1 1
EOM

#
# create minimum passwd file
#
cat > /mnt/etc/passwd <<EOM
root:*:0:0:Charlie &:/root:/bin/sh
EOM

cat > /mnt/etc/master.passwd <<EOM
root::0:0::0:0:Charlie &:/root:/bin/sh
EOM

chmod 600 /mnt/etc/master.passwd
chmod 644 /mnt/etc/passwd
/usr/sbin/pwd_mkdb -d/mnt/etc /mnt/etc/master.passwd

#
# umount the floppy and inform the user
#
/sbin/umount /mnt
echo "The floppy has been unmounted and is now ready."]]></programlisting>
      </sect3>
      
      <sect3>
	<title>After the Disaster</title>

	<para>The key question is: did your hardware survive?  You have been
	  doing regular backups so there is no need to worry about the
	  software.</para>

	<para>If the hardware has been damaged.  First, replace those parts
	  that have been damaged.</para>

	<para>If your hardware is okay, check your floppies.  If you are using
	  a custom boot floppy, boot single-user (type <literal>-s</literal>
	  at the <prompt>boot:</prompt> prompt).  Skip the following
	  paragraph.</para>
	  
	<para>If you are using the <filename>boot.flp</filename> and
	  <filename>fixit.flp</filename> floppies, keep reading.  Insert the
	  <filename>boot.flp</filename> floppy in the first floppy drive and
	  boot the computer.  The original install menu will be displayed on
	  the screen.  Select the <literal>Fixit--Repair mode with CDROM or
	    floppy.</literal> option.  Insert the
	  <filename>fixit.flp</filename> when prompted.
	  <command>restore</command> and the other programs that you need are
	  located in <filename>/mnt2/stand</filename>.</para>

	<para>Recover each filesystem separately.</para>

	<para>Try to &man.mount.8; (e.g. <command>mount /dev/da0a
	    /mnt</command>)  the root partition of your first disk.  If the
	  disklabel was damaged, use &man.disklabel.8; to re-partition and
	  label the disk to match the label that your printed and saved.  Use
	    &man.newfs.8; to re-create the filesystems.  Re-mount the root
	  partition of the floppy read-write (<command>mount -u -o rw
	    /mnt</command>).  Use your backup program and backup tapes to
	  recover the data for this filesystem (e.g. <command>restore vrf
	    /dev/sa0</command>).  Unmount the filesystem (e.g. <command>umount
	    /mnt</command>) Repeat for each filesystem that was
	  damaged.</para>

	<para>Once your system is running, backup your data onto new tapes.
	  Whatever caused the crash or data loss may strike again.  An another
	  hour spent now, may save you from further distress later.</para>
      </sect3>

<![ %not.published; [

      <sect3>
	<title>* I did not prepare for the Disaster, What Now?</title>

	<para></para>
      </sect3>
]]>

    </sect2>
  </sect1>

  <sect1 id="backups-floppybackups">
    <title>What about Backups to Floppies?</title>

    <sect2 id="floppies-using">
      <title>Can I use floppies for backing up my data?</title>
      
      <para>Floppy disks are not really a suitable media for
        making backups as:</para>

      <itemizedlist>
	<listitem>
	  <para>The media is unreliable, especially over long periods of
	    time</para>
	</listitem>

	<listitem>
	  <para>Backing up and restoring is very slow</para>
	</listitem>

	<listitem>
	  <para>They have a very limited capacity (the days of backing up
	    an entire hard disk onto a dozen or so floppies has long since
	    passed).</para>
	</listitem>
      </itemizedlist>

      <para>However, if you have no other method of backing up your data then
	floppy disks are better than no backup at all.</para>

      <para>If you do have to use floppy disks then ensure that you use good
	quality ones. Floppies that have been lying around the office for a
	couple of years are a bad choice. Ideally use new ones from a
	reputable manufacturer.</para>
    </sect2>
    
    <sect2 id="floppies-creating">
      <title>So how do I backup my data to floppies?</title>

      <para>The best way to backup to floppy disk is to use
        &man.tar.1; with the <option>-M</option> (multi volume) option, which
	allows backups to span multiple floppies.</para>

      <para>To backup all the files in the current directory and sub-directory
	use this (as root):</para>

      <screen>&prompt.root; <userinput>tar Mcvf /dev/rfd0 *</userinput></screen>

      <para>When the first floppy is full &man.tar.1; will prompt you to
	insert the next volume (because &man.tar.1; is media independent it
	refers to volumes. In this context it means floppy disk)</para>

      <screen>Prepare volume #2 for /dev/rfd0 and hit return:</screen>

      <para>This is repeated (with the volume number incrementing) until all
	the specified files have been archived.</para>
    </sect2>

    <sect2 id="floppies-compress">
      <title>Can I compress my backups?</title>

      <para>Unfortunately, &man.tar.1; will not allow the
	<option>-z</option> option to be used for multi-volume archives.
	You could, of course, &man.gzip.1; all the files, &man.tar.1; them to
	the floppies, then &man.gunzip.1; the files again!</para>
    </sect2>

    <sect2 id="floppies-restoring">
      <title>How do I restore my backups?</title>
      
      <para>To restore the entire archive use:</para>

      <screen>&prompt.root; <userinput>tar Mxvf /dev/rfd0</userinput></screen>

      <para>To restore only specific files you can either start with the first
	floppy and use:</para>

      <screen>&prompt.root; <userinput>tar Mxvf /dev/rfd0 <replaceable>filename</replaceable></userinput></screen>

      <para>&man.tar.1; will prompt you to insert subsequent floppies until it
	finds the required file.</para>

      <para>Alternatively, if you know which floppy the file is on then you
	can simply insert that floppy and use the same command as above. Note
	that if the first file on the floppy is a continuation from the
	previous one then &man.tar.1; will warn you that it cannot restore it,
	even if you have not asked it to!</para>
    </sect2>
  </sect1>
</chapter>

<!-- 
     Local Variables:
     mode: sgml
     sgml-declaration: "../chapter.decl"
     sgml-indent-data: t
     sgml-omittag: nil
     sgml-always-quote-attributes: t
     sgml-parent-document: ("../book.sgml" "part" "chapter")
     End:
-->