Corrected command snippets, text.
[dragonfly.git] / en / books / usersguide / backups / chapter.sgml
CommitLineData
267ea4d6 1<!--
2f6459be 2$DragonFly: doc/en/books/usersguide/backups/chapter.sgml,v 1.2 2004/06/01 20:01:21 justin Exp $
267ea4d6
JS
3-->
4<chapter id="backups">
5 <chapterinfo>
6 <authorgroup>
7 <author>
8 <firstname>Justin</firstname>
9 <surname>Sherrill</surname>
10 <contrib>Contributed by </contrib>
11 </author> <!-- justin@dragonflybsd.org 29 May 2004 -->
12 </authorgroup>
13 </chapterinfo>
14 <title>Backups</title>
15
16 <sect1 id="backups-synopsis">
17 <title>Backups Overview</title>
18 <para>If you are looking to save a relatively small number of files,
19 you can use
20 <citerefentry>
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
25 <citerefentry>
26 <refentrytitle>gzip</refentrytitle>
27 <manvolnum>1</manvolnum>
2f6459be 28 </citerefentry> to save on disk space or bandwidth used.
267ea4d6
JS
29 Save the resulting file somewhere other than on the disk that contains the
30 original files.</para>
31
2f6459be
JS
32 <para><citerefentry>
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>
37
38 <para>Special files, whole filesystems, and incremental
39 backups all require more specialized tools. For this, the tools
267ea4d6
JS
40 <citerefentry>
41 <refentrytitle>dump</refentrytitle>
42 <manvolnum>8</manvolnum>
43 </citerefentry> and
44 <citerefentry>
45 <refentrytitle>restore</refentrytitle>
46 <manvolnum>8</manvolnum>
47 </citerefentry>
2f6459be
JS
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>
54
55 <para><command>dump()</command> can dump a mounted disk to a single file:</para>
56
57 <screen>
58 &prompt.root; <userinput>dump 0af <replaceable>filename</replaceable> <replaceable>mountpoint</replaceable></userinput>
59 </screen>
60
61 <para><command>restore()</command> can then recreate that data from the dumpfile:</para>
62
63 <screen>
64 &prompt.root; <userinput>restore rf <replaceable>filename</replaceable></userinput>
65 </screen>
66
67 <note>
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>
71 </note>
72
73 <para>The dumped data can be automatically placed in a compressed file, and restored
74 while decompressing.</para>
75
76 <screen>
77 &prompt.root; <userinput>dump 0af - / | gzip > root.dump.gz</userinput>
78 &prompt.root; <userinput>gunzip root.dump.gz | restore rf -</userinput>
79 </screen>
80
81 <para>It's also possible to selectively restore files from a dump:</para>
82
83 <screen>
84 &prompt.root; <userinput>restore xf <replaceable>filename</replaceable> <replaceable>files_to_restore</replaceable></userinput>
85 </screen>
86
267ea4d6
JS
87 </sect1>
88
89 <sect1 id="backups-media">
2f6459be 90 <title>Backup Media</title>
267ea4d6
JS
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
2f6459be 96 media is accessed in linear fashion, and so it can may take some time to
267ea4d6 97 retrieve data.</para>
2f6459be
JS
98
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>
102
103 <screen>
104 &prompt.root; <userinput>dump 0abf 64 /dev/<replaceable>tapedevice</replaceable> /</userinput>
105 &prompt.root; <userinput>restore rbf 64 /dev/<replaceable>tapedevice</replaceable></userinput>
106 </screen>
107
108 <para><command>dd</command> can be used to reshape data passing to and from a
109 tape drive.</para>
110
111 <screen>
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>
114 </screen>
267ea4d6
JS
115
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>
122
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>
126
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>
131 </sect1>
132
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
136 easy enough to use
137 <citerefentry>
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>
144 </sect1>
145
146</chapter>