2 bup 0.01: It backs things up
3 ============================
5 bup is a program that backs things up. It's short for "backup." Can you
6 believe that nobody else has named an open source program "bup" after all
9 Despite its unassuming name, bup is pretty cool. To give you an idea of
10 just how cool it is, I wrote you this poem:
13 What rhymes with awesome?
15 But that's irrelevant.
17 Hmm. Did that help? Maybe prose is more useful after all.
20 Reasons bup is awesome
21 ----------------------
23 bup has a few advantages over other backup software:
25 - It uses a rolling checksum algorithm (similar to rsync) to split large
26 files into chunks. The most useful result of this is you can backup huge
27 virtual machine (VM) disk images, databases, and XML files incrementally,
28 even though they're typically all in one huge file, and not use tons of
29 disk space for multiple versions.
31 - It uses the packfile format from git (the open source version control
32 system), so you can access the stored data even if you don't like bup's
35 - Unlike git, it writes packfiles *directly* (instead of having a separate
36 garbage collection / repacking stage) so it's fast even with gratuitously
39 - Data is "automagically" shared between incremental backups without having
40 to know which backup is based on which other one - even if the backups
41 are made from two different computers that don't even know about each
42 other. You just tell bup to back stuff up, and it saves only the minimum
43 amount of data needed.
45 - Even when a backup is incremental, you don't have to worry about
46 restoring the full backup, then each of the incrementals in turn; an
47 incremental backup *acts* as if it's a full backup, it just takes less
50 - It's written in python (with some C parts to make it faster) so it's easy
51 for you to extend and maintain.
54 Reasons you might want to avoid bup
55 -----------------------------------
57 - This is version 0.01. What that means is this is the very first version.
58 Therefore it will most probably not work for you, but we don't know why.
60 - It requires python 2.5, a C compiler, and an installed git version >= 1.5.2.
62 - It only works on Linux (for now).
64 - It has almost no documentation. Not even a man page! This file is all
71 - check out the bup source code using git:
73 git clone git://github.com/apenwarr/bup
75 - install the python 2.5 development libraries. On Debian or Ubuntu, this
77 apt-get install python2.5-dev
79 - build the python module and symlinks:
87 (The tests should pass. If they don't pass for you, stop here and send
90 - Try making a local backup:
92 tar -cvf - /etc | bup split -n local-etc -vv
94 - Try restoring your backup:
96 bup join local-etc | tar -tf -
98 - Look at how much disk space your backup took:
102 - Make another backup (which should be mostly identical to the last one;
103 notice that you don't have to *specify* that this backup is incremental,
104 it just saves space automatically):
106 tar -cvf - /etc | bup split -n local-etc -vv
108 - Look how little extra space your second backup used on top of the first:
112 - Restore your old backup again (the ~1 is git notation for "one older than
115 bup join local-etc~1 | tar -tf -
117 - get a list of your previous backups:
119 GIT_DIR=~/.bup git log local-etc
121 - make a backup on a remote server (which must already have the 'bup' command
122 somewhere in the PATH, and be accessible via ssh; make sure to replace
123 SERVERNAME with the actual hostname of your server):
125 tar -cvf - /etc | bup split -r SERVERNAME: -n local-etc -vv
127 - try restoring the remote backup:
129 bup join -r SERVERNAME: local-etc | tar -tf -
131 That's all there is to it!
137 bup stores its data in a git-formatted repository. Unfortunately, git
138 itself doesn't actually behave very well for bup's use case (huge numbers of
139 files, files with huge sizes, retaining file permissions/ownership are
140 important), so we mostly don't use git's *code* except for a few helper
141 programs. For example, bup has its own git packfile writer written in
144 Basically, 'bup split' reads the data on stdin (or from files specified on
145 the command line), breaks it into chunks using a rolling checksum (similar to
146 rsync), and saves those chunks into a new git packfile. There is one git
149 When deciding whether to write a particular chunk into the new packfile, bup
150 first checks all the other packfiles that exist to see if they already have that
151 chunk. If they do, the chunk is skipped.
153 git packs come in two parts: the pack itself (*.pack) and the index (*.idx).
154 The index is pretty small, and contains a list of all the objects in the
155 pack. Thus, when generating a remote backup, we don't have to have a copy
156 of the packfiles from the remote server: the local end just downloads a copy
157 of the server's *index* files, and compares objects against those when
158 generating the new pack, which it sends directly to the server.
160 The "-n" option to 'bup split' and 'bup save' is the name of the backup you
161 want to create, but it's actually implemented as a git branch. So you can
162 do cute things like checkout a particular branch using git, and receive a
163 bunch of chunk files corresponding to the file you split.
165 If you use '-b' or '-t' or '-c' instead of '-n', bup split will output a
166 list of blobs, a tree containing that list of blobs, or a commit containing
167 that tree, respectively, to stdout. You can use this to construct your own
168 scripts that do something with those values.
170 'bup save' basically just runs 'bup split' a whole bunch of times, once per
171 file in a directory hierarchy, and assembles a git tree that contains all
172 the resulting objects. Among other things, that makes 'git diff' much more
173 useful (compared to splitting a tarball, which is essentially a big binary
174 blob). However, since bup splits large files into smaller chunks, the
175 resulting tree structure doesn't *exactly* correspond to what git itself
176 would have stored. Also, the tree format used by 'bup save' will probably
177 change in the future to support storing file ownership, more complex file
178 permissions, and so on.
181 Things that are stupid for now but which we'll fix later
182 --------------------------------------------------------
184 Help with any of these problems, or others, is very, very welcome. Let me
185 know if you'd like to help. Maybe we can start a mailing list.
187 - bup's incremental backup algorithm is braindead.
189 Bup reads the contents of every single file you want to back up, *then*
190 it checks if it has that content already, and if not, it backs up the
191 file. Now, it happens to do that very fast (using mmap'ed git packfile
192 indexes), all things considered, but it's not nearly as fast as simply
193 noticing that the file inode+ctime is the same as before and just
194 skipping it. There's nothing preventing us from adding this
195 optimization, though. (Perhaps we could use the git indexfile format for
198 - 'bup save' is incomplete and there's no 'bup restore' yet.
200 'bup save' is supposed to recursively go through a given directory and
201 store all the files efficiently, and then you could use 'bup restore' to
202 restore all or some of them. However, these features don't really work
205 Instead, for now the best way to use bup is to feed 'bup split' a big tar
206 file of your backup, then restore that tar file later with 'bup join'.
207 This is cute, but inefficient; for example, tar files don't have an
208 index, so to restore a single file would require linearly reading through
209 the entire tarball. (This is exactly like what always happens when you
210 make a backup using tar, but if we use git's native trees/blobs the way
211 they're meant to be used, it will be ridiculously faster.)
213 - bup could use inotify for *really* efficient incremental backups.
215 You could even have your system doing "continuous" backups: whenever a
216 file changes, we immediately send an image of it to the server. We could
217 give the continuous-backup process a really low CPU and I/O priority so
218 you wouldn't even know it was running.
220 - bup currently has no features that prune away *old* backups.
222 Because of the way the packfile system works, backups become "entangled"
223 in weird ways and it's not actually possible to delete one pack
224 (corresponding approximately to one backup) without risking screwing up
227 git itself has lots of ways of optimizing this sort of thing, but its
228 methods aren't really applicable here; bup packfiles are just too huge.
229 We'll have to do it in a totally different way. There are lots of
230 options. For now: make sure you've got lots of disk space :)
232 - bup doesn't ever validate existing backups/packs to ensure they're
235 This would be easy to implement (given that git uses hashes and CRCs all
236 over the place), but nobody has implemented it. For now, you could try
237 doing a test restore of your tarball; doing so should trigger git's error
238 handling if any of the objects are corrupted.
240 - bup has never been tested on anything but Linux.
242 There's nothing that makes it *inherently* non-portable, though, so
243 that's mostly a matter of someone putting in some effort.
249 bup is a work in progress and there are many ways it can still be improved.
250 If you'd like to contribute, please email me at <apenwarr@gmail.com>. If
251 enough people are interested, perhaps we should start a mailing list for