1
0
Fork 0
mirror of https://github.com/borgbackup/borg.git synced 2025-01-31 03:31:41 +00:00

Merge pull request #242 from ThomasWaldmann/delete-cache-only

implement borg delete --cache-only repo, attic #123
This commit is contained in:
TW 2015-10-03 19:46:51 +02:00
commit 4474db31d4

View file

@ -319,17 +319,19 @@ def do_delete(self, args):
if args.stats: if args.stats:
stats.print_('Deleted data:', cache) stats.print_('Deleted data:', cache)
else: else:
print("You requested to completely DELETE the repository *including* all archives it contains:") if not args.cache_only:
for archive_info in manifest.list_archive_infos(sort_by='ts'): print("You requested to completely DELETE the repository *including* all archives it contains:")
print(format_archive(archive_info)) for archive_info in manifest.list_archive_infos(sort_by='ts'):
if not os.environ.get('BORG_CHECK_I_KNOW_WHAT_I_AM_DOING'): print(format_archive(archive_info))
print("""Type "YES" if you understand this and want to continue.\n""") if not os.environ.get('BORG_CHECK_I_KNOW_WHAT_I_AM_DOING'):
if input('Do you want to continue? ') != 'YES': print("""Type "YES" if you understand this and want to continue.\n""")
self.exit_code = 1 if input('Do you want to continue? ') != 'YES':
return self.exit_code self.exit_code = 1
repository.destroy() return self.exit_code
repository.destroy()
print("Repository deleted.")
cache.destroy() cache.destroy()
print("Repository and corresponding cache were deleted.") print("Cache deleted.")
return self.exit_code return self.exit_code
def do_mount(self, args): def do_mount(self, args):
@ -811,6 +813,9 @@ def run(self, args=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('-c', '--cache-only', dest='cache_only',
action='store_true', default=False,
help='delete only the local cache for the given repository')
subparser.add_argument('target', metavar='TARGET', nargs='?', default='', subparser.add_argument('target', metavar='TARGET', nargs='?', default='',
type=location_validator(), type=location_validator(),
help='archive or repository to delete') help='archive or repository to delete')