jenkins-bot has submitted this change and it was merged.

Change subject: Remove backup support from Cirrus
......................................................................


Remove backup support from Cirrus

Backups should be managed by Elasticsearch, not Cirrus

Change-Id: Ifc97cebabb7b2b940c521f3241be1256bf403aae
---
M CirrusSearch.php
D maintenance/backupIndexes.php
2 files changed, 0 insertions(+), 147 deletions(-)

Approvals:
  Manybubbles: Looks good to me, approved
  jenkins-bot: Verified



diff --git a/CirrusSearch.php b/CirrusSearch.php
index 602dcf7..b778456 100644
--- a/CirrusSearch.php
+++ b/CirrusSearch.php
@@ -362,15 +362,6 @@
 // How long to cache interwiki search results for (in seconds)
 $wgCirrusSearchInterwikiCacheTime = 7200;
 
-// Configuration for backups, array format is as follows:
-//  array(
-//    'my_backups' => array( 'type' => 'fs', 'location' => '/bar/baz/' )
-//  )
-//
-// See the Elasticsearch configuration for more settings you can give, note
-// that type and location are required.
-$wgCirrusSearchBackup = array();
-
 // The seconds Elasticsearch will wait to batch index changes before making
 // them available for search.  Lower values make search more real time but put
 // more load on Elasticsearch.  Defaults to 1 second because that is the 
default
diff --git a/maintenance/backupIndexes.php b/maintenance/backupIndexes.php
deleted file mode 100644
index 5da7106..0000000
--- a/maintenance/backupIndexes.php
+++ /dev/null
@@ -1,138 +0,0 @@
-<?php
-
-namespace CirrusSearch;
-use \Maintenance;
-
-/**
- * Create snapshots of your indexes
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License along
- * with this program; if not, write to the Free Software Foundation, Inc.,
- * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- * http://www.gnu.org/copyleft/gpl.html
- */
-
-$IP = getenv( 'MW_INSTALL_PATH' );
-if( $IP === false ) {
-       $IP = __DIR__ . '/../../..';
-}
-require_once( "$IP/maintenance/Maintenance.php" );
-
-class BackupIndexes extends Maintenance {
-       /** @var \Elastica\Snapshot */
-       private $snapshot;
-
-       /** @var string */
-       private $repoName;
-
-       public function __construct() {
-               parent::__construct();
-               $this->mDescription = "Snapshot and restore indexes using the 
snapshot/restore feature of Elastic";
-               $this->addOption( 'repo', 'Which repository to use.', true, 
true );
-               $this->addOption( 'mode', "One of 'delete', 'list', 'snapshot', 
default is 'list'", false, true );
-               $this->addOption( 'baseName', 'Base name of index, defaults to 
wiki id.', false, true );
-               $this->addOption( 'snapshot', 'Name of the snapshot, otherwise 
defaults to cirrus-$baseName-{timestamp}', false, true );
-       }
-
-       public function execute() {
-               global $wgCirrusSearchBackup;
-
-               if ( !$wgCirrusSearchBackup ) {
-                       $this->error( "No backups configured, see 
\$wgCirrusSearchBackup", 1 );
-               }
-
-               $this->repoName = $this->getOption( 'repo' );
-               if ( !isset( $wgCirrusSearchBackup[ $this->repoName ] ) ) {
-                       $this->error( "No such repository '{$this->repoName}'", 
1 );
-               }
-
-               $this->snapshot = new \Elastica\Snapshot( 
Connection::getClient() );
-               $this->createRepositoryIfMissing( $wgCirrusSearchBackup[ 
$this->repoName ] );
-               switch( $this->getOption( 'mode', 'list' ) ) {
-                       case 'delete':
-                               $snapshot = $this->getOption( 'snapshot' );
-                               if ( !$snapshot ) {
-                                       $this->error( '--mode=delete requires 
--snapshot to be set', 1 );
-                               }
-                               $this->deleteSnapshot( $snapshot, 
$this->getSnapshots() );
-                               break;
-                       case 'snapshot':
-                               $this->takeSnapshot();
-                               break;
-                       case 'list':
-                       default:
-                               $this->listSnapshots( $this->getSnapshots() );
-                               break;
-               }
-       }
-
-       private function createRepositoryIfMissing( $settings ) {
-               try {
-                       $this->snapshot->getRepository( $this->repoName );
-               } catch ( \Elastica\Exception\NotFoundException $e ) {
-                       $this->output( "Snapshot repository '{$this->repoName}' 
does not exist, creating..." );
-                       $type = $settings['type'];
-                       unset( $settings['type'] );
-                       $this->snapshot->registerRepository( $this->repoName, 
$type, $settings );
-                       $this->output( "done.\n" );
-               }
-       }
-
-       private function getSnapshots() {
-               $snaps = array();
-               $snapshots = $this->snapshot->getAllSnapshots( $this->repoName 
);
-               foreach ( $snapshots['snapshots'] as $shot ) {
-                       $snaps[ $shot['snapshot'] ] = $shot['indices'];
-               }
-               return $snaps;
-       }
-
-       private function deleteSnapshot( $snapshot, $allSnapshots ) {
-               $this->output( "Deleting snapshot '$snapshot' from 
{$this->repoName}..." );
-
-               if ( !isset( $allSnapshots[ $snapshot ] ) ) {
-                       $this->output( "no such snapshot, skipping.\n" );
-                       return;
-               }
-
-               $this->snapshot->deleteSnapshot( $this->repoName, $snapshot );
-               $this->output( "done.\n" );
-       }
-
-       private function listSnapshots( $allSnapshots ) {
-               if ( !$allSnapshots ) {
-                       $this->output( "Repository {$this->repoName} has no 
snapshots yet.\n" );
-                       return;
-               }
-               $this->output( "Listing snapshots for {$this->repoName}:\n" );
-               foreach ( $allSnapshots as $shot => $indices ) {
-                       $this->output( "\t" . $shot . "\t" . implode( ',', 
$indices ) . "\n" );
-               }
-       }
-
-       private function takeSnapshot() {
-               $baseName = $this->getOption( 'baseName', wfWikiId() );
-               $snapshot = $this->getOption( 'snapshot', "cirrus-$baseName-" . 
time() );
-               $options = array(
-                       'ignore_unavailable' => true,
-                       'indices' => $baseName,
-               );
-
-               $this->output( "Creating snapshot '$snapshot'..." );
-               $this->snapshot->createSnapshot( $this->repoName, $snapshot, 
$options, false );
-               $this->output( "done.\n" );
-       }
-}
-
-$maintClass = "CirrusSearch\BackupIndexes";
-require_once RUN_MAINTENANCE_IF_MAIN;

-- 
To view, visit https://gerrit.wikimedia.org/r/204310
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: merged
Gerrit-Change-Id: Ifc97cebabb7b2b940c521f3241be1256bf403aae
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/CirrusSearch
Gerrit-Branch: master
Gerrit-Owner: Chad <[email protected]>
Gerrit-Reviewer: Jdouglas <[email protected]>
Gerrit-Reviewer: Manybubbles <[email protected]>
Gerrit-Reviewer: jenkins-bot <>

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

Reply via email to