Commit Graph

162 Commits (0acbf74c5794aeaf55c900fba81ddd7abad5ea09)

Author SHA1 Message Date
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
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 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 490f680f41 btrbk: bugfix: add backend mappings for "btrfs filesystem usage" 2018-04-30 14:15:30 +02:00
Axel Burri 719fb5fb74 btrbk: bugfix: correct scheduling of "first weekly backup in month/year"
In the scheduler, a month (or year) does not start at the first day,
but at the first `preserve_day_of_week`. Make sure that all days
before `preserve_day_of_week` in a month get delta_months+1.

Example (corner case):
  - `preserve_day_of_week  sunday`
  - `target_preserve  *m`
  - no backups in 2018-02
  - backup with timestamp 2018-03-01 (which is a thursday)
  - backup with timestamp 2018-03-04 (which is a sunday)

Without this patch, because there are no sunday backups in 2018-02,
the first backup is considered a weekly (+4d after sunday), and as
such "first weekly of month 2018-03", and the second one is discarded.

With this patch, the first item is considered "first weekly of month
2018-02", and the second gets "first weekly of month 2018-03".

NOTE: This change may result in (previously preserved) backups to be
deleted!
2018-04-05 18:00:29 +02:00
Thiodwitnir 5791d72171 btrbk: add "preserve_hour_of_day" configuration option
Introduces the new config option "preserve_hour_of_day" to specify
after what time backups should be considered as dailies.

Based on pull request #204, with changes:
 - calculation of weekly backups
 - change format of preserve_matrix
2018-04-05 16:37:31 +02:00
Axel Burri 951ae256fa btrbk: bump version to 0.27.0-dev 2018-04-05 16:26:57 +02:00
Axel Burri 1fd3a547df change version to 0.26.1; bump copyright year 2018-03-05 11:55:56 +01:00
Axel Burri 8610e75459 btrbk: add archive_exclude configuration option
Support wildcard characters, matches against both "$sroot->{PATH}" and
"$sroot->{PATH}/$snapshot_name".
2018-02-13 22:50:23 +01:00
Axel Burri a3641cff74 btrbk: fix filter statement matching for volume="/"
While $vol->{URL} can contain "//" if volume="/" (intentionally, this
is an assembled path), the filter statements are sanitized using
check_url(). This means we need to match the filter statement against
check_url($vol->{URL}). Same applies to subvol.
2018-02-03 12:55:21 +01:00
Axel Burri 84bac59ab4 btrbk: fix parsing of "openssl_iv_size" configuration option 2018-01-21 18:53:29 +01:00
Axel Burri 79cbf7c0c3 change version to 0.26.0 2017-10-12 00:39:06 +02:00
Axel Burri c4ced9d6e4 documentation: convert all groff files (man pages) to asciidoc
- btrbk.conf.5 to btrbk.conf.5.asciidoc
 - btrbk.1 to btrbk.1.asciidoc
 - ssh_filter_btrbk.1 to ssh_filter_btrbk.1.asciidoc
2017-10-11 18:04:25 +02:00
Axel Burri 3be65b9f67 btrbk: resolve ancestors (recursive on parent_uuid chain) when searching for latest common subvolume 2017-10-10 13:10:33 +02:00
Axel Burri 0799820556 btrbk: support btrfs-progs 4.13.2: adapt parsing of "btrfs subvolume list"
btrfs-progs v4.13.2 changed the output of "btrfs subvolume list", in
order to make the tabular output format look nicer (?!?):

e4c6772f69
2017-10-09 23:04:07 +02:00
Axel Burri e9a517f161 btrbk: add options "{snapshot,target,archive}_qgroup_destroy": destroy qgroups whenever a subvolume is deleted
Btrfs does not destroy qgroups when subvolumes are deleted (see
https://bugzilla.kernel.org/show_bug.cgi?id=91751). As a workaround
for this, btrbk can be configured to always destroy the corresponding
default qgroup "0/<subvol-id>" whenever a subvolume (snapshot, backup
or archive) is deleted.

Added configuration options:
 - snapshot_qgroup_destroy
 - target_qgroup_destroy
 - archive_qgroup_destroy
2017-10-02 16:23:23 +02:00
Axel Burri 2e974c1f4f btrbk: add "--wipe" command line option 2017-09-28 14:17:00 +02:00
Axel Burri 5bdc3e527b btrbk: add "prune" command 2017-09-28 14:17:00 +02:00
Axel Burri de7628ac7c btrbk: add openssl_enc encryption for raw targets; add system_urandom()
Example:

Manually create a key:

    # KEYFILE=/some/secure/place/btrbk.key
    # dd if=/dev/urandom bs=1 count=32 | od -x -A n | tr -d "[:space:]" > $KEYFILE

btrbk.conf:

    volume /mnt/btr_pool
      incremental no
      raw_target_encrypt  openssl_enc
      openssl_ciphername  aes-256-cbc
      openssl_iv_size     16  # NOTE: set to "no" if no IV is needed by the selected cipher
      openssl_keyfile     /some/secure/place/btrbk.key

      subvolume home
        target raw ssh://cloud.example.com/backup
2017-09-28 14:17:00 +02:00
Axel Burri e804930b5e btrbk: allow deletion of non-incremental raw targets
implemented directly in btrfs_subvolume_delete()
2017-09-28 14:17:00 +02:00
Axel Burri dcb0c5aa28 contrib/migration/raw_suffix2sidecar: add migration tool for creating raw sidecar files from uuid-suffixed raw backup files 2017-09-28 14:17:00 +02:00
Axel Burri cd8d7e3a0a btrbk: use sidecar file "*.info" instead of encoding uuids into filename for raw targets
pros:

 - better forward compatibility, e.g. symmetrical encryption
 - better readability of files

cons:

 - two files per backup
2017-09-28 14:16:53 +02:00
Axel Burri 571dae4428 btrbk: do not run in perl taint mode by default: remove "perl -T" in hashbang; hardcode $PATH only if taint mode is enabled
While taint mode [1] is a nice feature of perl, e.g. it disallows
using variables (such as filenames from the config file) which were
not validated in system() commands, it also treats $PATH as insecure
(which inherently is, as perl cannot know who messed around with it).

  [1] perlsec(1): http://perldoc.perl.org/perlsec.html
  [2] perlrun(1): http://perldoc.perl.org/perlrun.html

Note that btrbk still does all taint checks, and can be run in taint
mode:

  - by executing `perl -T /usr/sbin/btrbk`,
  - or by changing the hashbang to: `!#/usr/bin/perl -T`.
2017-09-25 17:53:35 +02:00
Axel Burri 6c2d56d621 btrbk: action "clean": dont list failed deletes in summary 2017-09-21 12:39:48 +02:00
Axel Burri f113436626 btrbk: bugfix: check path when expanding wildcards (warn and ignore if check fails)
Before this patch, btrbk errored (unsafe command), and then died.
Fixes #181.
2017-09-11 18:49:14 +02:00
Axel Burri 88aa8c1fea btrbk: remove "duration" column from transaction_log/transaction_syslog
The "duration" column in the transaction log has proven to be
confusing to some users, especially on errors (e.g. "send-receive
ERROR 27" in issue #177). As it's not really necessary (duration can
be computed from the corresponding "starting" log entry), it's now
being dropped.
2017-08-28 17:55:27 +02:00
Axel Burri 6acea6a08d btrbk: bugfix: print correct time in end_transaction() 2017-08-28 17:54:17 +02:00
Axel Burri ee17c1a2b4 ssh_filter_btrbk: accept mbuffer command (stream_compress) 2017-08-21 14:39:40 +02:00
Axel Burri 5428e9cd93 btrbk: add "resume" and "snapshot" commands; add --preserve-snapshots and --preserve-backups options; deprecate "-r, --resume-only" command line option 2017-08-21 13:23:20 +02:00
Axel Burri a9f1b6b24a change version to 0.25.1 2017-07-30 16:03:58 +02:00
Axel Burri 6cf5d59644 btrbk: add support for btrfs-progs 4.12: do not fail or set realpath_cache for relative paths in btrfs_subvolume_show()
As of btrfs-progs-v4.12, the "btrfs subvolume show" command does not
print the full (absolute, resolved) path anymore [1]. Instead, it prints
the relative path to btrfs root (or "/" if it is the root).

The impact for btrbk is that we cannot fill our realpath_cache in
btrfs_subvolume_show() anymore. This is not fatal, but has the
following consequences:

  - The "check for duplicate snapshot locations" may now miss
    subvolumes specified by symlinks.

  - If multiple "volume" sections point to the same subvolume (e.g. if
    specified using symlinks) an additional "btrfs subvolume list" is
    called. Note that the subvolume will still be recognized as
    identical, and the btr_tree will not be rebuilt.

  [1] btrfs-progs commit: b7df24aa5cddc4802b9938f56372b73869775cd9
2017-07-30 15:25:32 +02:00
Axel Burri 356231bc2a btrbk: abort if source subvolume has readonly or received_uuid flag 2017-07-29 19:03:23 +02:00
Axel Burri c0c546eb4e btrbk: stats command: show "correlated" status instead of "orphaned" (inverse logic which caused a lot of confusion) 2017-06-25 21:16:08 +02:00
Axel Burri 15bae5e051 btrbk: stats command: print up-to-date status on backups 2017-06-25 21:14:03 +02:00
Axel Burri b2cc99b0fb btrbk: bugfix: accept "no" for "transaction_log", "transaction_syslog" and "lockfile" configuration options 2017-06-25 18:06:06 +02:00
Axel Burri 315b3f24a1 btrbk: add config option "stream_buffer <size>". if set, pipes send stream through "mbuffer -m <size>" 2017-06-08 12:35:22 +02:00
Axel Burri 7436d9432c change version to 0.25.0 2017-03-18 16:53:07 +01:00
Axel Burri d31ffb8cb0 btrbk: allow trailing comments in btrbk.conf 2017-03-18 16:34:53 +01:00
Axel Burri 28c65e4675 btrbk: add raw_target_split option, using "split" instead of "dd" to write raw files 2017-03-18 14:47:43 +01:00
Axel Burri da70158c24 ssh_filter_btrbk: correctly handle --sudo option 2017-03-18 12:19:07 +01:00
Axel Burri 3b7ede773a btrbk: bugfix: make sure rate limiting comes after compression in cmd_pipe 2017-03-18 12:18:47 +01:00
Axel Burri cb82bd5fa4 btrbk: add supoort for "backend btrfs-progs-sudo" option; adaptions in ssh_filter_btrbk.sh 2017-01-04 15:04:22 +01:00
Ian Kelling d02f67a924 btrbk: get_receive_targets: also match "src.received_uuid == target.uuid"
This gets important when using an old backup disk as source.

In terms of btrfs send/receive, all subvolumes matching "uuid /
received_uuid" are valid backups.

Merged (amend) from pull request: #116

Verified by Axel Burri <axel@tty0.ch>
2017-01-04 12:41:05 +01:00
Axel Burri 79637de5aa btrbk: raw_target_encrypt: always set "gpg --no-random-seed-file": prevents creation of "~/.gnupg/random_seed" with slight perfomance penalty.
We set "--no-random-seed-file" because one of the btrbk
design principles is to not create any files unasked. Enabling
"--no-random-seed-file" creates ~/.gnupg/random_seed, and as
such depends on $HOME to be set correctly (think on running in
cron). From gpg2(1) man page:
  --no-random-seed-file GnuPG uses a file to store its
  internal random pool over invocations This makes random
  generation faster; however sometimes write operations are not
  desired. This option can be used to achieve that with the cost
  of slower random generation.
2017-01-03 13:41:39 +01:00
Axel Burri b69e9ebf34 btrbk: show aggregate "size" and "used" for "usage" action 2016-12-11 15:36:48 +01:00
Axel Burri da849b37ae change version to 0.24.0 2016-11-16 15:32:17 +01:00
Axel Burri ec63e9932b btrbk: support for btrfs-progs v4.8.3
Fix parsing of "btrfs sub show" output, which has changed for toplevel
subvolume.
2016-11-16 15:02:49 +01:00
Axel Burri 57be688f6b btrbk: bugfix: fix "list latest" with no snapshots 2016-11-12 13:21:33 +01:00
Axel Burri a8a311c8c7 btrbk: add "backend" configuration option: support for distinct binaries from btrfs-progs-btrbk
btrfs-progs-btrbk sources (fork of btrfs-progs) can be found at:

https://github.com/digint/btrfs-progs-btrbk
2016-08-29 18:40:42 +02:00
Axel Burri 961f96833a btrbk: use "dd" for raw target output, with configurable block size (raw_target_block_size)
We use "dd" instead of shell redirections, as it is common to have
special filesystems (like NFS, SMB, FUSE) mounted on the raw target
path. By using "dd" we make sure to write in reasonably large blocks
(default=128K), which is not always the case when using redirections
(e.g. "gpg > outfile" writes in 8K blocks).

Another approach would be to always pipe through "cat", which uses
st_blksize from fstat(2) (with a minimum of 128K) to determine the
block size.
2016-08-25 13:14:01 +02:00