From 63ce9992298792c94cf65bbda37bed15d1092af9 Mon Sep 17 00:00:00 2001 From: Thomas Waldmann Date: Thu, 18 Feb 2016 23:44:23 +0100 Subject: [PATCH] borg prune -v --list enables the keep/prune list output, fixes #658 so one can also have --stats without that. --- borg/archiver.py | 12 +++++++++--- borg/testsuite/archiver.py | 6 +++--- 2 files changed, 12 insertions(+), 6 deletions(-) diff --git a/borg/archiver.py b/borg/archiver.py index 910814c46..ee1ee32b3 100644 --- a/borg/archiver.py +++ b/borg/archiver.py @@ -528,12 +528,15 @@ class Archiver: stats = Statistics() with Cache(repository, key, manifest, do_files=args.cache_files, lock_wait=self.lock_wait) as cache: for archive in keep: - logger.info('Keeping archive: %s' % format_archive(archive)) + if args.output_list: + logger.info('Keeping archive: %s' % format_archive(archive)) for archive in to_delete: if args.dry_run: - logger.info('Would prune: %s' % format_archive(archive)) + if args.output_list: + logger.info('Would prune: %s' % format_archive(archive)) else: - logger.info('Pruning archive: %s' % format_archive(archive)) + if args.output_list: + logger.info('Pruning archive: %s' % format_archive(archive)) Archive(repository, key, manifest, archive.name, cache).delete(stats) if to_delete and not args.dry_run: manifest.write() @@ -1184,6 +1187,9 @@ class Archiver: subparser.add_argument('-s', '--stats', dest='stats', action='store_true', default=False, help='print statistics for the deleted archive') + subparser.add_argument('--list', dest='output_list', + action='store_true', default=False, + help='output verbose list of archives it keeps/prunes') subparser.add_argument('--keep-within', dest='within', type=str, metavar='WITHIN', help='keep all archives within this time interval') subparser.add_argument('-H', '--keep-hourly', dest='hourly', type=int, default=0, diff --git a/borg/testsuite/archiver.py b/borg/testsuite/archiver.py index d9eede408..73a267562 100644 --- a/borg/testsuite/archiver.py +++ b/borg/testsuite/archiver.py @@ -835,7 +835,7 @@ class ArchiverTestCase(ArchiverTestCaseBase): self.cmd('init', self.repository_location) self.cmd('create', self.repository_location + '::test1', src_dir) self.cmd('create', self.repository_location + '::test2', src_dir) - output = self.cmd('prune', '-v', '--dry-run', self.repository_location, '--keep-daily=2') + output = self.cmd('prune', '-v', '--list', '--dry-run', self.repository_location, '--keep-daily=2') self.assert_in('Keeping archive: test2', output) self.assert_in('Would prune: test1', output) output = self.cmd('list', self.repository_location) @@ -850,7 +850,7 @@ class ArchiverTestCase(ArchiverTestCaseBase): self.cmd('init', self.repository_location) self.cmd('create', self.repository_location + '::test1', src_dir) self.cmd('create', self.repository_location + '::test2', src_dir) - output = self.cmd('prune', '-v', '--dry-run', self.repository_location, '--keep-daily=2') + output = self.cmd('prune', '-v', '--list', '--dry-run', self.repository_location, '--keep-daily=2') self.assert_in('Keeping archive: test2', output) self.assert_in('Would prune: test1', output) output = self.cmd('list', self.repository_location) @@ -867,7 +867,7 @@ class ArchiverTestCase(ArchiverTestCaseBase): self.cmd('create', self.repository_location + '::foo-2015-08-12-20:00', src_dir) self.cmd('create', self.repository_location + '::bar-2015-08-12-10:00', src_dir) self.cmd('create', self.repository_location + '::bar-2015-08-12-20:00', src_dir) - output = self.cmd('prune', '-v', '--dry-run', self.repository_location, '--keep-daily=2', '--prefix=foo-') + output = self.cmd('prune', '-v', '--list', '--dry-run', self.repository_location, '--keep-daily=2', '--prefix=foo-') self.assert_in('Keeping archive: foo-2015-08-12-20:00', output) self.assert_in('Would prune: foo-2015-08-12-10:00', output) output = self.cmd('list', self.repository_location)