Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Newer
Older
100644 190 lines (128 sloc) 6.273 kB
5e7e298 @whiteinge Final presentation.
authored
1 ===========================
2 Ogden Area Linux User Group
3 ===========================
4 Backups
5 -------
6
7 :Presenter: Seth House
8 :Date: 2009-06-30
9
10 .. include:: <s5defs.txt>
11 .. footer:: ``rsync -a -delete --link-dest=$BACKUPDIR/`/bin/ls -t $BACKUPDIR | head -1` $HOME/ $BACKUPDIR/`date '+%FT%R'```
12
13 Overview
14 ========
15
16 .. class:: handout
17
18 Backup strategies depend highly on the specific needs of the system and the
19 user. There is no one-size-fits-all solution. Many talks on backups try to
20 cover many situations; I’m only going to discuss one. This advice should
21 suffice for *most* personal desktop usage.
22
23 Again, it is up to you to think through your usage and how your computer is
24 set up in order to decide what works for you.
25
26 Jamie W. Zawinski, famous for work on Mozilla, Netscape Navigator, and
27 currently maintains the XScreenSaver project.
28
29 “The universe tends toward maximum irony. Don’t push it.”
30 — jwz
31
32
33 Where to Back Up Your Files
34 ===========================
35
36 .. class:: handout
37
38 The backup method I’ll be talking about is as follows. Buy two external
39 hard drives. I know, there’s plenty of other things I’d rather spend $120
40 on too — do it anyway. Copy your files to one of the drives every single
41 day. Don’t forget — for the love of Pete, automate it. Keep that drive in
42 your home. Copy your files to the other drive once a month. Take it to the
43 office if you trust your desk space, or have a Backup Buddy and leave it at
44 your friend’s house. (I’ll talk about encrypting your drives at some later
45 date.)
46
47 .. class:: incremental
48
49 * Good: Keep a copy of your files on a separate partition.
50 * Better: Keep a copy of your files on a separate disk.
51 * Best:
52
53 * Buy two external hard drives.
54 * Copy your files to one every day; keep it in your home.
55 * Copy your files to the other once a month; keep it somewhere not in
56 your home.
57
58
59 What Files to Back Up
60 =====================
61
62 .. class:: handout
63
64 Generally, there is no reason to back up your entire disk. Decide what you
65 want to backup by making notes as you build and configure your system. If
66 you make a change to your system that was time consuming or hard to figure
67 out, you’ll want to backup those changes. If your whole installation is
68 stock, you probably just want to backup your ``home`` folder.
69
70 .. class:: incremental
71
72 * ``/etc``
73 * ``/var``
74
75 * ``/var/spool/mail``
76 * ``/var/logs``
77
78 * ``/boot/config`` or ``/usr/src/linux/.config``
79 * ``$HOME``
80
81 How to Back Up Your Files
82 =========================
83
84 .. class:: handout
85
86 There are a plethora of backup utilities, some free some commercial. We’re
87 going to talk about plain ‘ol ``rsync`` because it ships with every Unix
88 everywhere.
89
90 `Amanda`, `Bacula`_, `rdiff-backup`_, `TimeVault`_
91
92 .. class:: incremental
93
94 ``rsync``
95
96 .. _Amanda: http://amanda.zmanda.com/
97 .. _Bacula: http://www.bacula.org/en/
98 .. _rsnapshot: http://rsnapshot.org/
99 .. _rdiff-backup: http://www.nongnu.org/rdiff-backup/
100 .. _TimeVault: http://wiki.ubuntu.com/TimeVault
101
102
103 Behold! The Power of ``rsync``
104 ==============================
105
106 .. class:: handout
107
108 We can replicate all the functionality of Apple’s Time Machine in a one line
109 command. (Hyperbole much?)
110
111 How does this work? Well, we create an initial full backup of all your
112 files. Then we run a cronjob every two hours and rsync compares your
113 current files with the most recent backup, making hard links to everything
114 that is the same, and making full copies of everything that is different.
115
116 Hard links have the following properties, given the file ``a`` with link
117 ``b``: the contents of the file are only stored once, so you don’t use
118 twice the space; if you change ``a``, you're changing ``b``, and
119 vice-versa; if you change the permissions or ownership of ``a``, you're
120 changing those of ``b`` as well, and vice-versa; if you overwrite ``a`` by
121 copying a third file on top of it, you will also overwrite ``b``.
122
123 This command works because rsync always unlinks before overwriting. This is
124 referred to as creating `rsync Snapshots`_.
125
126 We usually think of a file's name as being the file itself, but really
127 the name is a hard link. A given file can have more than one hard link
128 to itself--for example, a directory has at least two hard links: the
129 directory name and . (for when you're inside it). It also has one hard
130 link from each of its sub-directories (the .. file inside each one). If
131 you have the stat utility installed on your machine, you can find out
132 how many hard links a file has […].
133
134 — Mike Rubel, http://www.mikerubel.org/computers/rsync_snapshots/#Incremental
135
136 What happens if you rm one of the links? The answer is that rm is a bit of
137 a misnomer; it doesn't really remove a file, it just removes that one link
138 to it. A file's contents aren't truly removed until the number of links to
139 it reaches zero.
140
141 Want a GUI? http://code.google.com/p/flyback/
142
143 To restore the backed-up files, just copy them! Simple.
144
145 .. _rsync Snapshots: http://www.mikerubel.org/computers/rsync_snapshots/
146
147 .. class:: incremental
148
149 `Apple’s Time Machine`_ in one line:
150
151 .. _Apple’s Time Machine: http://en.wikipedia.org/wiki/Time_Machine_(Apple_software)#How_It_Works
152
153 .. class:: incremental tiny
154
155 ::
156
157 0 */2 * * * BACKUPDIR=/var/timemachine/$USER;\
158 rsync -a -delete\
159 --link-dest=$BACKUPDIR/`/bin/ls -t $BACKUPDIR | head -1`\
160 $HOME/ $BACKUPDIR/`date '+%FT%R'`
161
162 .. ** vim syntax highlighting fix
163
164 .. class:: incremental
165
166 You have to manually create the initial backup with:
167
168 .. class:: incremental tiny
169
170 ::
171
172 rsync -a $HOME/ /var/timemachine/$USER/`date '+%FT%R'`
173
174
175 Useful ``rsync`` Flags
176 ======================
177
178 ``-x``
179 Avoid crossing filesystem boundries.
180 ``--exclude``
181 Do not sync any files or directories that match a pattern or path.
182 ``--dry-run``
183 Don’t make any actual changes to the filesystem.
184 ``-P``
185 Resume partially transfered files and show a progress meter.
186
187
188
189 .. vim:filetype=rst
Something went wrong with that request. Please try again.