Skip to content

Commit

Permalink
prefix setting now passed to all borg commands that support it.
Browse files Browse the repository at this point in the history
refined documentation of archive and prefix settings.
  • Loading branch information
Ken Kundert authored and Ken Kundert committed Sep 23, 2019
1 parent 40eec43 commit 33d5e09
Show file tree
Hide file tree
Showing 3 changed files with 55 additions and 21 deletions.
16 changes: 0 additions & 16 deletions doc/configuring.rst
Original file line number Diff line number Diff line change
Expand Up @@ -98,22 +98,6 @@ or Emborg's program name ('prog_name'). An example of this is shown in both
In this way you gain access to *Borg* settings. *archive* shows and example of
that.

It is generally better to specify *prefix* rather than *archive*, though you can
specify both if you wish. If *archive* is not specified and *prefix* is, then
*archive* is created by adding '{{now}}' to *prefix*. If *archive* is specified
but *prefix* is not, then *archive* is used as given and *prefix* is not passed
to the *prune* command. In this case you should not have multiple configurations
backup into the same repository.

For example, if *prefix* is '{config_name}-' and *archive* is not given then
*archive* becomes '{config_name}-{{now}}'. If neither *archive* or *prefix* is
specified, then '{config_name}-{{now}}' is used for *archive* and
'{config_name}-' is used for *prefix*. One would specify both *archive* and
*prefix* when you wanted to use a different format for *now*. For example::

archive = '{config_name}-{{now:%Y%m%d}}'
prefix = '{config_name}-'


Includes
--------
Expand Down
58 changes: 54 additions & 4 deletions doc/installing.rst
Original file line number Diff line number Diff line change
Expand Up @@ -70,13 +70,63 @@ repository. For a local repository you would use something like this::

repository = '/mnt/backups/{host_name}-{user_name}-{config_name}'

This assumes that */mnt/backups* contains many independent respositories.
Borg allows you to make a single repository the target of multiple backup
configurations, and in this way you can further benefit from its ability to
de-duplicate files. In this case you might want to use a less granular name for
you respository.

**archive**
**archive** and **prefix**

A template that is used when creating the archive name. A typical value might
be::
*archive* is a template that specifies the name of each archive. A typical
value might be::

archive = '{host_name}-{{now}}'
archive = '{config_name}-{{now}}'

This template consists of a leading part that is fixed ('{config_name}-') and
a trailing part that varies on each archive ('{{now}}', which is replaced by
a datestamp). The leading fixed part is referred to as the *prefix* and can be
given separately::

archive = '{config_name}-{{now}}'
prefix = '{config_name}-'

This is helpful when multiple configurations backup to the same repository. In
this case *prefix* is assumed to be unique between the configurations. It allows
certain commands to filter out archives that belong to other configurations.
Specifically the *check*, *delete*, *info*, *list*, *mount*, and *prune*
commands all use *prefix*.

When sharing a repository between multiple backup configurations, it is
important that all prefixes be unique. Be careful of one prefix that is a prefix
of another. For example, prefixes of *root* and *root2* would be bad because
*root* is a prefix of *root2*. In the examples given, *prefix* ends with '-' to
reduce the risk that one prefix could be a prefix of another.

If you do not specify either *archive* or *prefix*, they you get the following
defaults::

archive = '{config_name}-{{now}}'
prefix = '{config_name}-'

If you only specify *prefix*, then *archive* becomes::

archive = '<prefix>{{now}}'

If you only specify *archive*, then *prefix* remains unset. This is only
suitable when there is only one backup configuration using a repository.

If you want *prefix* and want to customize *now*, you should give both *prefix*
and *archive*. For example, you can reduce the length of the timestamp using::

archive = '{host_name}-{{now:%Y%m%d}}'
prefix = '{host_name}-'

In this example the host name was used as the prefix rather than the
configuration name. When specifying both the *prefix* and the *archive*, the
leading part of *archive* should match *prefix*. Be aware that by including
only the date in the archive name rather than the full timestamp, you are
limiting yourself to one archive per day.


**encryption**
Expand Down
2 changes: 1 addition & 1 deletion emborg/preferences.py
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,7 @@
desc = 'set umask to M (local and remote, default: 0077)'
),
prefix = dict(
cmds = 'prune',
cmds = 'check delete info list mount prune',
arg = 'PREFIX',
desc = 'only consider archive names starting with this prefix'
),
Expand Down

0 comments on commit 33d5e09

Please sign in to comment.