From 5aa97e283c98d6ecb14c35fcb32a3b566ddccbcd Mon Sep 17 00:00:00 2001 From: Michael Herold Date: Sat, 11 Jun 2016 12:03:55 +0200 Subject: [PATCH] Adds uuid to archive format tags --- docs/usage/create.rst.inc | 2 +- src/borg/archiver.py | 2 +- src/borg/helpers.py | 4 +++- 3 files changed, 5 insertions(+), 3 deletions(-) diff --git a/docs/usage/create.rst.inc b/docs/usage/create.rst.inc index 5c03c6365..6b50d9af2 100644 --- a/docs/usage/create.rst.inc +++ b/docs/usage/create.rst.inc @@ -79,7 +79,7 @@ The archive name needs to be unique. It must not end in '.checkpoint' or checkpoints and treated in special ways. In the archive name, you may use the following format tags: -{now}, {utcnow}, {fqdn}, {hostname}, {user}, {pid} +{now}, {utcnow}, {fqdn}, {hostname}, {user}, {pid}, {uuid} To speed up pulling backups over sshfs and similar network file systems which do not provide correct inode information the --ignore-inode flag can be used. This diff --git a/src/borg/archiver.py b/src/borg/archiver.py index 89ebc76bf..9450ef6a1 100644 --- a/src/borg/archiver.py +++ b/src/borg/archiver.py @@ -1362,7 +1362,7 @@ class Archiver: checkpoints and treated in special ways. In the archive name, you may use the following format tags: - {now}, {utcnow}, {fqdn}, {hostname}, {user}, {pid} + {now}, {utcnow}, {fqdn}, {hostname}, {user}, {pid}, {uuid} To speed up pulling backups over sshfs and similar network file systems which do not provide correct inode information the --ignore-inode flag can be used. This diff --git a/src/borg/helpers.py b/src/borg/helpers.py index 0008fc5bc..54183ef8e 100644 --- a/src/borg/helpers.py +++ b/src/borg/helpers.py @@ -13,6 +13,7 @@ import stat import textwrap import time import unicodedata +import uuid from binascii import hexlify from collections import namedtuple, deque from datetime import datetime, timezone, timedelta @@ -740,7 +741,8 @@ class Location: 'hostname': socket.gethostname(), 'now': current_time.now(), 'utcnow': current_time.utcnow(), - 'user': uid2user(os.getuid(), os.getuid()) + 'user': uid2user(os.getuid(), os.getuid()), + 'uuid': str(uuid.uuid4()) } return format_line(text, data)