Index: trunk/tools/mwmultiversion/multiversion/switchAllMediaWikis |
— | — | @@ -52,19 +52,20 @@ |
53 | 53 | } |
54 | 54 | |
55 | 55 | # 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 ); |
62 | 59 | |
63 | 60 | # Update wikiversions.dat... |
64 | | - if ( !file_put_contents( $datPath, $datList ) ) { |
| 61 | + if ( !file_put_contents( $datPath, $datList, LOCK_EX ) ) { |
65 | 62 | die( "Unable to write to wikiversions.dat.\n" ); |
66 | 63 | } |
| 64 | + echo "Updated wikiversions.dat.\n"; |
| 65 | + |
67 | 66 | # 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 ); |
69 | 70 | |
70 | 71 | echo "Re-configured $count wiki(s) from $oldVersion to $newVersion.\n"; |
71 | 72 | } |
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 |
1 | 25 | + * |