Repository: borgbackup/borg

Issue:
Allow use of {hostname} keyword in --glob-archives
<!--
Thank you for reporting an issue.

*IMPORTANT* -  *before* creating a new issue please look around:
 - Borgbackup documentation: http://borgbackup.readthedocs.io/en/stable/index.html
 - FAQ: https://borgbackup.readthedocs.io/en/stable/faq.html
 and
 - open issues in Github tracker: https://github.com/borgbackup/borg/issues
  
If you cannot find a similar problem, then create a new issue.

Please fill in as much of the template as possible.
-->

## Have you checked borgbackup docs, FAQ, and open Github issues?

Yes

## Is this a BUG / ISSUE report or a QUESTION?

Issue

(I would call it feature request, but that's not in my choices)

## System information. For client/server mode post info for both machines.
Ubuntu 18.04 4.15.0-46-generic #49-Ubuntu
#### Your borg version (borg -V).
borg 1.1.9

#### Operating system (distribution) and version.
um. Wasn't that "System information". If not... what was that?
#### Hardware / network configuration, and filesystems used.
AMD processor, local, single-machine backup, ZFS on the host, the target device is JFS.
#### How much data is handled by borg?
I *think* this is what you want?
```
bick-ubtu3 ~$ sudo -E borg info 
Repository ID: 50f08d75819b77b854c41d4f4e124806fc13835c0692a0a354bfdc44fde44a28
Location: /mnt/backup/borgbackup
Encrypted: Yes (repokey BLAKE2b)
Cache: /root/.cache/50f08d75819b77b854c41d4f4e124806fc13835c0692a0a354bfdc44fde44a28
Security dir: /root/.config/borg/security/50f08d75819b77b854c41d4f4e124806fc13835c0692a0a354bfdc44fde44a28
------------------------------------------------------------------------------
                       Original size      Compressed size    Deduplicated size
All archives:                3.24 TB              2.86 TB            391.18 GB

                       Unique chunks         Total chunks
Chunk index:                  371591              2704249
```
#### Full borg commandline that lead to the problem (leave away excludes and passwords)
No problem here. Just a wish.

## Describe the problem you're observing.
So if you use `--prefix` with `borg prune`, you get access to some nice keywords, especially `{hostname}`. It would be nice to have those available for the `--glob-archives` option, as well.
#### Can you reproduce the problem? If so, describe how. If not, describe troubleshooting steps you took before opening the issue.
Again... not a problem.
#### Include any warning/errors/backtraces from the system logs
I'm feeling redundant.
<!--

If this complaint relates to borg performance, please include CRUD benchmark
results and any steps you took to troubleshoot.
How to run benchmark: http://borgbackup.readthedocs.io/en/stable/usage/benchmark.html

*IMPORTANT* - Please mark logs and text output from terminal commands 
or else Github will not display them correctly. 
An example is provided below.

Example:
```
this is an example how log text should be marked (wrap it with ```)
```
-->



Discussion:
Yup, good idea.

Resolving patch:
diff --git a/src/borg/archiver.py b/src/borg/archiver.py
--- a/src/borg/archiver.py
+++ b/src/borg/archiver.py
@@ -47,7 +47,7 @@
     from .helpers import EXIT_SUCCESS, EXIT_WARNING, EXIT_ERROR
     from .helpers import Error, NoManifestError, set_ec
     from .helpers import positive_int_validator, location_validator, archivename_validator, ChunkerParams, Location
-    from .helpers import PrefixSpec, SortBySpec, FilesCacheMode
+    from .helpers import PrefixSpec, GlobSpec, SortBySpec, FilesCacheMode
     from .helpers import BaseFormatter, ItemFormatter, ArchiveFormatter
     from .helpers import format_timedelta, format_file_size, parse_file_size, format_archive
     from .helpers import safe_encode, remove_surrogates, bin_to_hex, prepare_dump_dict
@@ -2180,8 +2180,8 @@ def do_break_lock(self, args, repository):
                 # don't backup the other home directories
                 - /home/*\n\n''')
     helptext['placeholders'] = textwrap.dedent('''
-        Repository (or Archive) URLs, ``--prefix`` and ``--remote-path`` values support these
-        placeholders:
+        Repository (or Archive) URLs, ``--prefix``, ``--glob-archives`` and ``--remote-path``
+        values support these placeholders:
 
         {hostname}
             The (short) hostname of the machine.
@@ -2568,7 +2568,8 @@ def define_archive_filters_group(subparser, *, sort_by=True, first_last=True):
             group = filters_group.add_mutually_exclusive_group()
             group.add_argument('-P', '--prefix', metavar='PREFIX', dest='prefix', type=PrefixSpec, default='',
                                help='only consider archive names starting with this prefix.')
-            group.add_argument('-a', '--glob-archives', metavar='GLOB', dest='glob_archives', default=None,
+            group.add_argument('-a', '--glob-archives', metavar='GLOB', dest='glob_archives',
+                               type=GlobSpec, default=None,
                                help='only consider archive names matching the glob. '
                                     'sh: rules apply, see "borg help patterns". '
                                     '``--prefix`` and ``--glob-archives`` are mutually exclusive.')
diff --git a/src/borg/helpers/parseformat.py b/src/borg/helpers/parseformat.py
--- a/src/borg/helpers/parseformat.py
+++ b/src/borg/helpers/parseformat.py
@@ -225,6 +225,8 @@ def replace_placeholders(text):
 
 PrefixSpec = replace_placeholders
 
+GlobSpec = replace_placeholders
+
 
 def SortBySpec(text):
     from .manifest import AI_HUMAN_SORT_KEYS


Test patch: