Commit f3af8536 authored by Tres Seaver's avatar Tres Seaver

repozo: Remove '.index' + files corresponding to backups being removed.

parent da54ebd6
...@@ -8,6 +8,9 @@ ...@@ -8,6 +8,9 @@
Bugs fixed Bugs fixed
---------- ----------
- Updated the 'repozo --kill-old-on-full' option to remove any '.index'
files corresponding to backups being removed.
- When objects were added in savepoints and either the savepoint was - When objects were added in savepoints and either the savepoint was
rolled back (https://bugs.launchpad.net/zodb/+bug/143560) or the rolled back (https://bugs.launchpad.net/zodb/+bug/143560) or the
transaction was aborted transaction was aborted
...@@ -204,7 +207,7 @@ New Features ...@@ -204,7 +207,7 @@ New Features
iterator implementations should just raise StopIteration, which iterator implementations should just raise StopIteration, which
means they can now be implemented as generators. means they can now be implemented as generators.
- The file-storage backup script, repoze, will now create a backup - The file-storage backup script, repozo, will now create a backup
index file if an output file name is given via the --output/-o index file if an output file name is given via the --output/-o
option. option.
...@@ -225,9 +228,10 @@ Bugs Fixed ...@@ -225,9 +228,10 @@ Bugs Fixed
New Features New Features
------------ ------------
- Added a '--kill-old-on-full' argument to the backup options: if passed, - Added a '--kill-old-on-full' argument to the repozo backup options:
remove any older full or incremental backup files from the repository after if passed, remove any older full or incremental backup files from the
doing a full backup. (https://bugs.launchpad.net/zope2/+bug/143158) repository after doing a full backup.
(https://bugs.launchpad.net/zope2/+bug/143158)
- When transactions are aborted, new object ids allocated during the - When transactions are aborted, new object ids allocated during the
transaction are saved and used in subsequent transactions. This can transaction are saved and used in subsequent transactions. This can
......
...@@ -410,14 +410,21 @@ def delete_old_backups(options): ...@@ -410,14 +410,21 @@ def delete_old_backups(options):
dat = root + '.dat' dat = root + '.dat'
if dat in deletable: if dat in deletable:
deletable.remove(dat) deletable.remove(dat)
index = root + '.index'
if index in deletable:
deletable.remove(index)
for fname in deletable: for fname in deletable:
log('removing old backup file %s (and .dat)', fname) log('removing old backup file %s (and .dat / .index)', fname)
root, ext = os.path.splitext(fname) root, ext = os.path.splitext(fname)
try: try:
os.unlink(os.path.join(options.repository, root + '.dat')) os.unlink(os.path.join(options.repository, root + '.dat'))
except OSError: except OSError:
pass pass
try:
os.unlink(os.path.join(options.repository, root + '.index'))
except OSError:
pass
os.unlink(os.path.join(options.repository, fname)) os.unlink(os.path.join(options.repository, fname))
def do_full_backup(options): def do_full_backup(options):
......
...@@ -457,7 +457,10 @@ class Test_delete_old_backups(OptionsTestBase, unittest.TestCase): ...@@ -457,7 +457,10 @@ class Test_delete_old_backups(OptionsTestBase, unittest.TestCase):
self.failUnless(os.path.isfile(fqn)) self.failUnless(os.path.isfile(fqn))
def test_doesnt_remove_current_repozo_files(self): def test_doesnt_remove_current_repozo_files(self):
FILENAMES = ['2009-12-20-10-08-03.fs', '2009-12-20-10-08-03.dat'] FILENAMES = ['2009-12-20-10-08-03.fs',
'2009-12-20-10-08-03.dat',
'2009-12-20-10-08-03.index',
]
self._callFUT(filenames=FILENAMES) self._callFUT(filenames=FILENAMES)
remaining = os.listdir(self._repository_directory) remaining = os.listdir(self._repository_directory)
self.assertEqual(len(remaining), len(FILENAMES)) self.assertEqual(len(remaining), len(FILENAMES))
...@@ -466,9 +469,19 @@ class Test_delete_old_backups(OptionsTestBase, unittest.TestCase): ...@@ -466,9 +469,19 @@ class Test_delete_old_backups(OptionsTestBase, unittest.TestCase):
self.failUnless(os.path.isfile(fqn)) self.failUnless(os.path.isfile(fqn))
def test_removes_older_repozo_files(self): def test_removes_older_repozo_files(self):
OLDER_FULL = ['2009-12-20-00-01-03.fs', '2009-12-20-00-01-03.dat'] OLDER_FULL = ['2009-12-20-00-01-03.fs',
DELTAS = ['2009-12-21-00-00-01.deltafs', '2009-12-22-00-00-01.deltafs'] '2009-12-20-00-01-03.dat',
CURRENT_FULL = ['2009-12-23-00-00-01.fs', '2009-12-23-00-00-01.dat'] '2009-12-20-00-01-03.index',
]
DELTAS = ['2009-12-21-00-00-01.deltafs',
'2009-12-21-00-00-01.index',
'2009-12-22-00-00-01.deltafs',
'2009-12-22-00-00-01.index',
]
CURRENT_FULL = ['2009-12-23-00-00-01.fs',
'2009-12-23-00-00-01.dat',
'2009-12-23-00-00-01.index',
]
FILENAMES = OLDER_FULL + DELTAS + CURRENT_FULL FILENAMES = OLDER_FULL + DELTAS + CURRENT_FULL
self._callFUT(filenames=FILENAMES) self._callFUT(filenames=FILENAMES)
remaining = os.listdir(self._repository_directory) remaining = os.listdir(self._repository_directory)
...@@ -484,10 +497,19 @@ class Test_delete_old_backups(OptionsTestBase, unittest.TestCase): ...@@ -484,10 +497,19 @@ class Test_delete_old_backups(OptionsTestBase, unittest.TestCase):
self.failUnless(os.path.isfile(fqn)) self.failUnless(os.path.isfile(fqn))
def test_removes_older_repozo_files_zipped(self): def test_removes_older_repozo_files_zipped(self):
OLDER_FULL = ['2009-12-20-00-01-03.fsz', '2009-12-20-00-01-03.dat'] OLDER_FULL = ['2009-12-20-00-01-03.fsz',
'2009-12-20-00-01-03.dat',
'2009-12-20-00-01-03.index',
]
DELTAS = ['2009-12-21-00-00-01.deltafsz', DELTAS = ['2009-12-21-00-00-01.deltafsz',
'2009-12-22-00-00-01.deltafsz'] '2009-12-21-00-00-01.index',
CURRENT_FULL = ['2009-12-23-00-00-01.fsz', '2009-12-23-00-00-01.dat'] '2009-12-22-00-00-01.deltafsz',
'2009-12-22-00-00-01.index',
]
CURRENT_FULL = ['2009-12-23-00-00-01.fsz',
'2009-12-23-00-00-01.dat',
'2009-12-23-00-00-01.index',
]
FILENAMES = OLDER_FULL + DELTAS + CURRENT_FULL FILENAMES = OLDER_FULL + DELTAS + CURRENT_FULL
self._callFUT(filenames=FILENAMES) self._callFUT(filenames=FILENAMES)
remaining = os.listdir(self._repository_directory) remaining = os.listdir(self._repository_directory)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment