1
0
Fork 0
mirror of https://github.com/borgbackup/borg.git synced 2025-01-01 12:45:34 +00:00

Merge pull request #7514 from ThomasWaldmann/format-env-vars-master

implement BORG_<CMD>_FORMAT env vars, fixes #5166
This commit is contained in:
TW 2023-04-08 14:16:01 +02:00 committed by GitHub
commit e3352b1efc
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 14 additions and 3 deletions

View file

@ -104,6 +104,14 @@ General:
caused EROFS. You will need this to make archives from volume shadow copies
in WSL1 (Windows Subsystem for Linux 1).
Output formatting:
BORG_LIST_FORMAT
Giving the default value for ``borg list --format=X``.
BORG_RLIST_FORMAT
Giving the default value for ``borg rlist --format=X``.
BORG_PRUNE_FORMAT
Giving the default value for ``borg prune --format=X``.
Some automatic "answerers" (if set, they automatically answer confirmation questions):
BORG_UNKNOWN_UNENCRYPTED_REPO_ACCESS_IS_OK=no (or =yes)
For "Warning: Attempting to access a previously unknown unencrypted repository"

View file

@ -1,4 +1,5 @@
import argparse
import os
import textwrap
import sys
@ -24,7 +25,7 @@ def do_list(self, args, repository, manifest):
elif args.short:
format = "{path}{NL}"
else:
format = "{mode} {user:6} {group:6} {size:8} {mtime} {path}{extra}{NL}"
format = os.environ.get("BORG_LIST_FORMAT", "{mode} {user:6} {group:6} {size:8} {mtime} {path}{extra}{NL}")
def _list_inner(cache):
archive = Archive(manifest, args.name, cache=cache)

View file

@ -3,6 +3,7 @@
from datetime import datetime, timezone, timedelta
import logging
from operator import attrgetter
import os
import re
from ._common import with_repository, Highlander
@ -87,7 +88,7 @@ def do_prune(self, args, repository, manifest):
elif args.short:
format = "{archive}"
else:
format = "{archive:<36} {time} [{id}]"
format = os.environ.get("BORG_PRUNE_FORMAT", "{archive:<36} {time} [{id}]")
formatter = ArchiveFormatter(format, repository, manifest, manifest.key, json=False, iec=args.iec)
checkpoint_re = r"\.checkpoint(\.\d+)?"

View file

@ -1,4 +1,5 @@
import argparse
import os
import textwrap
import sys
@ -21,7 +22,7 @@ def do_rlist(self, args, repository, manifest):
elif args.short:
format = "{archive}{NL}"
else:
format = "{archive:<36} {time} [{id}]{NL}"
format = os.environ.get("BORG_RLIST_FORMAT", "{archive:<36} {time} [{id}]{NL}")
formatter = ArchiveFormatter(format, repository, manifest, manifest.key, json=args.json, iec=args.iec)
output_data = []