repozo generates different dates for filenames

Bug #993350 reported by Frank Hauptmann
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
ZODB
Fix Committed
Undecided
Tres Seaver

Bug Description

Sometimes repozo generates different dates in filenames for Data.fs and .index. For example:

2012-05-02-13-34-08.deltafs
2012-05-02-13-34-09.index

When doing a restore the index-File is not recognized and not restored.
A possible solution would be to generate the date-part of the filename just once on full backup or incremental backup to ensure that the second did not change.

Possible Patch:

Index: repozo.py
===================================================================
--- repozo.py (revision 3017)
+++ repozo.py (revision 3018)
@@ -305,7 +305,10 @@
     return bytesread, sum.hexdigest()

-def gen_filename(options, ext=None):
+def gen_filedate(options):
+ return getattr(options, 'test_now', time.gmtime()[:6])
+
+def gen_filename(options, ext=None, now=None):
     if ext is None:
         if options.full:
             ext = '.fs'
@@ -314,7 +317,8 @@
         if options.gzip:
             ext += 'z'
     # Hook for testing
- now = getattr(options, 'test_now', time.gmtime()[:6])
+ if now == None:
+ now = gen_filedate(options)
     t = now + (ext,)
     return '%04d-%02d-%02d-%02d-%02d-%02d%s' % t

@@ -330,7 +334,7 @@
 def find_files(options):
     when = options.date
     if not when:
- when = gen_filename(options, '')
+ when = gen_filename(options, ext='')
     log('looking for files between last full backup and %s...', when)
     all = filter(is_data_file, os.listdir(options.repository))
     all.sort()
@@ -429,7 +433,8 @@

 def do_full_backup(options):
     options.full = True
- dest = os.path.join(options.repository, gen_filename(options))
+ tnow = gen_filedate(options)
+ dest = os.path.join(options.repository, gen_filename(options, now=tnow))
     if os.path.exists(dest):
         raise WouldOverwriteFiles('Cannot overwrite existing file: %s' % dest)
     # Find the file position of the last completed transaction.
@@ -442,7 +447,7 @@
     pos = fs.getSize()
     # Save the storage index into the repository
     index_file = os.path.join(options.repository,
- gen_filename(options, '.index'))
+ gen_filename(options, '.index', tnow))
     log('writing index')
     fs._index.save(pos, index_file)
     fs.close()
@@ -461,7 +466,8 @@

 def do_incremental_backup(options, reposz, repofiles):
     options.full = False
- dest = os.path.join(options.repository, gen_filename(options))
+ tnow = gen_filedate(options)
+ dest = os.path.join(options.repository, gen_filename(options, now=tnow))
     if os.path.exists(dest):
         raise WouldOverwriteFiles('Cannot overwrite existing file: %s' % dest)
     # Find the file position of the last completed transaction.
@@ -474,7 +480,7 @@
     pos = fs.getSize()
     log('writing index')
     index_file = os.path.join(options.repository,
- gen_filename(options, '.index'))
+ gen_filename(options, '.index', tnow))
     fs._index.save(pos, index_file)
     fs.close()
     log('writing incremental: %s bytes to %s', pos-reposz, dest)

Tres Seaver (tseaver)
Changed in zodb:
assignee: nobody → Tres Seaver (tseaver)
status: New → Confirmed
Revision history for this message
Tres Seaver (tseaver) wrote :

Thanks for the patch! Committed on the 3.10 branch and the trunk.

Changed in zodb:
status: Confirmed → Fix Committed
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.