Commit fdc58a91 authored by Jérome Perrin's avatar Jérome Perrin

fixup! zodbsync: new command to replicate storage

parent 144f1b41
......@@ -22,6 +22,8 @@
"""
from __future__ import print_function
import datetime
from zodbtools.zodbcommit import zodbcommit
from zodbtools.zodbdump import Transaction, ObjectCopy, ObjectData, ObjectDelete
from zodbtools.util import ashex, parse_tid, storageFromURL, txnobjv
......@@ -42,9 +44,12 @@ def zodbsync(primary_store, secondary_store, until, verbosity):
print("until", readable_tid_repr(until), end='')
print()
start = datetime.datetime.now()
transaction_count = 0
for t in primary_store.iterator(start=at, stop=until):
if t.tid <= at and at != z64:
if verbosity > 1:
if verbosity > 2:
# XXX happens always at least once
print("skipping already present", readable_tid_repr(at))
continue
......@@ -65,6 +70,7 @@ def zodbsync(primary_store, secondary_store, until, verbosity):
t.extension_bytes,
objv)
zodbcommit(secondary_store, at, txn)
transaction_count += 1
if verbosity > 1:
print(readable_tid_repr(txn.tid), t.user, t.description, len(objv))
......@@ -72,6 +78,9 @@ def zodbsync(primary_store, secondary_store, until, verbosity):
print(readable_tid_repr(txn.tid))
at = txn.tid
if verbosity:
print("replicated %d transactions in %s" % (
transaction_count, datetime.datetime.now() - start))
# ----------------------------------------
......
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