- function &backupDb() {
- global $wgDBadminuser, $wgDBadminpassword;
- global $wgDBname;
- $db =& new Database( $this->backupServer(), $wgDBadminuser, $wgDBadminpassword, $wgDBname );
- $timeout = 3600 * 24;
- $db->query( "SET net_read_timeout=$timeout" );
- $db->query( "SET net_write_timeout=$timeout" );
+ /**
+ * Initialise starting time and maximum revision count.
+ * We'll make ETA calculations based an progress, assuming relatively
+ * constant per-revision rate.
+ * @param int $history WikiExporter::CURRENT or WikiExporter::FULL
+ */
+ function initProgress( $history = WikiExporter::FULL ) {
+ $table = ($history == WikiExporter::CURRENT) ? 'page' : 'revision';
+ $field = ($history == WikiExporter::CURRENT) ? 'page_id' : 'rev_id';
+
+ $dbr = wfGetDB( DB_SLAVE );
+ $this->maxCount = $dbr->selectField( $table, "MAX($field)", '', 'BackupDumper::dump' );
+ $this->startTime = wfTime();
+ }
+
+ /**
+ * @fixme the --server parameter is currently not respected, as it doesn't seem
+ * terribly easy to ask the load balancer for a particular connection by name.
+ */
+ function backupDb() {
+ $this->lb = wfGetLBFactory()->newMainLB();
+ $db = $this->lb->getConnection( DB_SLAVE, 'backup' );
+
+ // Discourage the server from disconnecting us if it takes a long time
+ // to read out the big ol' batch query.
+ $db->setTimeout( 3600 * 24 );
+