Commit Graph

688 Commits (prune-ignore-latest-common)

Author SHA1 Message Date
Axel Burri d345dfbf50 btrbk: UNFINISHED: add command-line option "--ignore-related"
Ref: github bug #249

Should work for `btrbk prune --preserve-backups --ignore-related`.

UNFINISHED: Counterpart for `--preserve-snapshots` still needs source readin.
2018-08-27 16:21:57 +02:00
Axel Burri 1862bc16d3 documentation: btrbk.1.asciidoc: add note about "prune": source/target must be accessible
Related to: c65f937473
2018-08-27 15:50:36 +02:00
Axel Burri 069304f3bb btrbk: use system_list_mountinfo(), remove system_list_mounts(); rename fs_spec -> mount_source
Reasons for changing to `cat /proc/self/mountinfo`:
 - `/proc/self/mounts` (or `/proc/mounts`) lacks extra info
   (namespaces) and is not documented in kernel (deprecated?).
 - findmnt(8) also uses /proc/self/mountinfo

Refs:
 - https://www.kernel.org/doc/Documentation/filesystems/proc.txt
 - https://bugzilla.redhat.com/show_bug.cgi?id=491924
 - https://git.kernel.org/pub/scm/linux/kernel/git/bwh/linux-stable.git/commit/?id=2d4d4864ac08caff5c204a752bd004eed4f08760
2018-08-27 14:54:32 +02:00
Axel Burri e02c2cf249 btrbk: add system_list_mountinfo: parse /proc/self/mountinfo
preparatory patch for removing system_list_mounts().
2018-08-27 14:52:28 +02:00
Axel Burri 37c0e840e9 btrbk: bugfix: use latest longest match for resolving mount point (e.g. for autofs) 2018-08-27 14:49:04 +02:00
Paride Legovini 3dc06c8067 documentation: btrbk.conf.5: clarify behavior of 'snapshot_create ondemand' when there are multiple targets 2018-07-30 03:28:18 +02:00
Axel Burri 0d124a4373 btrbk: fix regression in get_related_subvolumes(): correctly match same btrbk file name scheme
Since we consider all accessible subvolumes in get_related_subvolumes,
checking for equal BTRBK_BASENAME and empty SUBVOL_DIR does not work
when checking for same btrbk file name scheme.

fixes regression: b37ef84e36 (btrbk: always read mountpoints; include all snapshots from mountpoint as candidates for best common parent)
2018-07-18 16:13:33 +02:00
Axel Burri bf5fd7a90b btrbk: cosmetics: fix prototype of get_related_subvolumes() 2018-07-18 16:13:29 +02:00
Axel Burri 1242913d9b btrbk: cosmetics: rename variables (spec -> fs_spec) 2018-07-12 18:26:35 +02:00
Axel Burri 5b1b99c4ed documentation: btrbk.conf.5: add explanation on hostname and caches 2018-07-12 18:26:35 +02:00
Axel Burri 78cec36e30 ssh_filter_btrbk: tighten decompress match expression 2018-07-12 18:26:35 +02:00
Axel Burri 47f6f730ab btrbk: cosmetics: change error message in btrfs_subvolume_delete; add comments 2018-07-12 18:26:35 +02:00
Axel Burri faec212324 btrbk: check if received subvolume is really garbled before deleting it
Improve error handling in btrfs_send_receive: on error, always try to
read the target subvolume and only delete it automatically if it is
garbled (read/write, no received_uuid).

This is especially important if the target subvolume was already
present before send/receive.

Reverts: 4c4afe77 btrbk: skip target metadata test if send/receive has errors
2018-07-12 18:26:35 +02:00
Axel Burri de57efff82 btrbk: bugfix: print all errors if send/receive fails
If stream_compress is enabled and compress command is not found, we
now print "command not found".
2018-07-12 18:26:34 +02:00
Axel Burri 9aeaf2b15c btrbk: fix regression introduced with btrfs_subvolume_list_complete
If btrfs_subvolume_show($vol, rootid => 5) fails, there are no
"received_uuid" and no "gen" keys in the root node.

Fixes: 0acbf74c57 (btrbk: add btrfs_subvolume_list_complete: fetch all subvolumes with all flags)
2018-07-09 18:46:24 +02:00
Axel Burri 669a34357a btrbk: bugfix: handle corner case: url="ssh://my.host" (without trailing slash)
As we allow <url> to be specified as "<hostname>:<directory>", an URL
"ssh://my.host" (without trailing slash) was parsed as hostname="ssh",
directory="/my.host".
2018-07-09 16:13:48 +02:00
Axel Burri c2022a5b2f documentation: add text for "subvolume ." configuration 2018-07-09 16:13:00 +02:00
Axel Burri 0acbf74c57 btrbk: add btrfs_subvolume_list_complete: fetch all subvolumes with all flags
Wrapper, returns complete list of all subvolumes (including btrfs
root, id=5) with all flags. Requires three calls to btrfs-progs.

Adaptions and cleanup in btr_tree().
2018-07-09 16:13:00 +02:00
Axel Burri d15133b3d4 btrbk: snapshot_name defaults to volume name if subvolume name is "." 2018-07-09 16:13:00 +02:00
Axel Burri 7088a91fa3 btrbk: cosmetics: sanitize trailing "/." in check_file() 2018-07-09 16:13:00 +02:00
Axel Burri de5004c744 btrbk: abort subvolume if it is btrfs root (id=5)
Btrfs root subvolume (id=5) have no UUID and cannot be backed
up. Abort if "subvolume ." is configured on btrfs root, e.g.:

  volume /path/to/btrfs_root
    subvolume .
2018-07-09 16:13:00 +02:00
Axel Burri b0d58fd0f1 btrbk: btr_tree: always read btrfs root node (id=5), hoping to get its uuid
Note that the UUID for btrfs root (id=5) is not always present:

 - btrfs-progs < 4.12 does not support rootid lookup
 - UUID can be missing if filesystem was created with btrfs-progs < 4.16

Still we need to always read it, as the whole tree is cached and we
don't know if it will be used.
2018-07-09 16:13:00 +02:00
Axel Burri cb5e361f7a btrbk: add --rootid command option for "btrfs subvolume show" 2018-07-09 16:13:00 +02:00
Axel Burri 1aa0fe1aad btrbk: remove obsolete realpath_cache update in btrfs_subvolume_show()
Recent btrfs-progs do not print the real path any more, this is now
handled by btrfs_mountpoint() -> system_realpath().
2018-07-09 16:13:00 +02:00
Axel Burri 177671e920 btrbk: validate output of "btrfs subvolume show"; also return uuid for btrfs root (if present)
Filesystems created with btrfs-progs < 4.16 have valid UUID, while
others have not [1]. Validate output of "btrfs subvolume show", and
provide uuid for btrfs root (id=5) only if it is valid.

  [1]: 0a0a03554a: btrfs-progs: mkfs: add uuid and otime to ROOT_ITEM of, FS_TREE
2018-07-09 16:13:00 +02:00
teesid 9c70231859 btrbk: allow backup of subvolume (subvolid != 5) mounted at "/"
It works with the configuration snippet below if subvolid != 5:

```
volume /
  subvolume  .
    snapshot_name  root
```
2018-07-09 16:13:00 +02:00
Axel Burri 2f95baf6f3 documentation: adaptions for asciidoctor (ifdefs, literal blocks)
When using asciidoctor, backend "manpage" (-b manpage) is used, while
a2x converts asciidoc to docbook (xml), then manpage.

Asciidoctor creates ugly indentation for [literal] blocks in SYNOPSIS,
use [verse] instead.
2018-06-25 20:49:24 +02:00
Axel Burri 3e9066337a documentation: fallback to asciidoctor if asciidoc (a2x) is not present
Asciidoc is EOL and only supports python2. Provide a fallback to
Asciidoctor for manpage generation.

Reference: https://github.com/digint/btrbk/pull/219
2018-06-25 20:46:00 +02:00
Axel Burri a0f6b55d28 btrbk: fix regression: undefined array reference when no received_uuid present
fixes #239 (@ian-kelling)
2018-06-25 13:30:14 +02:00
Samantha McVey 211943d4af btrbk: cosmetics: reformat a regex to be much more readable 2018-06-04 11:39:52 +02:00
Samantha McVey 969569592a btrbk: cosmetics: use heredocs for the help message
Avoids use having to use 40 print's and having to quote each line and is
much easier to edit.
2018-06-04 11:39:03 +02:00
Axel Burri 1d0d57ffac documentation: btrbk.conf.5: add more text on file names and urls 2018-05-31 00:36:46 +02:00
Axel Burri 391e50b872 btrbk: do not warn on non-parseable btrfs mountpoint
Many people use whitespace even in mountpoints, silently ignore
(loglevel=info) non-parseable btrfs mountpoints.

Btrbk does not support file names with whitespace or special
characters by design, and specifying such mountpoints in the
configuration file fails anyway.
2018-05-31 00:34:50 +02:00
Axel Burri ffba3e47c6 documentation: ssh_filter_btrbk.1.asciidoc: fixes, cleanup
- add add "always allowed" commands (as bullet list)
- remove deprecated "-c, --compress"
2018-05-15 00:06:53 +02:00
Axel Burri 2f56c55120 btrbk: fix regression: actions "list snapshots/backups" print all snapshots under sroot (not snaproot)
Regression from: c457540ce3
2018-05-14 23:43:13 +02:00
Axel Burri 09918bf5af btrbk: cosmetics: print (fix) reason why snapshots/backups are skipped/preserved 2018-05-11 00:17:52 +02:00
Axel Burri 9ae823a757 btrbk: cosmetics: remove too chatty debug log 2018-05-10 15:44:46 +02:00
Vít Novotný c8fcb01bc2 btrbk: bugfix: do not read target btrfs tree on "btrbk snapshot --preserve"
If running "btrbk snapshot --preserve", there is no need to initialize
targets, and we don't want to warn and fail (exitcode=10) on missing
targets.
2018-05-10 15:18:36 +02:00
Axel Burri 17f41118d3 btrbk: bugfix: compare all mountpoints while resolving
When comparing longest match in mounts, all mountpoints have to be
taken into account (not only the btrfs mount points).
2018-05-10 14:02:44 +02:00
Axel Burri 847be88142 ChangeLog: add changes to internal data structures
Covers commits:

1c83a65 btrbk: add filter capabilities to vinfo_subvol_list
a25487e btrbk: cosmetics (log messages)
ef5c369 btrbk: use _is_same_fs_tree() where applicable
0454f60 btrbk: bugfix: match btrbk_basename in get_latest_snapshot_child()
2c1c3b4 btrbk: cleanup: remove snapshot_dir, rename sroot->snaproot
c457540 btrbk: use separate vinfo for snapshot directory (allows snapshot_dir to be a mountpoint)
f5dc4e0 btrbk: add known mountpoints to btr_tree nodes as anchor for reverse lookup
e9374b3 btrbk: replace url_cache by spec_cache
0ea0430 btrbk: cleanup (cosmetics, documentation)
b37ef84 btrbk: always read mountpoints; include all snapshots from mountpoint as candidates for best common parent
b549e11 btrbk: raw targets: move tree readin to separate function; add caching
7a1bc25 btrbk: raw targets: create fake btr_tree instead of maintaining separate list
6c502cb btrbk: search complete target tree for correlated subvolumes
2018-05-10 12:03:51 +02:00
Axel Burri 1c83a6545d btrbk: add filter capabilities to vinfo_subvol_list
Clean up (and speedup) code by filtering while building the list
instead of checking every item after building.
2018-05-10 11:48:34 +02:00
Axel Burri a25487e873 btrbk: cosmetics (log messages) 2018-05-10 11:48:34 +02:00
Axel Burri ef5c369a37 btrbk: use _is_same_fs_tree() where applicable 2018-05-10 11:48:34 +02:00
Axel Burri 0454f60ad1 btrbk: bugfix: match btrbk_basename in get_latest_snapshot_child() 2018-05-10 11:48:34 +02:00
Axel Burri 2c1c3b4d54 btrbk: cleanup: remove snapshot_dir, rename sroot->snaproot 2018-05-10 11:48:34 +02:00
Axel Burri c457540ce3 btrbk: use separate vinfo for snapshot directory (allows snapshot_dir to be a mountpoint)
Instead of passing snapshot_dir all over the place, use a separate
vinfo for the snapshot directory, accessible by vinfo_snapshot_root().
As it is initialized separately by vinfo_init_root(), it can be on a
different mountpoint.

This also allows us to use different semantics for snapshot_dir in the
future, as it does not need to be relative to the volume directory.
2018-05-10 11:48:34 +02:00
Axel Burri f5dc4e0a36 btrbk: add known mountpoints to btr_tree nodes as anchor for reverse lookup 2018-05-10 11:48:34 +02:00
Axel Burri e9374b3b1d btrbk: replace url_cache by spec_cache 2018-05-10 11:48:34 +02:00
Axel Burri 0ea0430c43 btrbk: cleanup (cosmetics, documentation) 2018-05-10 11:48:34 +02:00
Axel Burri b37ef84e36 btrbk: always read mountpoints; include all snapshots from mountpoint as candidates for best common parent
Dropped readin of subvolid and realpath by btrfs_subvolume_show(), we
now always read /proc/self/mounts (and call readlink).

When picking the best common parent in get_best_parent(), we want to
list as many snapshots as possible. For now, we list all from the
mountpoint of snaproot ($sroot/<snapshot_dir>), due to a bug in
btrfs-progs [1]. Also added code (commented out) to list snapshots
from all known mountpoints.

  [1] https://github.com/kdave/btrfs-progs/issues/96
2018-05-10 11:48:05 +02:00