mirror of
https://github.com/borgbackup/borg.git
synced 2024-12-25 01:06:50 +00:00
Merge pull request #1912 from Abogical/prune-progress
Add prune progress display
This commit is contained in:
commit
a4eef67e3b
1 changed files with 12 additions and 2 deletions
|
@ -1040,6 +1040,10 @@ def do_prune(self, args, repository, manifest, key):
|
||||||
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:
|
||||||
list_logger = logging.getLogger('borg.output.list')
|
list_logger = logging.getLogger('borg.output.list')
|
||||||
|
if args.output_list:
|
||||||
|
# set up counters for the progress display
|
||||||
|
to_delete_len = len(to_delete)
|
||||||
|
archives_deleted = 0
|
||||||
for archive in archives_checkpoints:
|
for archive in archives_checkpoints:
|
||||||
if archive in to_delete:
|
if archive in to_delete:
|
||||||
if args.dry_run:
|
if args.dry_run:
|
||||||
|
@ -1047,8 +1051,11 @@ def do_prune(self, args, repository, manifest, key):
|
||||||
list_logger.info('Would prune: %s' % format_archive(archive))
|
list_logger.info('Would prune: %s' % format_archive(archive))
|
||||||
else:
|
else:
|
||||||
if args.output_list:
|
if args.output_list:
|
||||||
list_logger.info('Pruning archive: %s' % format_archive(archive))
|
archives_deleted += 1
|
||||||
Archive(repository, key, manifest, archive.name, cache).delete(stats, forced=args.forced)
|
list_logger.info('Pruning archive: %s (%d/%d)' % (format_archive(archive),
|
||||||
|
archives_deleted, to_delete_len))
|
||||||
|
Archive(repository, key, manifest, archive.name, cache,
|
||||||
|
progress=args.progress).delete(stats, forced=args.forced)
|
||||||
else:
|
else:
|
||||||
if args.output_list:
|
if args.output_list:
|
||||||
list_logger.info('Keeping archive: %s' % format_archive(archive))
|
list_logger.info('Keeping archive: %s' % format_archive(archive))
|
||||||
|
@ -2324,6 +2331,9 @@ def build_parser(self, prog=None):
|
||||||
subparser.add_argument('--force', dest='forced',
|
subparser.add_argument('--force', dest='forced',
|
||||||
action='store_true', default=False,
|
action='store_true', default=False,
|
||||||
help='force pruning of corrupted archives')
|
help='force pruning of corrupted archives')
|
||||||
|
subparser.add_argument('-p', '--progress', dest='progress',
|
||||||
|
action='store_true', default=False,
|
||||||
|
help='show progress display while deleting archives')
|
||||||
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')
|
||||||
|
|
Loading…
Reference in a new issue