Download the PHP package tradesy/innobackupex without Composer
On this page you can find all versions of the php package tradesy/innobackupex. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download tradesy/innobackupex
More information about tradesy/innobackupex
Files in tradesy/innobackupex
Package innobackupex
Short Description Wrapper for innobackupex incremental backup/restore with ability to store backups on various repository (AWS S3, Google)
License MIT
Informations about the package innobackupex
Innobackupex
Innobackupex is a perl utility created by Percona for creating and restoring filesystem backups for MySQL
This is a PHP Wrapper for Innobackupex that allows us to use Object-Oriented design to Backup/Restore MySQL servers and automates the archival of backups onto cloud storage solutions such as AWS S3 and Google Cloud Storage.
This package is created as a PSR-0 namespaced library that is installable via PHP Composer.
Very little configuration is required to use this library.
Requirements
- PHP 5+
- PHP Composer
- (Optional) AWS CLI
- (Optional) GCS CLI
- MySQL Server with enough free disk space to create a backup
- (Optional) SSH Access to the MySQL Server
- (Required for SSH) libssh2-php
- php5-curl (required for guzzle)
- python-mysqldb # necessary for ansible mysql module
Methodology
This library is useable in several different ways. The simplest method requires PHP and this library to be downloaded onto the MySQL Server itself.
Alternatively, we are able to use the PHP_SSH2 Library in order to run this library remotely against any server with mysql and ssh access.
Installation
Include this repository within your composer.json package of your library
Run composer install
If you want to test using Vagrant, be sure to install Ansible dependencies:
ansible-galaxy install -v -r ansible/requirements.yml -p ansible/roles
Configuration
MySQL Configuration
Enabling Optional Encryption of Archives via Encryption Configuration
Please note, it is not recommended to store credentials or keys in plaintext within your VCS repositories. The example above is just an example. You can either encrypt the backup script, or encrypt a file with the key in it that is loadable by your backup script, or possibly use environment variables or some other solution for sensitive information.
SSH Connection Configuration
We then use this configuration object to create a connection object:
Alternatively, instead of SSH'ing into your MySQL Box, you can also run this library directly on your server using a LocalShell/Connection Object
LocalShell Connection Configuration
Save Modules
Save Modules determine where we will store our backups. You can specify one or more save modules in an array
To date, we have only implemented AWS S3 and GCS Save Modules. The goal is to have additional modules implemented using the same interfaces for us to be able to archive onto more providers by simply adding the configuration to the save module array
AWS S3 Save Module
There are two ways to use the AWS S3 Save Module. We can either use AWS's PHP SDK to handle the upload for us (\Tradesy\Innobackupex\S3\Local\Upload)
, or if this is not desired, we can fallback to using the shell AWS cli (\Tradesy\Innobackupex\S3\Remote\Upload)
which has it's own independent credentials and configuration
In order to use the local module, we must be using a LocalShell Connection as this library and composer dependency (AWS-PHP-SDK) is required.
With an SSH Connection, we are limited in that we don't have a copy of this library in th
Google Cloud Storage Save Module
At the moment, GCS PHP SDK is not capable of handling large file uploads without exhausting memory resources. Because of this, using the \Tradesy\Innobackupex\GCS\Remote\Upload
module is suggested.
Now that you have a mysql configuration, connection, and save module objects, you are ready to create the Backup Object:
Full Backup Object
to run the backup script, simply call:
This stores a serialized PHP Object of type \Tradesy\Innobackupex\Backup\Info
into the $save_directory
with information about relevant incremental and full backups for later use by the restoration process or additional incremental backups
Incremental Backup
Create the Incremental
object
Load the previous Backup Info serialized file
Create the Backup
Restoring from Backups
Please be sure to only run this when necessary and likely, on a non-production server as it will erase all existing MySQL Data.
The restoration process looks something like this:
- Download the Backup Info serialized object/file. This is typically stored within the same dated backup directory in your bucket. This holds information about where to find archives and naming conventions
- For each desired set of a single Full Backup and related Incremental Backups:
- Download archive to local system
-
Extract and optionally decrypt the archive
All of this is automated for your via our Restoration Configuration, Connection and Restore Modules:
***You must manually remove /var/lib/mysql on your target server in order to commence a Restoration.
Load Backup Info Object from disk
Use the same $mysql_config object as before.
Use localshell connection for fastest restoration:
Create desired restore modules
Create the Restore Object
When ready, simply call the restore method. All archives will be downloaded via the restore modules and prepared automatically. Additionally, the method will restore the database.
Sample Crontab
For more examples, please see the ./Examples
directory or Tests
Testing
Configuration for AWS/GCS (Optional):
You must configure your aws cli by adding api key credentials to:
/home/vagrant/.aws/boto
and configure gsutil by running
gsutil configure
You may have to update tests to reference personal buckets as well.
Start Vagrant:
Log into VM:
vagrant ssh
CD to shared Directory:
cd /var/www
Install composer packages:
composer install --dev
Create an SSH Key
ssh-keygen
( press enter a few times )
cat ~/.ssh/id_rsa.pub >> ~/.ssh/authorized_keys
Run PHPUnit
./vendor/bin/phpunit -v --debug
To see full test coverage, run:
./vendor/bin/phpunit --debug --verbose --coverage-html html
Currently at ~80% Test Coverage, 87.5% with GCS Local Module excluded
To Reset the Database after failed test suite:
On Host:
Known Bugs
GCS Local Module (PHP SDK) Doesn't Work. This is due to the utilization of file_get/put_contents
which is unstable for large files. Please use GCS\Remote\Upload|Download
Modules instead.
TODO
- Document usage and implement configurable logging (Monolog).
- Add more Modules
- Add tests for unencrypted and uncompressed (flat) backups
- Test against non-percona MySQL
License
Copyright (c) 2016, Matt Margolin
All rights reserved.
Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
-
Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
-
Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
- Neither the name of the copyright holder nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
Author Information
Matt Margolin
mm0 on github
All versions of innobackupex with dependencies
aws/aws-sdk-php Version 2.*
google/apiclient Version dev-master
monolog/monolog Version ^1.20