Skip to content

Commit 9d7c14c

Browse files
authored
Merge pull request #130 from poettering/feature-flags
Numerous changes, including support for quota project IDs and .gitignore-like files
2 parents 1d7eab0 + 8d94446 commit 9d7c14c

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

41 files changed

+2321
-302
lines changed

TODO

+11-7
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ SHORT-TERM:
44

55
TO MAKE IT USEFUL FOR BACKUPS:
66
* encryption: aes256 of rotating hash function + HMAC for identifying chunks + individually encrypted chunks
7-
* speed up repeated image generation: maintain persistent cache for directory trees that permits lookups by a path location as key, returning a chunk id and "newest covering mtime"
87

98
LATER:
109
* verify
@@ -26,22 +25,27 @@ LATER:
2625
* implicitly generate index + chunks when accessing base trees or archives through native protocol
2726
* rework caindex to read multiple chunks per read (use reallocbuffer like elsewhere)
2827
* permit 511 (or 4095?) redundant NUL bytes at the end of archive and index files, so that they could in theory stored on block devices
29-
* seed: cache GOODBYE name table data so that we can regenerate the right bits when needed
3028
* optionally import from/export to classic tar ball (and zip?)
3129
* optionally interpret aufs/union mount whiteout files?
32-
* fuse: expose acls and fcaps, selinux
30+
* fuse: expose acls and fcaps, selinux, quota projid
3331
* fuse: possibly translate user names on access
3432
* fuse: provide "mount.casync" compat symlink so that people can list casync mounts in /etc/fstab
3533
* encoder: change seeking to be more like decoder's seeking (i.e. delay returned events until the next ca_encoder_step() call)
3634
* rename offset accessor functions (drop the "archive")
3735
* send progress information via sd_notify(), so that people can wrap casync nicely in UIs
3836
* maybe turn "recursive" mode into a numeric value specifying how far to descend?
3937
* make "casync stat" work on a directory with a subpath
40-
* save/restore xfs/ext4 projid
4138
* tweak chunker: shift cut to last "marker".
4239
* define sane errors we can show user messages about
4340
* introduce a --best-effort mode when replaying, which means we'll ignore what we can't apply
44-
* add "--cache-auto" mode, that works like "--cache" but finds a suitable place for the cache automatically
45-
* use CaNameTable logic in seed, so that we can safely regenerate *any* chunk
4641
* when building the cache, also build a seed
47-
* make sure that "casync list" on a directory doesn't read any files
42+
* recognize NULL chunks and handle them specially
43+
* make archive digest generation optional
44+
* add "index" digest
45+
* maybe add a concept of "packfiles", to contain multiple chunks in one?
46+
* add libsmbclient backend (so that Lennart can backup to his synology NAS in the easiest way)
47+
* make sure "casync list /etc/fstab" does something useful
48+
* rework CaSeed logic to use CaCache as backend, and then add a new command "casync cache" or so, to explicitly generate a cache/seed
49+
* support blake2 as hashes
50+
* parallelize image generation: when storing chunks in the store do so in a thread
51+
* in "casync stat" output show which flags enable what

doc/casync.rst

+49
Original file line numberDiff line numberDiff line change
@@ -159,16 +159,20 @@ General options:
159159
--digest=<DIGEST> Pick digest algorithm (sha512-256 or sha256)
160160
--compression=<COMPRESSION> Pick compression algorithm (zstd, xz or gzip)
161161
--seed=<PATH> Additional file or directory to use as seed
162+
--cache=<PATH> Directory to use as encoder cache
163+
--cache-auto, -c Pick encoder cache directory automatically
162164
--rate-limit-bps=<LIMIT> Maximum bandwidth in bytes/s for remote communication
163165
--exclude-nodump=no Don't exclude files with chattr(1)'s +d **nodump** flag when creating archive
164166
--exclude-submounts=yes Exclude submounts when creating archive
167+
--exclude-file=no Don't respect .caexclude files in the file tree
165168
--reflink=no Don't create reflinks from seeds when extracting
166169
--hardlink=yes Create hardlinks from seeds when extracting
167170
--punch-holes=no Don't create sparse files when extracting
168171
--delete=no Don't delete existing files not listed in archive after extraction
169172
--undo-immutable=yes When removing existing files, undo chattr(1)'s +i 'immutable' flag when extracting
170173
--seed-output=no Don't implicitly add pre-existing output as seed when extracting
171174
--recursive=no List non-recursively
175+
--mkdir=no Don't automatically create mount directory if it is missing
172176
--uid-shift=<yes|SHIFT> Shift UIDs/GIDs
173177
--uid-range=<RANGE> Restrict UIDs/GIDs to range
174178

@@ -232,6 +236,7 @@ Individual archive features:
232236
--with=<acl> Store file access control lists
233237
--with=<selinux> Store SElinux file labels
234238
--with=<fcaps> Store file capabilities
239+
--with=<quota-projid> Store ext4/XFS quota project ID
235240

236241
(and similar: ``--without=16bit-uids``, ``--without=32bit-uids``, ...)
237242

@@ -241,3 +246,47 @@ Archive features
241246
The various ``--with=`` and ``--without=`` parameters control the precise set
242247
of metadata to store in the archive, or restore when extracting. These flags
243248
only apply if ``casync`` operates on the file system level.
249+
250+
Excluding Files and Directories from Archiving
251+
----------------------------------------------
252+
253+
When generating an archive or index from a file system directory tree, some
254+
files and directories are excluded by default and others may optionally be
255+
excluded:
256+
257+
1. Files and directories of virtual API file systems exposed by the kernel
258+
(i.e. procfs, sysfs, cgroupfs, devpts … — but not tmpfs/devtmpfs) are
259+
excluded unconditionally.
260+
261+
2. Depending on whether symlinks, device nodes, fifos and sockets are enabled
262+
for archiving with ``--with=`` and ``--without=``, file nodes of these types
263+
are excluded.
264+
265+
3. By default, files and directories with the ``+d`` chattr(1) flag set are
266+
excluded, however this behaviour may be turned off with
267+
``--exclude-nodump=no``.
268+
269+
4. Optionally, files and directories contained in submounts of the specified
270+
file system tree are excluded, if ``--exclude-submounts=yes`` is specified.
271+
272+
5. By default, any files and directories listed in ``.caexclude`` files in the
273+
file hierarchy are excluded, however interpretation of these files may be
274+
turned off with ``--exclude-file=no``. These files operate similar to
275+
``git``'s ``.gitignore`` concept: they are read as text file where each line
276+
is either empty/starts with ``#`` (in which case they have no effect, which
277+
may be used for commenting), or list a globbing path pattern of
278+
files/directories to ignore. If a line contains no ``/`` character the line
279+
applies to the directory the ``.caexclude`` file is located in as well as
280+
all child directories of it. If it contains at least one ``/`` character it
281+
is considered stricly relative to the directory the ``.caexclude`` file is
282+
located in. ``.caexclude`` files may appear in any directory of the file
283+
system tree that is archived, however they have no effect when placed in
284+
directories that are marked for exclusion via ``.caexclude`` files placed
285+
further up in the directory tree. When a line ends in a ``/`` character it
286+
applies to directories only, and not regular files or other file node
287+
types. If a line is prefixed with a ``!`` character matching files are
288+
excluded from the exclusion, i.e. the effect of other matching lines that
289+
are not prefixed like this is cancelled for matching files. ``!`` lines
290+
unconditionally take precedence over lines not marked like this. Moreover,
291+
lines prefixed with ``!`` also cancel the effect of patterns in
292+
``.caexclude`` files placed in directories further up the tree.

meson.build

+3
Original file line numberDiff line numberDiff line change
@@ -295,10 +295,13 @@ test_sources = '''
295295
test-cachunker-histogram
296296
test-cadigest
297297
test-caencoder
298+
test-calocation
298299
test-camakebst
300+
test-camatch
299301
test-caorigin
300302
test-casync
301303
test-cautil
304+
test-feature-flags
302305
test-util
303306
'''.split()
304307

src/cacache.c

+3-3
Original file line numberDiff line numberDiff line change
@@ -276,7 +276,7 @@ int ca_cache_get(CaCache *c, CaLocation *location, CaChunkID *ret_chunk_id, CaOr
276276
return -EINVAL;
277277

278278
/* The first item of the origin must match our lookup key. If it doesn't something's bad. */
279-
if (!ca_location_equal(location, ca_origin_get(origin, 0), false))
279+
if (!ca_location_equal(location, ca_origin_get(origin, 0), CA_LOCATION_WITH_MTIME|CA_LOCATION_WITH_FEATURE_FLAGS))
280280
return -EINVAL;
281281

282282
if (ret_chunk_id)
@@ -335,7 +335,7 @@ int ca_cache_put(CaCache *c, CaOrigin *origin, const CaChunkID *chunk_id) {
335335
const char *f;
336336
char *p;
337337

338-
/* If there's only a single item, then let's try to create this as symlink, is it is the cheapest
338+
/* If there's only a single item, then let's try to create this as symlink, it is the cheapest
339339
* option */
340340

341341
f = ca_location_format(first_location);
@@ -367,7 +367,7 @@ int ca_cache_put(CaCache *c, CaOrigin *origin, const CaChunkID *chunk_id) {
367367
if (r < 0)
368368
return r;
369369

370-
fd = openat(c->fd, temp, O_CREAT|O_WRONLY|O_CLOEXEC|O_EXCL|O_NOFOLLOW|O_EXCL, 0666);
370+
fd = openat(c->fd, temp, O_CREAT|O_EXCL|O_WRONLY|O_CLOEXEC|O_NOFOLLOW, 0666);
371371
if (fd < 0)
372372
return -errno;
373373

0 commit comments

Comments
 (0)