PHP Classes

Nomad PHP ElasticSearch Backup and Restore: Execute backup and restore on ElasticSearch to S3

Recommend this page to a friend!
  Info   View files Example   View files View files (21)   DownloadInstall with Composer Download .zip   Reputation   Support forum   Blog (1)    
Last Updated Ratings Unique User Downloads Download Rankings
2024-02-28 (2 months ago) RSS 2.0 feedNot enough user ratingsTotal: 35 All time: 10,960 This week: 68Up
Version License PHP version Categories
elastic-nomad-php 1.0Custom (specified...8Databases, Files and Folders, Searching, W..., P...
Description 

Author

This package can execute backup and restore actions of the ElasticSearch database to Amazon S3.

It provides a backup class to access an ElasticSearch index and retrieve it to local files that can be uploaded to a given Amazon S3 bucket.

The package also provides a backup class that retrieves files from a previous backup process stored in Amazon S3 and restores the Elastic Search index.

Innovation Award
PHP Programming Innovation award nominee
February 2024
Number 4
ElasticSearch is a tool to index and search content so that it can be quickly searched.

Usually, developers need to build indexes with the content that will be searched. Then, they use ElasticSearch queries to perform searches about the indexed content.

This package provides a solution that can backup and restore ElasticSearch indexes in Amazon S3 just in case it is necessary to restore lost ElasticSearch indexes due to data corruption or an eventual security issue.

Manuel Lemos
Picture of Leonardo Di Sarli
  Performance   Level  
Name: Leonardo Di Sarli <contact>
Classes: 11 packages by
Country: Brazil Brazil
Age: ???
All time rank: 3922317 in Brazil Brazil
Week rank: 12 Up2 in Brazil Brazil Up
Innovation award
Innovation award
Nominee: 5x

Winner: 2x

Example

<?php

use ElasticNomad\Nomad;

require_once
'vendor/autoload.php';

$dotenv = Dotenv\Dotenv::createImmutable(__DIR__);
$dotenv->load();

$validOperations = [
   
'backup',
   
'restore',
];
$operationsParams = [
   
'backup' => [
       
'index',
    ],
   
'restore' => [
       
'file_name',
    ],
];

$operation = $argv[1] ?? '';

if (!
in_array($operation, $validOperations)) {
    echo
'Please, use a valid operation: ' . implode(', ', $validOperations);
    die;
}

$params = array_slice(
   
$argv,
   
2
);

if (
    isset(
$operationsParams[$operation]) &&
   
count($params) < count($operationsParams[$operation])
) {
    echo
'Please, provide all the parameters: ' . implode(', ', $operationsParams[$operation]);
    die;
}

$options = [];
if (isset(
$operationsParams[$operation])) {
    foreach (
$operationsParams[$operation] as $index => $paramName) {
       
$options[$paramName] = $params[$index];
    }
}

$nomad = new Nomad();
$nomad->{$operation}($options);


Details

PHP Elastic Nomad

Latest Version PRs Welcome

PHP script to execute Elasticsearch backups and restorations using S3.

Installation

Requires PHP 8.1

Sample

it's a good idea to look in the sample folder to understand how it works.

First you need to building a correct environment to install dependences

docker build -t kiwfy/elastic-nomad-php -f contrib/Dockerfile .

Access the container

docker run -v ${PWD}/:/var/www/html -it kiwfy/elastic-nomad-php bash

Verify if all dependencies is installed (if need anyelse)

composer install --no-dev --prefer-dist

and run

php index.php

Development

Want to contribute? Great!

The project using a simple code. Make a change in your file and be careful with your updates! Any new code will only be accepted with all viladations.

To ensure that the entire project is fine:

First you need to building a correct environment to install/update all dependences

docker build -t kiwfy/elastic-nomad-php -f contrib/Dockerfile .

Access the container

docker run -v ${PWD}/:/var/www/html -it kiwfy/elastic-nomad-php bash

Install all dependences

composer install --dev --prefer-dist

Run all validations

composer check

Kiwfy - Open your code, open your mind!


  Files folder image Files  
File Role Description
Files folder imagecontrib (4 files)
Files folder imagesrc (3 files, 1 directory)
Accessible without login Plain text file .editorconfig Data Auxiliary data
Accessible without login Plain text file .env.example Data Auxiliary data
Accessible without login Plain text file composer.json Data Auxiliary data
Accessible without login Plain text file composer.lock Data Auxiliary data
Accessible without login Plain text file index.php Example Example script
Accessible without login Plain text file LICENSE Lic. License text
Accessible without login Plain text file phpcs.xml Data Auxiliary data
Accessible without login Plain text file phpmd.xml Data Auxiliary data
Accessible without login Plain text file phpunit.xml Data Auxiliary data
Accessible without login Plain text file query.json Data Auxiliary data
Accessible without login Plain text file README.md Doc. Documentation

  Files folder image Files  /  contrib  
File Role Description
  Accessible without login Plain text file coverage-checker.php Example Example script
  Accessible without login Plain text file Dockerfile Data Auxiliary data
  Accessible without login Plain text file pre-commit Data Auxiliary data
  Accessible without login Plain text file setup.sh Data Auxiliary data

  Files folder image Files  /  src  
File Role Description
Files folder imageHelpers (3 files)
  Plain text file Backup.php Class Class source
  Plain text file Nomad.php Class Class source
  Plain text file Restore.php Class Class source

  Files folder image Files  /  src  /  Helpers  
File Role Description
  Plain text file Elasticsearch.php Class Class source
  Plain text file Log.php Class Class source
  Plain text file S3Helper.php Class Class source

 Version Control Unique User Downloads Download Rankings  
 100%
Total:35
This week:0
All time:10,960
This week:68Up