r112288 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r112287‎ | r112288 | r112289 >
Date:01:38, 24 February 2012
Author:aaron
Status:ok
Tags:
Comment:
Split out wikiversions.dat backup script and made a few small cleanups.
Modified paths:
  • /trunk/tools/mwmultiversion/multiversion/backupWikiversions (added) (history)
  • /trunk/tools/mwmultiversion/multiversion/switchAllMediaWikis (modified) (history)

Diff [purge]

Index: trunk/tools/mwmultiversion/multiversion/switchAllMediaWikis
@@ -52,19 +52,20 @@
5353 }
5454
5555 # Backup old wikiversions.dat...
56 - $timestamp = date( 'c' ); // ISO 8601
57 - $backupPath = "$common/multiversion/backup/wikiversions-$timestamp.dat";
58 - if ( !copy( $datPath, $backupPath ) ) {
59 - die( "Unable to write backup file `$backupPath`.\n" );
60 - }
61 - echo "Wrote backup file `$backupPath`.\n";
 56+ $retVal = 1;
 57+ passthru( "cd $common/multiversion && ./backupWikiversions", $retVal );
 58+ ( $retVal == 0 ) or die( 1 );
6259
6360 # Update wikiversions.dat...
64 - if ( !file_put_contents( $datPath, $datList ) ) {
 61+ if ( !file_put_contents( $datPath, $datList, LOCK_EX ) ) {
6562 die( "Unable to write to wikiversions.dat.\n" );
6663 }
 64+ echo "Updated wikiversions.dat.\n";
 65+
6766 # Rebuild wikiversions.cdb...
68 - shell_exec( "cd $common/multiversion && ./refreshWikiversionsCDB" );
 67+ $retVal = 1;
 68+ passthru( "cd $common/multiversion && ./refreshWikiversionsCDB", $retVal );
 69+ ( $retVal == 0 ) or die( 1 );
6970
7071 echo "Re-configured $count wiki(s) from $oldVersion to $newVersion.\n";
7172 }
Index: trunk/tools/mwmultiversion/multiversion/backupWikiversions
@@ -0,0 +1,23 @@
 2+#!/usr/bin/env php
 3+<?php
 4+error_reporting( E_ALL );
 5+require_once( dirname( __FILE__ ) . '/defines.php' );
 6+/*
 7+ * This script backs up the current wikiversions dat file to the /backup directory.
 8+ *
 9+ * @return void
 10+ */
 11+function backupWikiversions() {
 12+ $common = '/home/wikipedia/common';
 13+ $datPath = MULTIVER_CDB_DIR_HOME . '/wikiversions.dat';
 14+
 15+ # Backup old wikiversions.dat...
 16+ $timestamp = date( 'c' ); // ISO 8601
 17+ $backupPath = "$common/multiversion/backup/wikiversions-$timestamp.dat";
 18+ if ( !copy( $datPath, $backupPath ) ) {
 19+ die( "Unable to write wikiversions.dat backup file at `$backupPath`.\n" );
 20+ }
 21+ echo "Wrote wikiversions.dat backup file at `$backupPath`.\n";
 22+}
 23+
 24+backupWikiversions();
Property changes on: trunk/tools/mwmultiversion/multiversion/backupWikiversions
___________________________________________________________________
Added: svn:executable
125 + *

Status & tagging log