mirror of
https://github.com/borgbackup/borg.git
synced 2024-12-25 17:27:31 +00:00
add --list option for borg create
like --stats enables statistics output, --list enables the file/dirs list output.
This commit is contained in:
parent
fa054d0f2e
commit
96f88a29d2
2 changed files with 9 additions and 5 deletions
|
@ -80,7 +80,7 @@ def print_warning(self, msg, *args):
|
||||||
logger.warning(msg)
|
logger.warning(msg)
|
||||||
|
|
||||||
def print_file_status(self, status, path):
|
def print_file_status(self, status, path):
|
||||||
if self.output_filter is None or status in self.output_filter:
|
if self.output_list and (self.output_filter is None or status in self.output_filter):
|
||||||
logger.info("%1s %s", status, remove_surrogates(path))
|
logger.info("%1s %s", status, remove_surrogates(path))
|
||||||
|
|
||||||
def do_serve(self, args):
|
def do_serve(self, args):
|
||||||
|
@ -129,6 +129,7 @@ def do_change_passphrase(self, args):
|
||||||
def do_create(self, args):
|
def do_create(self, args):
|
||||||
"""Create new archive"""
|
"""Create new archive"""
|
||||||
self.output_filter = args.output_filter
|
self.output_filter = args.output_filter
|
||||||
|
self.output_list = args.output_list
|
||||||
dry_run = args.dry_run
|
dry_run = args.dry_run
|
||||||
t0 = datetime.now()
|
t0 = datetime.now()
|
||||||
if not dry_run:
|
if not dry_run:
|
||||||
|
@ -858,6 +859,9 @@ def build_parser(self, args=None, prog=None):
|
||||||
help="""show progress display while creating the archive, showing Original,
|
help="""show progress display while creating the archive, showing Original,
|
||||||
Compressed and Deduplicated sizes, followed by the Number of files seen
|
Compressed and Deduplicated sizes, followed by the Number of files seen
|
||||||
and the path being processed, default: %(default)s""")
|
and the path being processed, default: %(default)s""")
|
||||||
|
subparser.add_argument('--list', dest='output_list',
|
||||||
|
action='store_true', default=False,
|
||||||
|
help='output verbose list of items (files, dirs, ...)')
|
||||||
subparser.add_argument('--filter', dest='output_filter', metavar='STATUSCHARS',
|
subparser.add_argument('--filter', dest='output_filter', metavar='STATUSCHARS',
|
||||||
help='only display items with the given status characters')
|
help='only display items with the given status characters')
|
||||||
subparser.add_argument('-e', '--exclude', dest='excludes',
|
subparser.add_argument('-e', '--exclude', dest='excludes',
|
||||||
|
|
|
@ -762,11 +762,11 @@ def test_file_status(self):
|
||||||
os.utime('input/file1', (now - 5, now - 5)) # 5 seconds ago
|
os.utime('input/file1', (now - 5, now - 5)) # 5 seconds ago
|
||||||
self.create_regular_file('file2', size=1024 * 80)
|
self.create_regular_file('file2', size=1024 * 80)
|
||||||
self.cmd('init', self.repository_location)
|
self.cmd('init', self.repository_location)
|
||||||
output = self.cmd('create', '-v', self.repository_location + '::test', 'input')
|
output = self.cmd('create', '-v', '--list', self.repository_location + '::test', 'input')
|
||||||
self.assert_in("A input/file1", output)
|
self.assert_in("A input/file1", output)
|
||||||
self.assert_in("A input/file2", output)
|
self.assert_in("A input/file2", output)
|
||||||
# should find first file as unmodified
|
# should find first file as unmodified
|
||||||
output = self.cmd('create', '-v', self.repository_location + '::test1', 'input')
|
output = self.cmd('create', '-v', '--list', self.repository_location + '::test1', 'input')
|
||||||
self.assert_in("U input/file1", output)
|
self.assert_in("U input/file1", output)
|
||||||
# this is expected, although surprising, for why, see:
|
# this is expected, although surprising, for why, see:
|
||||||
# http://borgbackup.readthedocs.org/en/latest/faq.html#i-am-seeing-a-added-status-for-a-unchanged-file
|
# http://borgbackup.readthedocs.org/en/latest/faq.html#i-am-seeing-a-added-status-for-a-unchanged-file
|
||||||
|
@ -785,7 +785,7 @@ def test_create_topical(self):
|
||||||
output = self.cmd('create', self.repository_location + '::test0', 'input')
|
output = self.cmd('create', self.repository_location + '::test0', 'input')
|
||||||
self.assert_not_in('file1', output)
|
self.assert_not_in('file1', output)
|
||||||
# should list the file as unchanged
|
# should list the file as unchanged
|
||||||
output = self.cmd('create', '-v', '--filter=U', self.repository_location + '::test1', 'input')
|
output = self.cmd('create', '-v', '--list', '--filter=U', self.repository_location + '::test1', 'input')
|
||||||
self.assert_in('file1', output)
|
self.assert_in('file1', output)
|
||||||
# should *not* list the file as changed
|
# should *not* list the file as changed
|
||||||
output = self.cmd('create', '-v', '--filter=AM', self.repository_location + '::test2', 'input')
|
output = self.cmd('create', '-v', '--filter=AM', self.repository_location + '::test2', 'input')
|
||||||
|
@ -793,7 +793,7 @@ def test_create_topical(self):
|
||||||
# change the file
|
# change the file
|
||||||
self.create_regular_file('file1', size=1024 * 100)
|
self.create_regular_file('file1', size=1024 * 100)
|
||||||
# should list the file as changed
|
# should list the file as changed
|
||||||
output = self.cmd('create', '-v', '--filter=AM', self.repository_location + '::test3', 'input')
|
output = self.cmd('create', '-v', '--list', '--filter=AM', self.repository_location + '::test3', 'input')
|
||||||
self.assert_in('file1', output)
|
self.assert_in('file1', output)
|
||||||
|
|
||||||
def test_cmdline_compatibility(self):
|
def test_cmdline_compatibility(self):
|
||||||
|
|
Loading…
Reference in a new issue