https://www.mediawiki.org/wiki/Special:Code/MediaWiki/112288

Revision: 112288
Author:   aaron
Date:     2012-02-24 01:38:53 +0000 (Fri, 24 Feb 2012)
Log Message:
-----------
Split out wikiversions.dat backup script and made a few small cleanups.

Modified Paths:
--------------
    trunk/tools/mwmultiversion/multiversion/switchAllMediaWikis

Added Paths:
-----------
    trunk/tools/mwmultiversion/multiversion/backupWikiversions

Added: trunk/tools/mwmultiversion/multiversion/backupWikiversions
===================================================================
--- trunk/tools/mwmultiversion/multiversion/backupWikiversions                  
        (rev 0)
+++ trunk/tools/mwmultiversion/multiversion/backupWikiversions  2012-02-24 
01:38:53 UTC (rev 112288)
@@ -0,0 +1,23 @@
+#!/usr/bin/env php
+<?php
+error_reporting( E_ALL );
+require_once( dirname( __FILE__ ) . '/defines.php' );
+/*
+ * This script backs up the current wikiversions dat file to the /backup 
directory.
+ *
+ * @return void
+ */
+function backupWikiversions() {
+       $common = '/home/wikipedia/common';
+       $datPath = MULTIVER_CDB_DIR_HOME . '/wikiversions.dat';
+
+       # Backup old wikiversions.dat...
+       $timestamp = date( 'c' ); // ISO 8601
+       $backupPath = "$common/multiversion/backup/wikiversions-$timestamp.dat";
+       if ( !copy( $datPath, $backupPath ) ) {
+               die( "Unable to write wikiversions.dat backup file at 
`$backupPath`.\n" );
+       }
+       echo "Wrote wikiversions.dat backup file at `$backupPath`.\n";
+}
+
+backupWikiversions();


Property changes on: trunk/tools/mwmultiversion/multiversion/backupWikiversions
___________________________________________________________________
Added: svn:executable
   + *

Modified: trunk/tools/mwmultiversion/multiversion/switchAllMediaWikis
===================================================================
--- trunk/tools/mwmultiversion/multiversion/switchAllMediaWikis 2012-02-24 
01:29:37 UTC (rev 112287)
+++ trunk/tools/mwmultiversion/multiversion/switchAllMediaWikis 2012-02-24 
01:38:53 UTC (rev 112288)
@@ -52,19 +52,20 @@
        }
 
        # Backup old wikiversions.dat...
-       $timestamp = date( 'c' ); // ISO 8601
-       $backupPath = "$common/multiversion/backup/wikiversions-$timestamp.dat";
-       if ( !copy( $datPath, $backupPath ) ) {
-               die( "Unable to write backup file `$backupPath`.\n" );
-       }
-       echo "Wrote backup file `$backupPath`.\n";
+       $retVal = 1;
+       passthru( "cd $common/multiversion && ./backupWikiversions", $retVal );
+       ( $retVal == 0 ) or die( 1 );
 
        # Update wikiversions.dat...
-       if ( !file_put_contents( $datPath, $datList ) ) {
+       if ( !file_put_contents( $datPath, $datList, LOCK_EX ) ) {
                die( "Unable to write to wikiversions.dat.\n" );
        }
+       echo "Updated wikiversions.dat.\n";
+
        # Rebuild wikiversions.cdb...
-       shell_exec( "cd $common/multiversion && ./refreshWikiversionsCDB" );
+       $retVal = 1;
+       passthru( "cd $common/multiversion && ./refreshWikiversionsCDB", 
$retVal );
+       ( $retVal == 0 ) or die( 1 );
 
        echo "Re-configured $count wiki(s) from $oldVersion to $newVersion.\n";
 }


_______________________________________________
MediaWiki-CVS mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-cvs

Reply via email to