McdeSys gets the backup (lib/McdeSys/backup.c): a partition becomes the backup disk with an encrypted repository (borg init -e repokey-blake2); every hour root's crontab runs dtbackup run: borg create of / (and /home) on its own file systems, lz4, then prune -- 24 hourly, 30 daily, 52 weekly, every monthly unless set otherwise (keep_* in /etc/mcde-backup.conf, -1 keeps every one) -- and compact. The watcher: before and after each run, while the backup disk has less than min_free percent free (10 unless set), the oldest backup is deleted and the space given back; the newest is never deleted. Listing (borg list --json) and restoring a path into a folder (borg extract). The passphrase lives in /etc/mcde-backup.pass, root's alone, handed over by BORG_PASSCOMMAND. docs/reference/borg.txt from borg 1.4.5's own documentation. dtbackup run | status | list: the same from a shell and for cron, no X. Measured: builds on the Linux host and compiles in the build VM; as a user dtbackup status says no disk is set up and dtbackup run refuses. Not measured: a real backup -- borg is not on the host and goes into the set with the next userland. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
218 lines
14 KiB
Plaintext
218 lines
14 KiB
Plaintext
BorgBackup 1.4.5 (pkgsrc sysutils/py-borgbackup): what McdeSys's backup follows.
|
|
Source: borgbackup-1.4.5.tar.gz from PyPI, sha512 as pkgsrc's distinfo; docs/usage/*.rst.inc. Collected 2026-11-11.
|
|
|
|
== init.rst.inc:76-135 (encryption modes; repokey-blake2)
|
|
encryption mode.
|
|
|
|
As a general rule of thumb, use ``repokey`` with a strong passphrase:
|
|
|
|
borg init --encryption repokey /path/to/repo
|
|
|
|
However, there are many reasons to choose differently. See the section
|
|
below for details. In any case, Borg will:
|
|
|
|
1. Ask you to enter a unique and strong passphrase.
|
|
2. Create a random Borg key (which actually consists of three random
|
|
secrets, see :ref:`key_files` for details).
|
|
3. Encrypt the Borg key with your passphrase.
|
|
4. Store the encrypted Borg key inside the repository directory (with
|
|
``repokey`` and ``repokey-blake2`` modes; with ``keyfile`` and
|
|
``keyfile-blake2`` modes the Borg key is stored in your home
|
|
directory instead, see below). Since we usually have to assume that
|
|
an attacker could gain access to the repository (that's why we
|
|
encrypt the data in the first place), choosing a strong and unique
|
|
passphrase is absolutely crucial.
|
|
5. Encrypt and sign your backups with the Borg key to prevent anyone
|
|
from reading or forging them unless they have the Borg key *and*
|
|
know the passphrase.
|
|
6. Use the Borg key to decrypt and thus access the data stored in your
|
|
repository, e.g. when extracting files. The contents can also be
|
|
verified to detect accidental corruption or malicious tampering.
|
|
|
|
As you can see, you always need *both* the Borg key and passphrase to
|
|
access your data. Thus it's crucial to keep a backup of your key
|
|
*outside* both the repository and the system you create backups of.
|
|
You can easily run into a "leaving your keys inside your car" situation
|
|
otherwise. See :ref:`borg_key_export` to create a backup of your key
|
|
(e.g., by printing it on paper).
|
|
|
|
Encryption is done locally - i.e., if you back up to a remote machine,
|
|
the remote machine neither sees your passphrase, nor your unencrypted
|
|
Borg key, nor your unencrypted files. Chunking and ID generation are
|
|
based on your key to improve privacy.
|
|
|
|
**About hardware acceleration:**
|
|
|
|
Borg encrypts data with AES, which is pretty fast thanks to hardware
|
|
acceleration on basically all modern Intel, AMD, and ARM CPUs since
|
|
around the early 2010s (very cheap models since the mid-2010s).
|
|
|
|
As the hashing algorithm, Borg can use either SHA256 or BLAKE2b. ARM
|
|
CPUs support hardware-accelerated SHA256 hashing since ARMv7 with NEON
|
|
(around 2011), or ARMv8 (around 2013). AMD CPUs support it since Zen 1
|
|
(around 2017), i.e. all AMD Ryzen CPUs. Intel CPUs support it since Ice
|
|
Lake on mobile (10th gen, around 2021), and Rocket Lake on desktop
|
|
(11th gen, around 2021). Very cheap models have received support a few
|
|
years later. If your CPU doesn't support hardware-accelerated SHA256
|
|
hashing, you might want to give BLAKE2b hashing a try - it's likely
|
|
faster then. So, instead of ``repokey`` mode, use ``repokey-blake2``
|
|
(or any of the other ``-blake2`` modes for that matter).
|
|
|
|
Hardware acceleration is always used automatically when available.
|
|
|
|
Picking a passphrase
|
|
++++++++++++++++++++
|
|
|
|
== init.rst.inc:205-230 (repokey: the key lives in the repository, protected by the passphrase)
|
|
``keyfile-blake2`` modes with an empty passphrase. These modes are
|
|
generally safe even without a passphrase, but keeping an offsite
|
|
backup of the Borg key is also important then. See below for details.
|
|
|
|
If you can assure that an attacker can't gain access to your repo, e.g.
|
|
when independently encrypting your repository disk or filesystem, you
|
|
can think about using ``repokey`` or ``repokey-blake2`` modes with an
|
|
empty passphrase. However, keep in mind that if an attacker still
|
|
somehow manages to gain access, they have full access to your repo. In
|
|
such situations choosing ``repokey`` over ``authenticated`` mode has
|
|
the advantage of allowing you to add a passphrase later using
|
|
:ref:`borg_key_change-passphrase`.
|
|
|
|
**About modes with encryption:**
|
|
|
|
With ``repokey`` and ``repokey-blake2`` modes the key is stored with
|
|
the repo and encrypted with your passphrase. If an attacker gains
|
|
access to your repo and knows the passphrase, he can access and tamper
|
|
with the repo. The repo's security thus relies on the strength of your
|
|
passphrase. Creating an offsite backup of your Borg key (e.g., by
|
|
printing it on paper) is recommended, see :ref:`borg_key_export`.
|
|
|
|
If you're thinking about storing the passphrase on the disk of the
|
|
system you're backing up, consider using the ``keyfile`` method
|
|
instead. It generally provides the same or better security then.
|
|
|
|
|
|
== general/environment.rst.inc:10-40 (BORG_PASSPHRASE, BORG_PASSCOMMAND)
|
|
When set, use the value to give the default repository location. If a command needs an archive
|
|
parameter, you can abbreviate as ``::archive``. If a command needs a repository parameter, you
|
|
can either leave it away or abbreviate as ``::``, if a positional parameter is required.
|
|
BORG_PASSPHRASE
|
|
When set, use the value to answer the passphrase question for encrypted repositories.
|
|
It is used when a passphrase is needed to access an encrypted repo as well as when a new
|
|
passphrase should be initially set when initializing an encrypted repo.
|
|
See also BORG_NEW_PASSPHRASE.
|
|
BORG_PASSCOMMAND
|
|
When set, use the standard output of the command (trailing newlines are stripped) to answer the
|
|
passphrase question for encrypted repositories.
|
|
It is used when a passphrase is needed to access an encrypted repo as well as when a new
|
|
passphrase should be initially set when initializing an encrypted repo. Note that the command
|
|
is executed without a shell. So variables, like ``$HOME`` will work, but ``~`` won't.
|
|
If BORG_PASSPHRASE is also set, it takes precedence.
|
|
See also BORG_NEW_PASSPHRASE.
|
|
BORG_PASSPHRASE_FD
|
|
When set, specifies a file descriptor to read a passphrase
|
|
from. Programs starting borg may choose to open an anonymous pipe
|
|
and use it to pass a passphrase. This is safer than passing via
|
|
BORG_PASSPHRASE, because on some systems (e.g. Linux) environment
|
|
can be examined by other processes.
|
|
If BORG_PASSPHRASE or BORG_PASSCOMMAND are also set, they take precedence.
|
|
BORG_NEW_PASSPHRASE
|
|
When set, use the value to answer the passphrase question when a **new** passphrase is asked for.
|
|
This variable is checked first. If it is not set, BORG_PASSPHRASE and BORG_PASSCOMMAND will also
|
|
be checked.
|
|
Main usecase for this is to fully automate ``borg key change-passphrase``.
|
|
BORG_DISPLAY_PASSPHRASE
|
|
When set, use the value to answer the "display the passphrase for verification" question when defining a new passphrase for encrypted repositories.
|
|
BORG_EXIT_CODES
|
|
|
|
== create.rst.inc (synopsis and options)
|
|
60: | | ``-e PATTERN``, ``--exclude PATTERN`` | exclude paths matching PATTERN |
|
|
68: | | ``--exclude-caches`` | exclude directories that contain a CACHEDIR.TAG file (http://www.bford.info/cachedir/spec.html) |
|
|
80: | | ``-x``, ``--one-file-system`` | stay in the same file system and do not store mount points of other file systems - this might behave different from your expectations, see the description below. |
|
|
120: | | ``-C COMPRESSION``, ``--compression COMPRESSION`` | select compression algorithm, see the output of the "borg help compression" command for details. |
|
|
161: -e PATTERN, --exclude PATTERN exclude paths matching PATTERN
|
|
165: --exclude-caches exclude directories that contain a CACHEDIR.TAG file (http://www.bford.info/cachedir/spec.html)
|
|
173: -x, --one-file-system stay in the same file system and do not store mount points of other file systems - this might behave different from your expectations, see the description below.
|
|
195: -C COMPRESSION, --compression COMPRESSION select compression algorithm, see the output of the "borg help compression" command for details.
|
|
224:{now}, {utcnow}, {fqdn}, {hostname}, {user} and some others.
|
|
306:The ``-x`` or ``--one-file-system`` option excludes directories that are mount points (and everything in them).
|
|
315:Therefore, when using ``--one-file-system``, you should double-check that the backup works as intended.
|
|
|
|
== prune.rst.inc:85-100
|
|
--quick-stats print only deletion statistics, skipping repository-wide statistics
|
|
--list output verbose list of archives it keeps/prunes
|
|
--keep-within INTERVAL keep all archives within this time interval
|
|
--keep-last, --keep-secondly number of secondly archives to keep
|
|
--keep-minutely number of minutely archives to keep
|
|
-H, --keep-hourly number of hourly archives to keep
|
|
-d, --keep-daily number of daily archives to keep
|
|
-w, --keep-weekly number of weekly archives to keep
|
|
-m, --keep-monthly number of monthly archives to keep
|
|
--keep-13weekly number of quarterly archives to keep (13 week strategy)
|
|
--keep-3monthly number of quarterly archives to keep (3 month strategy)
|
|
-y, --keep-yearly number of yearly archives to keep
|
|
--save-space work slower, but using less space
|
|
-c SECONDS, --checkpoint-interval SECONDS write checkpoint every SECONDS seconds (Default: 1800)
|
|
|
|
|
|
|
|
== compact.rst.inc (synopsis)
|
|
.. IMPORTANT: this file is auto-generated from borg's built-in help, do not edit!
|
|
.. _borg_compact:
|
|
borg compact
|
|
------------
|
|
.. code-block:: none
|
|
borg [common options] compact [options] [REPOSITORY]
|
|
.. only:: html
|
|
.. class:: borg-options-table
|
|
+-------------------------------------------------------+-------------------------+----------------------------------------------------------------+
|
|
| **positional arguments** |
|
|
+-------------------------------------------------------+-------------------------+----------------------------------------------------------------+
|
|
| | ``REPOSITORY`` | repository to compact |
|
|
|
|
== list.rst.inc:78-84 (--json)
|
|
--consider-checkpoints Show checkpoint archives in the repository contents list (default: hidden).
|
|
--short only print file/directory names, nothing else
|
|
--format FORMAT specify format for file or archive listing (default for files: "{mode} {user:6} {group:6} {size:8} {mtime} {path}{extra}{NL}"; for archives: "{archive:<36} {time} [{id}]{NL}")
|
|
--json Only valid for listing repository contents. Format output as JSON. The form of ``--format`` is ignored, but keys used in it are added to the JSON output. Some keys are always present. Note: JSON can only represent text. A "barchive" key is therefore not available.
|
|
--json-lines Only valid for listing archive contents. Format output as JSON Lines. The form of ``--format`` is ignored, but keys used in it are added to the JSON output. Some keys are always present. Note: JSON can only represent text. A "bpath" key is therefore not available.
|
|
|
|
|
|
|
|
== extract.rst.inc (synopsis)
|
|
9: borg [common options] extract [options] ARCHIVE [PATH...]
|
|
58: | | ``--strip-components NUMBER`` | Remove the specified number of leading path elements. Paths with fewer elements will be silently skipped. |
|
|
98: --strip-components NUMBER Remove the specified number of leading path elements. Paths with fewer elements will be silently skipped.
|
|
|
|
== prune.rst.inc:145-156 (a negative number keeps without limit)
|
|
As an example, ``--keep-daily 7`` means to keep the latest backup on each day,
|
|
up to 7 most recent days with backups (days without backups do not count).
|
|
The rules are applied from secondly to yearly, and backups selected by previous
|
|
rules do not count towards those of later rules. The time that each backup
|
|
starts is used for pruning purposes. Dates and times are interpreted in
|
|
the local time zone, and weeks go from Monday to Sunday. Specifying a
|
|
negative number of archives to keep means that there is no limit. As of Borg
|
|
1.2.0, Borg will retain the oldest archive if any of the secondly, minutely,
|
|
hourly, daily, weekly, monthly, quarterly, or yearly rules was not otherwise
|
|
able to meet its retention target. This enables the first chronological archive
|
|
to continue aging until it is replaced by a newer archive that meets the
|
|
retention criteria.
|
|
|
|
== help.rst.inc:290-306 (placeholders {hostname}, {now})
|
|
Repository (or Archive) URLs, ``--prefix``, ``--glob-archives``, ``--comment``
|
|
and ``--remote-path`` values support these placeholders:
|
|
|
|
{hostname}
|
|
The (short) hostname of the machine.
|
|
|
|
{fqdn}
|
|
The full name of the machine.
|
|
|
|
{reverse-fqdn}
|
|
The full name of the machine in reverse domain name notation.
|
|
|
|
{now}
|
|
The current local date and time, by default in ISO-8601 format.
|
|
You can also supply your own `format string <https://docs.python.org/3.10/library/datetime.html#strftime-and-strptime-behavior>`_, e.g. {now:%Y-%m-%d_%H:%M:%S}
|
|
|
|
{utcnow}
|