2 $DragonFly: doc/en/books/usersguide/backups/chapter.sgml,v 1.2 2004/06/01 20:01:21 justin Exp $
8 <firstname>Justin</firstname>
9 <surname>Sherrill</surname>
10 <contrib>Contributed by </contrib>
11 </author> <!-- justin@dragonflybsd.org 29 May 2004 -->
14 <title>Backups</title>
16 <sect1 id="backups-synopsis">
17 <title>Backups Overview</title>
18 <para>If you are looking to save a relatively small number of files,
21 <refentrytitle>tar</refentrytitle>
22 <manvolnum>1</manvolnum>
23 </citerefentry> to concatenate multiple files into a single archive.
24 Optionally, then use a utility like
26 <refentrytitle>gzip</refentrytitle>
27 <manvolnum>1</manvolnum>
28 </citerefentry> to save on disk space or bandwidth used.
29 Save the resulting file somewhere other than on the disk that contains the
30 original files.</para>
33 <refentrytitle>cpdup</refentrytitle>
34 <manvolnum>1</manvolnum>
35 </citerefentry> can be used to backup/mirror an entire directory
36 structure to a different disk.</para>
38 <para>Special files, whole filesystems, and incremental
39 backups all require more specialized tools. For this, the tools
41 <refentrytitle>dump</refentrytitle>
42 <manvolnum>8</manvolnum>
45 <refentrytitle>restore</refentrytitle>
46 <manvolnum>8</manvolnum>
48 will handle almost any eventuality. <command>dump()</command> will copy a
49 complete filesystem to the location specified; <command>restore()</command>
50 will replace that filesystem into a clean partition. It is possible
51 to completely reformat a hard drive that has been backed up with
52 <command>dump()</command>, and then use <command>restore()</command> to
53 bring that drive back completely to its original state.</para>
55 <para><command>dump()</command> can dump a mounted disk to a single file:</para>
58 &prompt.root; <userinput>dump 0af <replaceable>filename</replaceable> <replaceable>mountpoint</replaceable></userinput>
61 <para><command>restore()</command> can then recreate that data from the dumpfile:</para>
64 &prompt.root; <userinput>restore rf <replaceable>filename</replaceable></userinput>
68 <para>When using the -r option, <command>restore()</command> rebuilds the filesystem
69 described by the dumpfile. Only restore files using -r in an empty directory or
70 clean mountpoint. Otherwise, any existing data could be overwritten.</para>
73 <para>The dumped data can be automatically placed in a compressed file, and restored
74 while decompressing.</para>
77 &prompt.root; <userinput>dump 0af - / | gzip > root.dump.gz</userinput>
78 &prompt.root; <userinput>gunzip root.dump.gz | restore rf -</userinput>
81 <para>It's also possible to selectively restore files from a dump:</para>
84 &prompt.root; <userinput>restore xf <replaceable>filename</replaceable> <replaceable>files_to_restore</replaceable></userinput>
89 <sect1 id="backups-media">
90 <title>Backup Media</title>
91 <para>The "classical" method of data storage has always been tape drives.
92 A number of SCSI and IDE tape drives are supported under DragonFly; no
93 compatibility list exists at this point, though devices supported on
94 FreeBSD-4 should work. Tape backup has several advantages: it is stable,
95 relatively cheap, and can hold a large quantity of data. However, tape
96 media is accessed in linear fashion, and so it can may take some time to
99 <para>Tape speed can be improved by using larger block sizes. The
100 'b' option controls block size while using <command>dump()</command> or
101 <command>restore</command>.</para>
104 &prompt.root; <userinput>dump 0abf 64 /dev/<replaceable>tapedevice</replaceable> /</userinput>
105 &prompt.root; <userinput>restore rbf 64 /dev/<replaceable>tapedevice</replaceable></userinput>
108 <para><command>dd</command> can be used to reshape data passing to and from a
112 &prompt.root; <userinput>tar czf - / | dd obs=64k of=/dev/<replaceable>tapedevice</replaceable></userinput>
113 &prompt.root; <userinput>dd ibs=64k | tar xvzpf -</userinput>
116 <para>More recently, recordable optical media have become a viable option for
117 backup media. The shelf life and price per megabyte of saved data is not
118 as great as tape (as of this writing), but the recording equipment is
119 relatively common for creating CDs, and becoming more so for DVDs.<!-- Check
120 the "Recording media" section (FIXME: insert link to desktop/recording media)
121 for more information on burning CDs and DVDs.--></para>
123 <para>A third media option is hard drives. While these are not as cheap as tape or
124 blank optical media, they offer the ability, when mounted, to instantly
125 access data, or to update existing records.</para>
127 <para>Whichever option is picked, the backup media, once filled, should be stored
128 in a location physically separated from the source data. Time invested in
129 backups is wasted if the backups can be lost in the same accident that
130 destroys the original data.</para>
133 <sect1 id="backups-automating">
134 <title>Automating backups</title>
135 <para>If you are performing relatively simple backups to a network location, it's
138 <refentrytitle>cron</refentrytitle>
139 <manvolnum>8</manvolnum>
140 </citerefentry> to schedule regular backup events. For more
141 complex situtations, there are ports available such as
142 <filename role="package">misc/amanda</filename> or
143 <filename role="package">sysutils/bacula</filename>.</para>