1 Backup Format Description
2 for Cumulus: Efficient Filesystem Backup to the Cloud
3 Version: "Cumulus Snapshot v0.11"
5 NOTE: This format specification is intended to be mostly stable, but is
6 still subject to change before the 1.0 release. The code may provide
7 additional useful documentation on the format.
9 NOTE2: The name of this project has changed from LBS to Cumulus. In
10 some areas the name "LBS" is still used.
12 This document simply describes the snapshot format. It is described
13 from the point of view of a decompressor which wishes to restore the
14 files from a snapshot. It does not specify the exact behavior required
15 of the backup program writing the snapshot. For details of the current
16 backup program, see implementation.txt.
18 This document does not explain the rationale behind the format; for
25 In several places in the Cumulus format, a cryptographic checksum may be
26 used to allow data integrity to be verified. At the moment, only the
27 SHA-1 checksum is supported, but it is expected that other algorithms
28 will be supported in the future.
30 When a checksum is called for, the checksum is always stored in a text
31 format. The general format used is
32 <algorithm>=<hexdigits>
34 <algorithm> identifies the checksum algorithm used, and allows new
35 algorithms to be added later. At the moment, the only permissible value
36 is "sha1", indicating a SHA-1 checksum.
38 <hexdigits> is a sequence of hexadecimal digits which encode the
39 checksum value. For sha1, <hexdigits> should be precisely 40 digits
42 A sample checksum string is
43 sha1=67049e7931ad7db37b5c794d6ad146c82e5f3187
46 SEGMENTS & OBJECTS: STORAGE AND NAMING
47 ======================================
49 A Cumulus snapshot consists, at its base, of a collection of /objects/:
50 binary blobs of data, much like a file. Higher layers interpret the
51 contents of objects in various ways, but the lowest layer is simply
52 concerned with storing and naming these objects.
54 An object is a sequence of bytes (octets) of arbitrary length. An
55 object may contain as few as zero bytes (though such objects are not
56 very useful). Object sizes are potentially unbounded, but it is
57 recommended that the maximum size of objects produced be on the order of
58 megabytes. Files of essentially unlimited size can be stored in a
59 Cumulus snapshot using objects of modest size, so this should not cause
60 any real restrictions.
62 For storage purposes, objects are grouped together into /segments/.
63 Segments use the TAR format; each object within a segment is stored as a
64 separate file. Segments are named using UUIDs (Universally Unique
65 Identifiers), which are 128-bit numbers. The textual form of a UUID is
66 a sequence of lowercase hexadecimal digits with hyphens inserted at
67 fixed points; an example UUID is
68 a704eeae-97f2-4f30-91a4-d4473956366b
69 This segment could be stored in the filesystem as a file
70 a704eeae-97f2-4f30-91a4-d4473956366b.tar
71 The UUID used to name a segment is assigned when the segment is created.
73 Filters can be layered on top of the segment storage to provide
74 compression, encryption, or other features. For example, the example
75 segment above might be stored as
76 a704eeae-97f2-4f30-91a4-d4473956366b.tar.bz2
78 a704eeae-97f2-4f30-91a4-d4473956366b.tar.gpg
79 if the file data had been filtered through bzip2 or gpg, respectively,
80 before storage. Filtering of segment data is outside the scope of this
81 format specification, however; it is assumed that if filtering is used,
82 when decompressing the unfiltered data can be recovered (yielding data
85 Objects within a segment are numbered sequentially. This sequence
86 number is then formatted as an 8-digit (zero-padded) hexadecimal
87 (lowercase) value. The fully qualified name of an object consists of
88 the segment name, followed by a slash ("/"), followed by the object
89 sequence number. So, for example
90 a704eeae-97f2-4f30-91a4-d4473956366b/000001ad
93 Within the segment TAR file, the filename used for each object is its
94 fully-qualified name. Thus, when extracted using the standard tar
95 utility, a segment will produce a directory with the same name as the
96 segment itself, and that directory will contain a set of
97 sequentially-numbered files each storing the contents of a single
100 NOTE: When naming an object, the segment portion consists of the UUID
101 only. Any extensions appended to the segment when storing it as a file
102 in the filesystem (for example, .tar.bz2) are _not_ part of the name of
105 There are two additional components which may appear in an object name;
108 First, a checksum may be added to the object name to express an
109 integrity constraint: the referred-to data must match the checksum
110 given. A checksum is enclosed in parentheses and appended to the object
112 a704eeae-97f2-4f30-91a4-d4473956366b/000001ad(sha1=67049e7931ad7db37b5c794d6ad146c82e5f3187)
114 Secondly, an object may be /sliced/: a subset of the bytes actually
115 stored in the object may be selected to be returned. The slice syntax
118 where <start> is the first byte to return (as a decimal offset) and
119 <length> specifies the number of bytes to return (again in decimal). It
120 is invalid to select using the slice syntax a range of bytes that does
121 not fall within the original object. The slice specification should be
122 appended to an object name, for example:
123 a704eeae-97f2-4f30-91a4-d4473956366b/000001ad[264+1000]
124 selects only bytes 264..1263 from the original object. As an
125 abbreviation, the slice syntax
129 In place of a traditional slice, the annotation
131 may be used. This is somewhat similar to specifying [<length>], but
132 additionally asserts that the referenced object is exactly <length>
133 bytes long--that is, this slice syntax does not change the bytes
134 returned at all, but can be used to provide information about the
135 underlying object store.
137 Both a checksum and a slice can be used. In this case, the checksum is
138 given first, followed by the slice. The checksum is computed over the
139 original object contents, before slicing.
144 In addition to the standard syntax for objects described above, the
145 special name "zero" may be used instead of segment/sequence number.
146 This represents an object consisting entirely of zeroes. The zero
147 object must have a slice specification appended to indicate the size of
148 the object. For example
150 represents a block consisting of 1024 null bytes. A checksum should not
151 be given. The slice syntax should use the abbreviated length-only form.
154 FILE METADATA LISTING
155 =====================
157 A snapshot stores two distinct types of data into the object store
158 described above: data and metadata. Data for a file may be stored as a
159 single object, or the data may be broken apart into blocks which are
160 stored as separate objects. The file /metadata/ log (which may be
161 spread across multiple objects) specifies the names of the files in a
162 snapshot, metadata about them such as ownership and timestamps, and
163 gives the list of objects that contain the data for the file.
165 The metadata log consists of a set of stanzas, each of which are
166 formatted somewhat like RFC 822 (email) headers. An example is:
169 checksum: sha1=11bd6ec140e4ec3110a91e1dd0f02b63b701421f
170 data: 2f46bce9-4554-4a60-a4a2-543637bd3989/000001f7
178 The meanings of all the fields are described later. A blank line
179 separates stanzas with information about different files. In addition
180 to regular stanzas, the metadata listing may contain a line containing
181 an object reference prefixed with "@". Such a line indicates that the
182 contents of the referenced object should be fetched and parsed as a
183 metadata listing at this point, prior to continuing to parse the current
186 Several common encodings are used for various fields. The encoding used
187 for each field is specified in the field listing that follows.
188 encoded string: An arbitrary string (octet sequence), with bytes
189 optionally escaped by replacing a byte with %xx, where "xx" is a
190 hexadecimal representation of the byte replaced. For example,
191 space can be replaced with "%20". This is the same escaping
192 mechanism as used in URLs.
193 integer: An integer, which may be written in decimal, octal, or
194 hexadecimal. Strings starting with 0 are interpreted as octal,
195 and those starting with 0x are intepreted as hexadecimal.
197 Common fields (required in all stanzas):
198 path [encoded string]: Full path of the file archived. Note: In
199 previous versions (<= 0.2) the name of this field was "name".
200 user [special]: The user ID of the file, as an integer, optionally
201 followed by a space and the corresponding username, as an
202 escaped string enclosed in parentheses.
203 group [special]: The group ID which owns the file. Encoding is the
204 same as for the user field: an integer, with an optional name in
205 parentheses following.
206 mode [integer]: Unix mode bits for the file.
207 type [special]: A single character which indicates the type of file.
208 The type indicators are meant to be consistent with the
209 characters used with the -type option to find(1), and the file
210 type checks in test(1):
218 Note that previous versions used '-' to indicate a regular file.
219 This character should not be generated in any new snapshots, but
220 may be encountered in old snapshots (those with a format version
222 mtime [integer]: Modification time of the file.
224 Optional common fields:
225 links [integer]: Number of hard links to this file, generally only
226 reported if greater than 1.
227 inode [string]: String specifying the inode number of this file when
228 it was dumped. If "links" is greater than 1, then searching for
229 other files that have an identical "inode" value can be used to
230 determine which files should be hard-linked together when
231 restoring. The inode field should be treated as an opaque
232 string and compared for equality as such; an implementation may
233 choose whatever representation is convenient. The format
234 produced by the standard tool is <major>/<minor>/<inode> (where
235 <major> and <minor> specify the device of the containing
236 filesystem and <inode> is the inode number of the file).
237 ctime [integer]: Change time for the inode.
239 Special fields used for regular files:
240 checksum [string]: Checksum of the file contents.
241 size [integer]: Size of the file, in bytes.
242 data [reference list]: Whitespace-separated list of object
243 references. The referenced data, when concatenated in the
244 listed order, will reconstruct the file data. Any reference
245 that begins with a "@" character is an indirect reference--the
246 given object includes a whitespace-separated list of object
247 references which should be parsed in the same manner as the data
250 Special fields used for symbolic links:
251 target[encoded string]: The target of the symlink, as returned by
252 readlink(2). Note: In old version of the format (<= 0.2), this
253 field was called "contents" instead of "target".
255 Special fields used for block and character device files:
256 device[special]: The major and minor number of the device. Encoded
257 as "major/minor", where major is the major device number encoded
258 into an integer, and minor is the minor device number.
264 The snapshot descriptor is a small file which describes a single
265 snapshot. It is one of the few files which is not stored as an object
266 in the segment store. It is stored as a separate file, in plain text,
267 but in the same directory as segments are stored.
269 The name of snapshot descriptor file is
270 snapshot-<scheme>-<timestamp>.lbs
271 <scheme> is a descriptive text which can be used to distinguish several
272 logically distinct sets of snapshots (such as snapshots for two
273 different directory trees) that are being stored in the same location.
274 <timestamp> gives the date and time the snapshot was taken; the format
275 is %Y%m%dT%H%M%S (20070806T092239 means 2007-08-06 09:22:39). It is
276 recommended that the timestamp be given in UTC for consistent sorting
277 even if the offset from UTC to local time changes, however the
278 authoritative timestamp (including timezone) can be found in the Date
279 field. (In version v0.10 and earlier the timestamp is given in local
280 time; in current versions UTC is used.)
282 The contents of the descriptor are a set of RFC 822-style headers (much
283 like the metadata listing). The fields which are defined are:
284 Format: The string "Cumulus Snapshot v0.11" which identifies this
285 file as a Cumulus backup descriptor. The version number (v0.11)
286 might change if there are changes to the format. It is expected
287 that at some point, once the format is stabilized, the version
288 identifier will be changed to v1.0. (Earlier versions, format
289 v0.8 and earlier, used the string "LBS Snapshot" instead of
290 "Cumulus Snapshot", reflecting an earlier name for the project.
291 Consumers should be prepared for either name.)
292 Producer: A informative string which identifies the program that
294 Date: The date the snapshot was produced, in the local time zone.
295 This matches the timestamp encoded in the filename, but is
296 written out in full. A timezone (offset from UTC) is given.
297 For example: "2007-08-06 02:22:39 -0700".
298 Scheme: The <scheme> field from the descriptor filename.
299 Segments: A whitespace-seprated list of segment names. Any segment
300 which is referenced by this snapshot must be included in the
301 list, since this list can be used in garbage-collecting old
302 segments, determining which segments need to be downloaded to
303 completely reconstruct a snapshot, etc.
304 Root: A single object reference which points to the metadata
305 listing for the snapshot.
306 Checksums: A checksum file may be produced (with the same name as
307 the snapshot descriptor file, but with extension .sha1sums
308 instead of .lbs) containing SHA-1 checksums of all segments.
309 This field contains a checksum of that file.
310 Intent: Informational; records the value of the --intent flag when
311 the snapshot was created, and can be used when determining which
312 snapshots to later delete.