Compare commits

...

57 Commits

Author SHA1 Message Date
Axel Burri ba3c36c984 btrbk: fix duplicate cmdline option -l in lsbtr 2025-07-06 01:09:14 +02:00
Axel Burri c69f70e1d0 btrbk: fix loglevel along with verbose 2025-07-06 00:56:29 +02:00
Axel Burri 18ddc65979 documentation: fix stream_compress_adapt 2023-08-28 19:14:35 +02:00
Axel Burri 225f60f565 btrbk: remove handling of deprecated options before v0.23
After 7 years and a lot of warnings we can drop this code. Note that
most of those refer to `upgrade_to_v0.23.0.md`, which was removed in
16364e2.
2023-08-28 18:55:47 +02:00
Axel Burri f7e1265e7a documentation: remove upgrade_to_v0.23.0.md from Makefile
Forgotten after removal in:

   16364e2833 documentation: remove obsolete upgrade_to_v0.23.0.md
2023-08-28 18:42:42 +02:00
Axel Burri a4d4dff0d1 btrbk_restore_raw.py: fix spelling 2023-08-05 20:56:39 +02:00
Axel Burri d819f17e44 kdf_pbkdf2.py: fix spelling 2023-08-05 20:56:39 +02:00
Axel Burri 1807ad5cee btrbk-mail: fix spelling 2023-08-05 20:56:39 +02:00
Axel Burri b139875e2b btrbk: fix spelling 2023-08-05 20:56:39 +02:00
Axel Burri f6bdab143b documentation: fix spelling 2023-08-05 20:56:39 +02:00
Axel Burri 16364e2833 documentation: remove obsolete upgrade_to_v0.23.0.md 2023-08-05 20:56:34 +02:00
Axel Burri efa4d13111 ChangeLog: fix spelling 2023-08-05 20:56:34 +02:00
Yaroslav Halchenko dac6350b5d github: actions: add codespell master on push and PRs 2023-08-05 20:28:41 +02:00
oldherl a488096869 doc: README.md: fix typo 2023-07-14 19:40:18 +02:00
Sam James 9dfee7bc32 doc: allow asciidoc again
This effectively reverts 0e63843195 and
173319e7e1.

asciidoc has been revived (for a while now) and doesn't require Python 2. We
still prefer asciidoctor and fallback to asciidoc/a2x if it's not available.

Comparing the asciidoc and asciidoctor man pages, everything looks OK.

Python tends to be available more readily in distribution build environments
rather than the Ruby stack. Also, the pregenerated man pages are gone as of
f132c94c65.

Signed-off-by: Sam James <sam@gentoo.org>
2023-07-14 18:55:05 +02:00
Axel Burri db45f0b09c btrbk-mail: add example to enable all rsync 2023-07-07 01:53:15 +02:00
Axel Burri fa704c3185 btrbk-mail: add missing declare 2023-07-07 01:45:32 +02:00
Axel Burri b63609c298 btrbk-mail: declare associative arrays 2023-06-08 00:27:16 +02:00
Axel Burri 98580418e3 btrbk: fix displaying excluded in summary
- fix framework
 - print source excluded by archive_exclude in summary
 - fix exclude list in summary
2023-04-22 16:53:13 +02:00
Axel Burri 135edabc71 btrbk: rephrase warnings on unexpected (foreign) location 2023-04-22 16:51:32 +02:00
Axel Burri 4ba944e6a5 btrbk: fix exit status for action usage 2023-04-22 16:51:32 +02:00
Axel Burri dd7149b111 btrbk: improve error message 2023-04-22 16:51:32 +02:00
Axel Burri ed33db523c btrbk: add reason text to filter statements 2023-04-22 16:51:32 +02:00
Axel Burri 15a6b98a08 btrbk: print "create" action in schedule 2023-04-22 16:51:32 +02:00
Axel Burri eff9af34bc btrbk: fix print schedule if deletion is skipped
If deletion is skipped, we don't have a schedule call on the target,
which is used for --print-schedule text. Add some (rather hacky) code
to be able to also use the schedule result of the backup process.
2023-04-22 16:51:32 +02:00
Axel Burri 468ca1eae5 btrbk: tidy logging
Especially corrects $svol->{PRINT} where not applicable.
2023-04-22 16:51:32 +02:00
Axel Burri cca200707d btrbk: set subvolume url to /dev/null on archive
This should not be printed anywhere. If it is, it's a bug.
2023-04-22 16:51:32 +02:00
Axel Burri d4ab986245 btrbk: skip subvolume init on archive 2023-04-22 16:51:32 +02:00
Axel Burri 6f1145c279 btrbk: add archive related summary
Note that "no target action" for archive is replaced by "<no_action>",
for consistency with action run:

   [-] /path/to/target/snapshot_basename.*

is now displayed as:

   <no_action>
2023-04-22 16:51:32 +02:00
Axel Burri 6d047cbaec btrbk: disable target_create_dir for user; fix dryrun 2023-04-22 16:51:32 +02:00
Axel Burri e737927bd9 btrbk: tidy variable names 2023-04-22 16:51:32 +02:00
Axel Burri 053cd7a59c btrbk: use parser function for assembling archive config 2023-04-22 16:51:32 +02:00
Axel Burri 443cb1891b btrbk: action_archive: no strict_related parent search
strict_related parent search does not make much sense on archive: on
targets, parent_uuid chain is broken after first prune.

Ref: 318126b831
2023-04-22 16:51:32 +02:00
Axel Burri ac0f7e3b91 btrbk: action_archive: honor archive_exclude_older in backup step 2023-04-22 16:51:32 +02:00
Axel Burri d12241fcfc btrbk: action_archive: use correct config_preserve_hash 2023-04-22 16:51:32 +02:00
Axel Burri 1465a1ecc2 btrbk: use same code for backup and archive
Note that some functionality breaks with this commit. Specific
adaptions are done in following commits.
2023-04-22 16:51:32 +02:00
Axel Burri c385b0b731 btrbk: create dir if target_create_dir is set 2023-04-22 16:51:32 +02:00
Axel Burri 7aece45dbf btrbk: add vinfo_mkdir 2023-04-22 16:51:32 +02:00
Axel Burri 2bdd5eb8fc btrbk: use vinfo_realpath 2023-04-22 16:51:32 +02:00
Axel Burri 30b22d49d2 btrbk: add vinfo_realpath 2023-04-22 16:51:32 +02:00
Axel Burri 544d95e094 btrbk: add comment 2023-04-22 16:51:32 +02:00
Axel Burri fe137bd19c btrbk: honor --exclude on delete 2023-04-22 16:51:32 +02:00
Axel Burri 6d57aa4dbe documentation: honor --exclude on backup candidates 2023-04-22 16:51:32 +02:00
Axel Burri 4c174c8f72 btrbk: honor --exclude on backup candidates 2023-04-22 16:51:32 +02:00
Axel Burri c0da910276 btrbk: on resume, abort on unexpected if receive target is not present
A more sophisticated implementation would be to check this after
scheduling, only if the target really needs to be backuped.

We could as well automatically trigger a `btrfs snapshot -r` on target
in these cases, but this seems counter-intuitive.
2023-04-22 16:51:32 +02:00
Axel Burri d498dbb5c3 btrbk: list unexpected archive targets when aborting 2023-04-22 16:51:32 +02:00
Axel Burri 61691abbfc documentation: update deletion of raw targets 2023-04-22 16:51:32 +02:00
Axel Burri c4bf7b0c5a btrbk: use depends callback for raw depends 2023-04-22 16:51:32 +02:00
Axel Burri 6373e32875 btrbk: add depends callback to scheduler 2023-04-22 16:51:32 +02:00
Axel Burri 2a1a42e824 btrbk: related_nodes: add fatal option 2023-04-22 16:51:32 +02:00
Axel Burri e93952b08b btrbk: related_nodes: return reference instead of array
Preparatory for adding fatal option returning undef.
2023-04-22 16:51:32 +02:00
Axel Burri 131e75376f btrbk: fix raw parent_uuid 2023-04-22 16:51:32 +02:00
Axel Burri b77abb3eff btrbk: abort if cmdline specified config not found 2023-04-22 16:51:32 +02:00
Axel Burri 799d235218 btrbk: remove double-slash from file arguments
Sanitize file (or subvolume path) arguments in safe_cmd, effectively
removing leading double slash.

Files originating from "volume /" can be assembled as "//some/subvol",
which is useful internally but undesired as command arguments, as
ancient systems might interpret leading double slash "//" in a special
way.

Posix states:

> A pathname that begins with two successive slashes may be
> interpreted in an implementation-defined manner, although more than
> two leading slashes shall be treated as a single slash.
2023-04-22 16:51:32 +02:00
Axel Burri b9c5e3fc29 btrbk: bump version to 0.33.0-dev 2023-04-22 16:51:32 +02:00
Axel Burri 73c5d180f6 documentation: rephrase lockfile 2023-04-22 16:51:32 +02:00
Axel Burri ac42b29b0a bump copyright year 2023-04-10 16:04:27 +02:00
13 changed files with 401 additions and 619 deletions

26
.github/workflows/codespell.yml vendored Normal file
View File

@ -0,0 +1,26 @@
---
name: Codespell
on:
push:
branches: [master]
pull_request:
branches: [master]
permissions:
contents: read
jobs:
codespell:
name: Check for spelling errors
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Codespell
uses: codespell-project/actions-codespell@v2
with:
check_filenames: true
skip: ".git,*.pdf,*.svg"
ignore_words_list: uptodate

View File

@ -47,7 +47,7 @@ btrbk-0.32.1
btrbk-0.32.0
* MIGRATION
- If timestamp_format is not configured, explicitely set
- If timestamp_format is not configured, explicitly set
"timestamp_format short" to revert old behavior.
- Update ssh_filter_btrbk.sh on remote hosts.
* Change default for timestamp_format to "long".
@ -81,7 +81,7 @@ btrbk-0.31.2
* MIGRATION
- Update ssh_filter_btrbk.sh on remote hosts.
* ssh_filter_btrbk.sh: Fix security vulnerability.
Specialy crafted commands may be executed without being propely
Specially crafted commands may be executed without being properly
checked. Applies to remote hosts filtering ssh commands using
ssh_filter_btrbk.sh in authorized_keys.
* Warn if no subvolume defined in config (close #378).
@ -248,7 +248,7 @@ btrbk-0.27.0
- Allow snapshot_dir to be a mountpoint.
- Search complete target tree for correlated subvolumes.
- Include snapshots from all mountpoints as candidates (disabled
due to uptream bug: github.com/kdave/btrfs-progs/issues/96).
due to upstream bug: github.com/kdave/btrfs-progs/issues/96).
- Read /proc/self/mountinfo instead of /proc/self/mounts.
- Always read /proc/self/mountinfo.
- Resolve realpath using readlink(1).
@ -319,7 +319,7 @@ btrbk-0.25.0
* Allow trailing comments in btrbk.conf (close #129).
* Bugfix: rate limiting must be done after compression (close #134).
* raw_target_encrypt: Always set "gpg --no-random-seed-file":
prevents creation of "~/.gnupg/random_seed" with slight perfomance
prevents creation of "~/.gnupg/random_seed" with slight performance
penalty.
btrbk-0.24.0

View File

@ -428,7 +428,7 @@ host. For each backup, two files are created:
* `/backup/home.YYYYMMDD.btrfs.xz.gpg.info`: sidecar file containing
metadata used by btrbk.
I you are using raw _incremental_ backups, please make sure you
If you are using raw _incremental_ backups, please make sure you
understand the implications (see [btrbk.conf(5)], TARGET TYPES).

811
btrbk

File diff suppressed because it is too large Load Diff

View File

@ -4,6 +4,9 @@
now=$(date +%Y%m%d)
declare -A rsync_src rsync_dst rsync_log rsync_rsh rsync_opt
declare -A sync_fs_onchange
##### start config section #####
# Email recipients, separated by whitespace:
@ -30,7 +33,9 @@ rsync_opt[example_data]="-az --delete --inplace --numeric-ids --acls --xattrs"
# If set, add "rsync_dst" to "sync_fs" (see below) if rsync reports files transferred
#sync_fs_onchange[example_data]=yes
# Enabled rsync declarations (whitespace-separated list)
# Enable all rsync declarations (all indices of rsync_src array)
#rsync_enable=${!rsync_src[@]}
# Explicitly enable rsync declarations (whitespace-separated list)
#rsync_enable="example_data"
rsync_enable=

View File

@ -54,7 +54,7 @@ salt_hex = "".join(["{:02x}".format(x) for x in salt])
dk_hex = "".join(["{:02x}".format(x) for x in dk])
print("KEY=" + dk_hex);
print("algoritm=pbkdf2_hmac");
print("algorithm=pbkdf2_hmac");
print("hash_name=" + hash_name);
print("salt=" + salt_hex);
print("iterations=" + str(iterations));

View File

@ -196,7 +196,7 @@ def main():
parser.add_argument('restore_dir', help="target directory for restored subvolumes"
" (path argument for \"btrfs receive\")")
parser.add_argument('-n', '--dry-run', action='store_true',
help="print commmands that would be executed")
help="print commands that would be executed")
parser.add_argument('--ignore-missing', action='store_true',
help="do not fail on missing parent snapshots")

View File

@ -1,5 +1,4 @@
DOCS = FAQ.md \
upgrade_to_v0.23.0.md
DOCS = FAQ.md
MAN_MAN1 = btrbk.1 \
lsbtr.1 \
ssh_filter_btrbk.1
@ -18,8 +17,19 @@ ifeq ($(COMPRESS), yes)
endif
# convert using "asciidoctor": <https://asciidoctor.org>
ASCIIDOCTOR_MANPAGE = asciidoctor -d manpage -b manpage
ASCIIDOCTOR_HTML = asciidoctor -b html5 -d article
# fallback to "a2x" from asciidoc package: <http://asciidoc.org>
ifneq (, $(shell command -v asciidoctor 2> /dev/null))
ASCIIDOC_MANPAGE = asciidoctor -d manpage -b manpage
ASCIIDOC_HTML = asciidoctor -b html5 -d article
else ifneq (, $(shell command -v a2x 2> /dev/null))
# NOTE: using -L (--no-xmllint), as xmllint is a separate package on many distros.
ASCIIDOC_MANPAGE = a2x -L -d manpage -f manpage
ASCIIDOC_HTML = asciidoc -b html -d article
else
ASCIIDOC_ERR = $(error "please install either asciidoc or asciidoctor")
ASCIIDOC_MANPAGE = $(ASCIIDOC_ERR)
ASCIIDOC_HTML = $(ASCIIDOC_ERR)
endif
# reproducible builds: reference date is ":date:" attribute from asciidoc source
date_attr = $(shell sed -rn 's/:date:\s*//p' $(1))
@ -50,10 +60,10 @@ clean:
gzip -9 -n -c $< > $@
%.1 : %.1.asciidoc
SOURCE_DATE_EPOCH=$(call source_date_epoch,$<) $(ASCIIDOCTOR_MANPAGE) -o $@ $<
SOURCE_DATE_EPOCH=$(call source_date_epoch,$<) $(ASCIIDOC_MANPAGE) $<
%.5 : %.5.asciidoc
SOURCE_DATE_EPOCH=$(call source_date_epoch,$<) $(ASCIIDOCTOR_MANPAGE) -o $@ $<
SOURCE_DATE_EPOCH=$(call source_date_epoch,$<) $(ASCIIDOC_MANPAGE) $<
%.html : %.asciidoc
SOURCE_DATE_EPOCH=$(call source_date_epoch,$<) $(ASCIIDOCTOR_HTML) -o $@ $<
SOURCE_DATE_EPOCH=$(call source_date_epoch,$<) $(ASCIIDOC_HTML) -o $@ $<

View File

@ -88,8 +88,15 @@ OPTIONS
commands that would be executed.
--exclude <filter>::
Exclude configured sections matching '<filter>'. See
<<_filter_statements,FILTER STATEMENTS>> below.
Exclude configured sections matching '<filter>' (see
<<_filter_statements,FILTER STATEMENTS>> below), or any specific
snapshot from being backuped or deleted, or any specific backup
from being deleted.
+
Note that excluding specific snapshots from being backuped has impact
on scheduling: e.g. if the "first snapshot of the day" is excluded,
the "second snapshot of the day" shifts to "first", creating a backup
as "first backup of the day".
-p, --preserve::
Preserve all snapshots and backups. Skips deletion of any
@ -136,7 +143,7 @@ OPTIONS
space-separated, quoted key=value pairs (machine readable).
+
If set to "col:", prints only the <columns> specified (comma-separated
list). Header lines are ommitted if the "h:" modifier is present.
list). Header lines are omitted if the "h:" modifier is present.
Columns prefixed with "-" are collapsed if empty. Columns postfixed
with ":RALIGN" are right-aligned.
@ -154,9 +161,9 @@ with ":RALIGN" are right-aligned.
command (version >= 20180505) installed on the host running btrbk.
--lockfile <file>::
Create lockfile <file> on startup; checks lockfile before running
any btrfs commands (using perl "flock"), and exits if the lock is
held by another btrbk instance. Overrides configuration option
Place an exclusive lock on <file> during program execution, using
flock(2). If the lock is held by another process, exit before
running any actions. Overrides configuration option
"lockfile". Ignored on dryrun ('-n', '--dry-run').
--override <config_option>=<value>::

View File

@ -291,9 +291,9 @@ set to ``all'' (the default).
Number of threads to use for <compress_command>. Only supported
for "pigz", "pbzip2", "bzip3", "zstd" and recent versions of "xz".
*stream_compress_adapt* default|<number>::
*stream_compress_adapt* yes|no::
Enable adaptive compression for <compress_command>. Only supported
for "zstd" (version >= 1.3.6).
for "zstd" (version >= 1.3.6). Defaults to ``no''.
*stream_buffer* <size>|no::
Add a buffer to the btrfs send stream (locally, on uncompressed
@ -359,10 +359,10 @@ constraints.
daemon, auth, lpr, news, cron, authpriv, local0..local7.
*lockfile* <file>|no::
Create lockfile <file> on startup; checks lockfile before running
any btrfs commands (using perl "flock"), and exits if the lock is
held by another btrbk instance. Ignored on dryrun ('-n',
'--dry-run'). See also '--lockfile' command-line option.
Place an exclusive lock on <file> during program execution, using
flock(2). If the lock is held by another process, exit before
running any actions. Ignored on dryrun ('-n', '--dry-run'). See
also '--lockfile' command-line option.
*backend* <backend>::
Backend filesystem utilities to be used for btrfs specific
@ -605,10 +605,6 @@ TARGET TYPES
btrfs-send(8), with optional compression and encryption.
+
--
Note that the target preserve mechanism is currently disabled for
incremental raw backups (btrbk does not delete any incremental raw
files)!
Raw backups consist of two files: the main data file containing the
btrfs send stream, and a sidecar file ".info" containing metadata:
@ -624,6 +620,11 @@ For 'incremental' backups ("incremental yes"), please note that:
make sure that a non-incremental backup is triggered from time to
time.
* The scheduler will never delete dependent parents of backups
preserved by the retention policy (run btrbk with the '-S',
'--print-schedule' option to get a comprehensive output of the
scheduler results).
* There is currently no support for rotation of incremental backups:
if 'incremental' is set, a full backup must be triggered manually
from time to time in order to be able to delete old backups.

View File

@ -9,7 +9,8 @@ file, choose one of the following methods:
### Generic Linux System
Install [asciidoctor] if you want to build the documentation.
Install [asciidoctor] or [asciidoc] if you want to build the
documentation.
Download and unpack the latest [btrbk source tarball] and type:
@ -64,3 +65,4 @@ btrbk is in Void's `current` repository
[btrbk source tarball]: https://digint.ch/download/btrbk/releases/
[asciidoctor]: https://asciidoctor.org
[asciidoc]: https://asciidoc.org

View File

@ -67,7 +67,7 @@ OPTIONS
space-separated key="value" pairs (machine readable).
+
If set to "col:", prints only the <columns> specified (comma-separated
list). Header lines are ommitted if the "h:" modifier is present.
list). Header lines are omitted if the "h:" modifier is present.
Columns prefixed with "-" are collapsed if empty. Columns postfixed
with ":RALIGN" are right-aligned.

View File

@ -1,92 +0,0 @@
Upgrading to btrbk-v0.23.0
==========================
In order to keep btrbk simple and intuitive while adding new features,
it became inevitable to change the semantics of the "retention policy"
related configuration options.
What has changed?
-----------------
### Preserve *first* instead of *last* snapshot/backup
btrbk used to *always* transfer the latest snapshot to the target
location, while considering the *last* snapshot/backup of a day as a
daily backup (and also the last weekly as a monthly). This made it
very cumbersome when running btrbk in a cron job as well as manually,
because the last manually created snapshot was immediately transferred
on every run, and used as the daily backup (instead of the one created
periodically by the cron job).
The new semantics are to consider the *first* (instead of *last*)
snapshot of a hour/day/week/month as the one to be preserved, while
only transferring the snapshots needed to satisfy the target retention
policy.
### Preserve snapshots for a minimum amount of time
In order to specify a minimum amount of time in which *all* snapshots
should be preserved, the new "snapshot_preserve_min" and
"target_preserve_min" configuration options were introduced. This was
previously covered by "snapshot_preserve_daily", which caused a lot of
confusion among users.
Upgrading the configuration file: /etc/btrbk/btrbk.conf
-------------------------------------------------------
Please read the description of the "run" command in [btrbk(1)], as
well as the "RETENTION POLICY" section in [btrbk.conf(5)] for a
detailed description. Make sure to understand the new concept, and run
`btrbk --print-schedule dryrun` after updating the configuration.
### Upgrade retention policy
If you want the same behaviour as before:
# replace this:
snapshot_preserve_daily <daily>
snapshot_preserve_weekly <weekly>
snapshot_preserve_monthly <monthly>
# with:
snapshot_preserve_min <daily>d
snapshot_preserve <weekly>w <monthly>m
# ... do the same with "target_preserve_*" options
But what you probably want is something like:
snapshot_preserve_min 5d
snapshot_preserve <daily>d <weekly>w <monthly>m
target_preserve_min no
target_preserve <daily>d <weekly>w <monthly>m *y
This states:
* Keep all snapshots for five days (no matter how many there are)
* Transfer only the first snapshot of a day to the target
* Keep all "first snapshots of a day" for `<daily>` days, etc.
### Upgrade "resume_missing"
If you have a line: "resume_missing yes" somwhere in your config,
simply remove it. btrbk always resumes missing backups.
If you have "resume_missing no", you can imitate this behaviour by
setting:
target_preserve_min latest
target_preserve no
This states: "always transfer the latest snapshot to the target".
[btrbk(1)]: https://digint.ch/btrbk/doc/btrbk.1.html
[btrbk.conf(5)]: https://digint.ch/btrbk/doc/btrbk.conf.5.html