Download the PHP package jairocgr/datashot without Composer
On this page you can find all versions of the php package jairocgr/datashot. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download jairocgr/datashot
More information about jairocgr/datashot
Files in jairocgr/datashot
Package datashot
Short Description A tool for taking partial database dumps and scripting datbases
License MIT
Homepage https://github.com/jairocgr/datashot
Informations about the package datashot
Datashot Database Snapper
A tool for taking partial and minified database snapshots for testing and development purpose.
Instead of taking a full database dump, you can filter which rows you want to dump in order to come up with a downsized database snapshot.
Requirements
To install and run datashot you must have:
- PHP >= 5.6 with PDO extension
zlib
PHP extension for gzip compression- MySQL client (
mysql
andmysqldump
on path) - Gzip on path
- Composer dependency manager
Installing
Install it as a regular package via composer:
composer require jairocgr/datashot
Usage
You can call it as a command line tool:
php vendor/bin/datashot --help
Getting Started
With datashot
you can filter which rows you want to dump to come up with a
much smaller database dump.
You can reduce ginormous multi-gigabyte databases in to a small gziped file ready to be restored in to staging and local develoment environments.
This kind of power come up handy for troubleshooting production bugs and all arround better development experience with real life data that best reflects your application usage than a mocked or seeded schema.
With datashot
you can for instance take a database dump with only the orders
from the current quarter.
You can also perform other operations like:
- Fully
replicate
databases from a host to another, restore
existant dumps to a database hosts, and- upload/download dumps from a SFTP or S3 repositories via
cp
command.
Configuration
The first step is to setup the datashot.config.php
file in the root of your
application repository.
This is the configuration file where you set the database hosts, passwords and
the SQL WHERE
clauses in order to slice the database down.
For a more complete and commented and configuration file see the sample
datashot.config.php
file inside this repository root directory
Database Hosts
You have to configure all your database in order to be able to work with it.
Repositories
You have to set the repositories where you will store the dumps.
Snappers
The snappers tell datashot
how to slice down the database.
Your First Snapshot
To take a database snapshot using the previously configured file:
php vendor/bin/datashot snap myerp --from live1 --to remote:quick_snap --snapper quick
Then datashot
will take a proper mysqldump
from the scheme myerp
that
is running inside the production server live1
and it will be using the quick
snapper to cut the logs
and users
table down.
Then it will upload a file called quick.gz
to the remote s3 repository called
remote
previously configured in the datashot.config.php
configuration
file.
Restoring Snapshots
You can use datashot
to download and restore
your snapshots:
php vendor/bin/datashot restore remote:quick --to dev --database myerp_dev
The command above will download the quick
snapshot previously taken, restore
the dump as myerp_dev
schema at dev
databaser server.
You can also restore the snapshot like a regular gziped SQL dump file:
gunzip < path/to/quick.gz | mysql -h localhost myerp
Hat Tipping
I tip my hat to ifsnop/mysqldump-php for providing insights on how to dump a mysql database via PHP/PDO.
License
This project is licensed under the MIT License - see the LICENSE file for details
All versions of datashot with dependencies
ext-pdo Version *
ext-zlib Version *
symfony/console Version ^5
symfony/process Version ^5
league/flysystem-aws-s3-v3 Version ^1
league/flysystem-sftp Version ^1
vlucas/phpdotenv Version ^5