浏览代码

Merge pull request #1154 from hemio-ev/uuid-format-tags

Adds uuid to archive format tags
TW 9 年之前
父节点
当前提交
fa77e74908
共有 3 个文件被更改,包括 5 次插入3 次删除
  1. 1 1
      docs/usage/create.rst.inc
  2. 1 1
      src/borg/archiver.py
  3. 3 1
      src/borg/helpers.py

+ 1 - 1
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.
 checkpoints and treated in special ways.
 
 
 In the archive name, you may use the following format tags:
 In the archive name, you may use the following format tags:
-{now}, {utcnow}, {fqdn}, {hostname}, {user}, {pid}
+{now}, {utcnow}, {fqdn}, {hostname}, {user}, {pid}, {uuid4}
 
 
 To speed up pulling backups over sshfs and similar network file systems which do
 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
 not provide correct inode information the --ignore-inode flag can be used. This

+ 1 - 1
src/borg/archiver.py

@@ -1362,7 +1362,7 @@ class Archiver:
         checkpoints and treated in special ways.
         checkpoints and treated in special ways.
 
 
         In the archive name, you may use the following format tags:
         In the archive name, you may use the following format tags:
-        {now}, {utcnow}, {fqdn}, {hostname}, {user}, {pid}
+        {now}, {utcnow}, {fqdn}, {hostname}, {user}, {pid}, {uuid4}
 
 
         To speed up pulling backups over sshfs and similar network file systems which do
         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
         not provide correct inode information the --ignore-inode flag can be used. This

+ 3 - 1
src/borg/helpers.py

@@ -13,6 +13,7 @@ import stat
 import textwrap
 import textwrap
 import time
 import time
 import unicodedata
 import unicodedata
+import uuid
 from binascii import hexlify
 from binascii import hexlify
 from collections import namedtuple, deque
 from collections import namedtuple, deque
 from datetime import datetime, timezone, timedelta
 from datetime import datetime, timezone, timedelta
@@ -740,7 +741,8 @@ class Location:
             'hostname': socket.gethostname(),
             'hostname': socket.gethostname(),
             'now': current_time.now(),
             'now': current_time.now(),
             'utcnow': current_time.utcnow(),
             'utcnow': current_time.utcnow(),
-            'user': uid2user(os.getuid(), os.getuid())
+            'user': uid2user(os.getuid(), os.getuid()),
+            'uuid4': str(uuid.uuid4())
             }
             }
         return format_line(text, data)
         return format_line(text, data)