From 5ae340998c85c14c8b8787569bd51441727d498d Mon Sep 17 00:00:00 2001 From: Thomas Waldmann Date: Wed, 22 Jun 2016 00:31:31 +0200 Subject: [PATCH] update docs about placeholders --- borg/archiver.py | 34 ++++++++++++++++++++++++++++++++++ docs/quickstart.rst | 6 +++--- docs/usage.rst | 5 +++-- 3 files changed, 40 insertions(+), 5 deletions(-) diff --git a/borg/archiver.py b/borg/archiver.py index ef49e8581..169e8bcb0 100644 --- a/borg/archiver.py +++ b/borg/archiver.py @@ -803,6 +803,39 @@ class Archiver: EOF $ borg create --exclude-from exclude.txt backup / ''') + helptext['placeholders'] = textwrap.dedent(''' + Repository (or Archive) URLs and --prefix values support these placeholders: + + {hostname} + + The (short) hostname of the machine. + + {fqdn} + + The full name of the machine. + + {now} + + The current local date and time. + + {utcnow} + + The current UTC date and time. + + {user} + + The user name (or UID, if no name is available) of the user running borg. + + {pid} + + The current process ID. + + Examples:: + + borg create /path/to/repo::{hostname}-{user}-{utcnow} ... + borg create /path/to/repo::{hostname}-{now:%Y-%m-%d_%H:%M:%S} ... + borg prune --prefix '{hostname}-' ... + ''') def do_help(self, parser, commands, args): if not args.topic: @@ -1013,6 +1046,7 @@ class Archiver: all files on these file systems. See the output of the "borg help patterns" command for more help on exclude patterns. + See the output of the "borg help placeholders" command for more help on placeholders. """) subparser = subparsers.add_parser('create', parents=[common_parser], diff --git a/docs/quickstart.rst b/docs/quickstart.rst index 1d15f5d23..81d358d4c 100644 --- a/docs/quickstart.rst +++ b/docs/quickstart.rst @@ -110,7 +110,7 @@ certain number of old archives:: # Backup all of /home and /var/www except a few # excluded directories borg create -v --stats \ - $REPOSITORY::`hostname`-`date +%Y-%m-%d` \ + $REPOSITORY::'{hostname}-{now:%Y-%m-%d}' \ /home \ /var/www \ --exclude '/home/*/.cache' \ @@ -118,10 +118,10 @@ certain number of old archives:: --exclude '*.pyc' # Use the `prune` subcommand to maintain 7 daily, 4 weekly and 6 monthly - # archives of THIS machine. --prefix `hostname`- is very important to + # archives of THIS machine. The '{hostname}-' prefix is very important to # limit prune's operation to this machine's archives and not apply to # other machine's archives also. - borg prune -v $REPOSITORY --prefix `hostname`- \ + borg prune -v $REPOSITORY --prefix '{hostname}-' \ --keep-daily=7 --keep-weekly=4 --keep-monthly=6 .. backup_compression: diff --git a/docs/usage.rst b/docs/usage.rst index 258f9a1aa..acca302ac 100644 --- a/docs/usage.rst +++ b/docs/usage.rst @@ -425,8 +425,9 @@ will see what it would do without it actually doing anything. # Do a dry-run without actually deleting anything. $ borg prune --dry-run --keep-daily=7 --keep-weekly=4 /path/to/repo - # Same as above but only apply to archive names starting with "foo": - $ borg prune --keep-daily=7 --keep-weekly=4 --prefix=foo /path/to/repo + # Same as above but only apply to archive names starting with the hostname + # of the machine followed by a "-" character: + $ borg prune --keep-daily=7 --keep-weekly=4 --prefix='{hostname}-' /path/to/repo # Keep 7 end of day, 4 additional end of week archives, # and an end of month archive for every month: