$this->addOption( 'posdir', 'Directory to read/record journal positions', false, true );
$this->addOption( 'posdump', 'Just dump current journal position into the position dir.' );
$this->addOption( 'postime', 'For position dumps, get the ID at this time', false, true );
$this->addOption( 'posdir', 'Directory to read/record journal positions', false, true );
$this->addOption( 'posdump', 'Just dump current journal position into the position dir.' );
$this->addOption( 'postime', 'For position dumps, get the ID at this time', false, true );
$this->addOption( 'verbose', 'Verbose mode', false, false, 'v' );
$this->setBatchSize( 50 );
}
$this->addOption( 'verbose', 'Verbose mode', false, false, 'v' );
$this->setBatchSize( 50 );
}
- $end = $this->getOption( 'end', INF );
+
+ if ( $this->hasOption( 'backoff' ) ) {
+ $time = time() - $this->getOption( 'backoff', 0 );
+ $end = (int)$src->getJournal()->getPositionAtTime( $time );
+ } else {
+ $end = $this->getOption( 'end', INF );
+ }
$this->output( "Synchronizing backend '{$dst->getName()}' to '{$src->getName()}'...\n" );
$this->output( "Starting journal position is $start.\n" );
$this->output( "Synchronizing backend '{$dst->getName()}' to '{$src->getName()}'...\n" );
$this->output( "Starting journal position is $start.\n" );
if ( $startFromPosFile && $pos >= $start ) { // successfully advanced
file_put_contents( $posFile, $pos, LOCK_EX );
}
if ( $startFromPosFile && $pos >= $start ) { // successfully advanced
file_put_contents( $posFile, $pos, LOCK_EX );
}
* Sync $dst backend to $src backend based on the $src logs given after $start.
* Returns the journal entry ID this advanced to and handled (inclusive).
*
* Sync $dst backend to $src backend based on the $src logs given after $start.
* Returns the journal entry ID this advanced to and handled (inclusive).
*
- * @param $src FileBackend
- * @param $dst FileBackend
- * @param $start integer Starting journal position
- * @param $end integer Starting journal position
- * @param $callback Closure Callback to update any position file
- * @return integer|false Journal entry ID or false if there are none
+ * @param FileBackend $src
+ * @param FileBackend $dst
+ * @param int $start Starting journal position
+ * @param int $end Starting journal position
+ * @param Closure $callback Callback to update any position file
+ * @return int|bool Journal entry ID or false if there are none
*/
protected function syncBackends(
FileBackend $src, FileBackend $dst, $start, $end, Closure $callback
*/
protected function syncBackends(
FileBackend $src, FileBackend $dst, $start, $end, Closure $callback
if ( !$fsFile ) {
$this->error( "Unable to sync '$dPath': could not get local copy." );
$status->fatal( 'backend-fail-internal', $src->getName() );
if ( !$fsFile ) {
$this->error( "Unable to sync '$dPath': could not get local copy." );
$status->fatal( 'backend-fail-internal', $src->getName() );
} else { // error
$this->error( "Unable to sync '$dPath': could not stat file." );
$status->fatal( 'backend-fail-internal', $src->getName() );
} else { // error
$this->error( "Unable to sync '$dPath': could not stat file." );
$status->fatal( 'backend-fail-internal', $src->getName() );