Browse Source

Fix for database dump removal incorrectly skipping some database dumps.

tags/1.4.15
Dan Helfman 11 months ago
parent
commit
d978a2d190
3 changed files with 16 additions and 11 deletions
  1. +1
    -0
      NEWS
  2. +3
    -3
      borgmatic/hooks/dump.py
  3. +12
    -8
      tests/unit/hooks/test_dump.py

+ 1
- 0
NEWS View File

@@ -1,4 +1,5 @@
1.4.15
* Fix for database dump removal incorrectly skipping some database dumps.
* #123: Support for mounting an archive as a FUSE filesystem via "borgmatic mount" action, and
unmounting via "borgmatic umount". See the documentation for more information:
https://torsion.org/borgmatic/docs/how-to/extract-a-backup/#mount-a-filesystem


+ 3
- 3
borgmatic/hooks/dump.py View File

@@ -71,10 +71,10 @@ def remove_database_dumps(dump_path, databases, database_type_name, log_prefix,
continue

os.remove(dump_filename)
dump_path = os.path.dirname(dump_filename)
dump_file_dir = os.path.dirname(dump_filename)

if len(os.listdir(dump_path)) == 0:
os.rmdir(dump_path)
if len(os.listdir(dump_file_dir)) == 0:
os.rmdir(dump_file_dir)


def convert_glob_patterns_to_borg_patterns(patterns):


+ 12
- 8
tests/unit/hooks/test_dump.py View File

@@ -51,16 +51,20 @@ def test_flatten_dump_patterns_with_no_hooks_errors():

def test_remove_database_dumps_removes_dump_for_each_database():
databases = [{'name': 'foo'}, {'name': 'bar'}]
flexmock(module).should_receive('make_database_dump_filename').and_return(
'databases/localhost/foo'
flexmock(module).should_receive('make_database_dump_filename').with_args(
'databases', 'foo', None
).and_return('databases/localhost/foo')
flexmock(module).should_receive('make_database_dump_filename').with_args(
'databases', 'bar', None
).and_return('databases/localhost/bar')
flexmock(module.os).should_receive('listdir').and_return([])
flexmock(module.os).should_receive('rmdir')

for name in ('foo', 'bar'):
flexmock(module.os).should_receive('remove').with_args(
'databases/localhost/{}'.format(name)
).once()
flexmock(module.os).should_receive('remove').with_args('databases/localhost/foo').once()
flexmock(module.os).should_receive('remove').with_args('databases/localhost/bar').once()
flexmock(module.os).should_receive('listdir').with_args('databases/localhost').and_return(
['bar']
).and_return([])

flexmock(module.os).should_receive('rmdir').with_args('databases/localhost').once()

module.remove_database_dumps('databases', databases, 'SuperDB', 'test.yaml', dry_run=False)



Loading…
Cancel
Save