]> arthur.barton.de Git - bup.git/blob - Documentation/bup-restore.md
ab98c00b9e402d054f3096efa9c895cad7a796f2
[bup.git] / Documentation / bup-restore.md
1 % bup-restore(1) Bup %BUP_VERSION%
2 % Avery Pennarun <apenwarr@gmail.com>
3 % %BUP_DATE%
4
5 # NAME
6
7 bup-restore - extract files from a backup set
8
9 # SYNOPSIS
10
11 bup restore [\--outdir=*outdir*] [\--exclude-rx *pattern*] [-v] [-q]
12 \<paths...\>
13
14 # DESCRIPTION
15
16 `bup restore` extracts files from a backup set (created
17 with `bup-save`(1)) to the local filesystem.
18
19 The specified *paths* are of the form
20 /_branch_/_revision_/_some/where_.  The components of the
21 path are as follows:
22
23 branch
24 :   the name of the backup set to restore from; this
25     corresponds to the `--name` (`-n`) option to `bup save`.
26
27 revision
28 :   the revision of the backup set to restore.  The
29     revision *latest* is always the most recent
30     backup on the given branch.  You can discover other
31     revisions using `bup ls /branch`.
32     
33 some/where
34 :   the previously saved path (after any stripping/grafting) that you
35     want to restore.  For example, `etc/passwd`.
36     
37 If _some/where_ names a directory, `bup restore` will restore that
38 directory and then recursively restore its contents.
39
40 If _some/where_ names a directory and ends with a slash (ie.
41 path/to/dir/), `bup restore` will restore the children of that
42 directory directly to the current directory (or the `--outdir`).  If
43 _some/where_ does not end in a slash, the children will be restored to
44 a subdirectory of the current directory.
45
46 If _some/where_ names a directory and ends in '/.' (ie.
47 path/to/dir/.), `bup restore` will do exactly what it would have done
48 for path/to/dir, and then restore _dir_'s metadata to the current
49 directory (or the `--outdir`).  See the EXAMPLES section.
50
51 Whenever path metadata is available, `bup restore` will attempt to
52 restore it.  When restoring ownership, bup implements tar/rsync-like
53 semantics.  It will not try to restore the user unless running as
54 root, and it will fall back to the numeric uid or gid whenever the
55 metadata contains a user or group name that doesn't exist on the
56 current system.  The use of user and group names can be disabled via
57 `--numeric-ids` (which can be important when restoring a chroot, for
58 example), and as a special case, a uid or gid of 0 will never be
59 remapped by name.
60
61 Hardlinks will also be restored when possible, but at least currently,
62 no links will be made to targets outside the restore tree, and if the
63 restore tree spans a different arrangement of filesystems from the
64 save tree, some hardlink sets may not be completely restored.
65
66 Also note that changing hardlink sets on disk between index and save
67 may produce unexpected results.  With the current implementation, bup
68 will attempt to recreate any given hardlink set as it existed at index
69 time, even if all of the files in the set weren't still hardlinked
70 (but were otherwise identical) at save time.
71
72 Note that during the restoration process, access to data within the
73 restore tree may be more permissive than it was in the original
74 source.  Unless security is irrelevant, you must restore to a private
75 subdirectory, and then move the resulting tree to its final position.
76 See the EXAMPLES section for a demonstration.
77
78 # OPTIONS
79
80 -C, \--outdir=*outdir*
81 :   create and change to directory *outdir* before
82     extracting the files.
83
84 \--numeric-ids
85 :   restore numeric IDs (user, group, etc.) rather than names.
86
87 \--exclude-rx=*pattern*
88 :   exclude any path matching *pattern*, which must be a Python
89     regular expression (http://docs.python.org/library/re.html).  The
90     pattern will be compared against the full path rooted at the top
91     of the restore tree, without anchoring, so "x/y" will match
92     "ox/yard" or "box/yards".  To exclude the contents of /tmp, but
93     not the directory itself, use "^/tmp/.". (can be specified more
94     than once)
95
96     Note that the root of the restore tree (which matches '^/') is the
97     top of the archive tree being restored, and has nothing to do with
98     the filesystem destination.  Given "restore ... /foo/latest/etc/",
99     the pattern '^/passwd$' would match if a file named passwd had
100     been saved as '/foo/latest/etc/passwd'.
101
102     Examples:
103
104       * '/foo$' - exclude any file named foo
105       * '/foo/$' - exclude any directory named foo
106       * '/foo/.' - exclude the content of any directory named foo
107       * '^/tmp/.' - exclude root-level /tmp's content, but not /tmp itself
108
109 -v, \--verbose
110 :   increase log output.  Given once, prints every
111     directory as it is restored; given twice, prints every
112     file and directory.
113
114 -q, \--quiet
115 :   don't show the progress meter.  Normally, is stderr is
116     a tty, a progress display is printed that shows the
117     total number of files restored.
118
119 # EXAMPLE
120     
121 Create a simple test backup set:
122     
123     $ bup index -u /etc
124     $ bup save -n mybackup /etc/passwd /etc/profile
125     
126 Restore just one file:
127     
128     $ bup restore /mybackup/latest/etc/passwd
129     Restoring: 1, done.
130     
131     $ ls -l passwd
132     -rw-r--r-- 1 apenwarr apenwarr 1478 2010-09-08 03:06 passwd
133
134 Restore etc to test (no trailing slash):
135     
136     $ bup restore -C test /mybackup/latest/etc
137     Restoring: 3, done.
138     
139     $ find test
140     test
141     test/etc
142     test/etc/passwd
143     test/etc/profile
144     
145 Restore the contents of etc to test (trailing slash):
146
147     $ bup restore -C test /mybackup/latest/etc/
148     Restoring: 2, done.
149     
150     $ find test
151     test
152     test/passwd
153     test/profile
154
155 Restore the contents of etc and etc's metadata to test (trailing
156 "/."):
157
158     $ bup restore -C test /mybackup/latest/etc/.
159     Restoring: 2, done.
160     
161     # At this point test and etc's metadata will match.
162     $ find test
163     test
164     test/passwd
165     test/profile
166
167 Restore a tree without risk of unauthorized access:
168
169     # mkdir --mode 0700 restore-tmp
170
171     # bup restore -C restore-tmp /somebackup/latest/foo
172     Restoring: 42, done.
173
174     # mv restore-tmp/foo somewhere
175
176     # rmdir restore-tmp
177     
178
179 # SEE ALSO
180
181 `bup-save`(1), `bup-ftp`(1), `bup-fuse`(1), `bup-web`(1)
182
183 # BUP
184
185 Part of the `bup`(1) suite.