mirror of
https://github.com/borgbackup/borg.git
synced 2025-02-24 23:13:25 +00:00
Merge pull request #679 from ThomasWaldmann/prune--list
borg prune -v --list enables the keep/prune list output, fixes #658
This commit is contained in:
commit
6ff78cfb71
2 changed files with 12 additions and 6 deletions
|
@ -528,12 +528,15 @@ def do_prune(self, args):
|
||||||
stats = Statistics()
|
stats = Statistics()
|
||||||
with Cache(repository, key, manifest, do_files=args.cache_files, lock_wait=self.lock_wait) as cache:
|
with Cache(repository, key, manifest, do_files=args.cache_files, lock_wait=self.lock_wait) as cache:
|
||||||
for archive in keep:
|
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:
|
for archive in to_delete:
|
||||||
if args.dry_run:
|
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:
|
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)
|
Archive(repository, key, manifest, archive.name, cache).delete(stats)
|
||||||
if to_delete and not args.dry_run:
|
if to_delete and not args.dry_run:
|
||||||
manifest.write()
|
manifest.write()
|
||||||
|
@ -1184,6 +1187,9 @@ def build_parser(self, args=None, prog=None):
|
||||||
subparser.add_argument('-s', '--stats', dest='stats',
|
subparser.add_argument('-s', '--stats', dest='stats',
|
||||||
action='store_true', default=False,
|
action='store_true', default=False,
|
||||||
help='print statistics for the deleted archive')
|
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',
|
subparser.add_argument('--keep-within', dest='within', type=str, metavar='WITHIN',
|
||||||
help='keep all archives within this time interval')
|
help='keep all archives within this time interval')
|
||||||
subparser.add_argument('-H', '--keep-hourly', dest='hourly', type=int, default=0,
|
subparser.add_argument('-H', '--keep-hourly', dest='hourly', type=int, default=0,
|
||||||
|
|
|
@ -835,7 +835,7 @@ def test_prune_repository(self):
|
||||||
self.cmd('init', self.repository_location)
|
self.cmd('init', self.repository_location)
|
||||||
self.cmd('create', self.repository_location + '::test1', src_dir)
|
self.cmd('create', self.repository_location + '::test1', src_dir)
|
||||||
self.cmd('create', self.repository_location + '::test2', 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('Keeping archive: test2', output)
|
||||||
self.assert_in('Would prune: test1', output)
|
self.assert_in('Would prune: test1', output)
|
||||||
output = self.cmd('list', self.repository_location)
|
output = self.cmd('list', self.repository_location)
|
||||||
|
@ -850,7 +850,7 @@ def test_prune_repository_save_space(self):
|
||||||
self.cmd('init', self.repository_location)
|
self.cmd('init', self.repository_location)
|
||||||
self.cmd('create', self.repository_location + '::test1', src_dir)
|
self.cmd('create', self.repository_location + '::test1', src_dir)
|
||||||
self.cmd('create', self.repository_location + '::test2', 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('Keeping archive: test2', output)
|
||||||
self.assert_in('Would prune: test1', output)
|
self.assert_in('Would prune: test1', output)
|
||||||
output = self.cmd('list', self.repository_location)
|
output = self.cmd('list', self.repository_location)
|
||||||
|
@ -867,7 +867,7 @@ def test_prune_repository_prefix(self):
|
||||||
self.cmd('create', self.repository_location + '::foo-2015-08-12-20:00', src_dir)
|
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-10:00', src_dir)
|
||||||
self.cmd('create', self.repository_location + '::bar-2015-08-12-20: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('Keeping archive: foo-2015-08-12-20:00', output)
|
||||||
self.assert_in('Would prune: foo-2015-08-12-10:00', output)
|
self.assert_in('Would prune: foo-2015-08-12-10:00', output)
|
||||||
output = self.cmd('list', self.repository_location)
|
output = self.cmd('list', self.repository_location)
|
||||||
|
|
Loading…
Reference in a new issue