All Projects → spatie → Laravel Db Snapshots

spatie / Laravel Db Snapshots

Licence: mit
Quickly dump and load databases

Projects that are alternatives of or similar to Laravel Db Snapshots

Backup Manager
Database backup manager for dumping to and restoring databases from S3, Dropbox, FTP, SFTP, and Rackspace Cloud
Stars: ✭ 1,589 (+144.46%)
Mutual labels:  database, mysql, postgresql, restore
Db Dumper
Dump the contents of a database
Stars: ✭ 744 (+14.46%)
Mutual labels:  dump, database, mysql, postgresql
Backup
MySQL Database backup package for Laravel
Stars: ✭ 66 (-89.85%)
Mutual labels:  dump, database, mysql, restore
Easydb
Easy-to-use PDO wrapper for PHP projects.
Stars: ✭ 624 (-4%)
Mutual labels:  database, mysql, postgresql
Go Sqlbuilder
A flexible and powerful SQL string builder library plus a zero-config ORM.
Stars: ✭ 539 (-17.08%)
Mutual labels:  database, mysql, postgresql
Dbeaver
Free universal database tool and SQL client
Stars: ✭ 23,752 (+3554.15%)
Mutual labels:  database, mysql, postgresql
Pgloader
Migrate to PostgreSQL in a single command!
Stars: ✭ 3,754 (+477.54%)
Mutual labels:  database, mysql, postgresql
Jooq
jOOQ is the best way to write SQL in Java
Stars: ✭ 4,695 (+622.31%)
Mutual labels:  database, mysql, postgresql
Sqlboiler
Generate a Go ORM tailored to your database schema.
Stars: ✭ 4,497 (+591.85%)
Mutual labels:  database, mysql, postgresql
Evolve
Database migration tool for .NET and .NET Core projects. Inspired by Flyway.
Stars: ✭ 477 (-26.62%)
Mutual labels:  database, mysql, postgresql
Beekeeper Studio
Modern and easy to use SQL client for MySQL, Postgres, SQLite, SQL Server, and more. Linux, MacOS, and Windows.
Stars: ✭ 8,053 (+1138.92%)
Mutual labels:  database, mysql, postgresql
Typeorm
ORM for TypeScript and JavaScript (ES7, ES6, ES5). Supports MySQL, PostgreSQL, MariaDB, SQLite, MS SQL Server, Oracle, SAP Hana, WebSQL databases. Works in NodeJS, Browser, Ionic, Cordova and Electron platforms.
Stars: ✭ 26,559 (+3986%)
Mutual labels:  database, mysql, postgresql
Jet
Type safe SQL builder with code generation and automatic query result data mapping
Stars: ✭ 373 (-42.62%)
Mutual labels:  database, mysql, postgresql
Franchise
🍟 a notebook sql client. what you get when have a lot of sequels.
Stars: ✭ 3,823 (+488.15%)
Mutual labels:  database, mysql, postgresql
Dibi
Dibi - smart database abstraction layer
Stars: ✭ 373 (-42.62%)
Mutual labels:  database, mysql, postgresql
Symmetric Ds
SymmetricDS is a database and file synchronization solution that is platform-independent, web-enabled, and database agnostic. SymmetricDS was built to make data replication across two to tens of thousands of databases and file systems fast, easy and resilient. We specialize in near real time, bi-directional data replication across large node networks over the WAN or LAN.
Stars: ✭ 450 (-30.77%)
Mutual labels:  database, mysql, postgresql
Denodb
MySQL, SQLite, MariaDB, PostgreSQL and MongoDB ORM for Deno
Stars: ✭ 498 (-23.38%)
Mutual labels:  database, mysql, postgresql
Backup
Easy full stack backup operations on UNIX-like systems.
Stars: ✭ 4,682 (+620.31%)
Mutual labels:  database, mysql, postgresql
Dbshield
Database firewall written in Go
Stars: ✭ 620 (-4.62%)
Mutual labels:  database, mysql, postgresql
Sql exporter
Database agnostic SQL exporter for Prometheus
Stars: ✭ 301 (-53.69%)
Mutual labels:  database, mysql, postgresql

Quickly dump and load databases

Latest Version on Packagist Software License Test Status Code Style Status Total Downloads

This package provides Artisan commands to quickly dump and load databases in a Laravel application.

# Create a dump
php artisan snapshot:create my-first-dump

# Make some changes to your db
# ...

# Create another dump
php artisan snapshot:create my-second-dump

# Load up the first dump
php artisan snapshot:load my-first-dump

# Load up the latest dump
php artisan snapshot:load --latest

# List all snapshots
php artisan snapshot:list

# Remove old snapshots. Keeping only the most recent
php artisan snapshot:cleanup --keep=2

This package supports MySQL, PostgreSQL and SQLite.

Support us

We invest a lot of resources into creating best in class open source packages. You can support us by buying one of our paid products.

We highly appreciate you sending us a postcard from your hometown, mentioning which of our package(s) you are using. You'll find our address on our contact page. We publish all received postcards on our virtual postcard wall.

Support us

We invest a lot of resources into creating best in class open source packages. You can support us by buying one of our paid products.

We highly appreciate you sending us a postcard from your hometown, mentioning which of our package(s) you are using. You'll find our address on our contact page. We publish all received postcards on our virtual postcard wall.

Installation

You can install the package via Composer:

composer require spatie/laravel-db-snapshots

You should add a disk named snapshots to app/config/filesystems.php on which the snapshots will be saved. This would be a typical configuration:

// ...
'disks' => [
    // ...
    'snapshots' => [
        'driver' => 'local',
        'root' => database_path('snapshots'),
    ],
// ...    

Optionally, you may publish the configuration file with:

php artisan vendor:publish --provider="Spatie\DbSnapshots\DbSnapshotsServiceProvider" --tag="config"

This is the content of the published file:

return [

    /**
     * The name of the disk on which the snapshots are stored.
     */
    'disk' => 'snapshots',

    /**
     * The connection to be used to create snapshots. Set this to null
     * to use the default configured in `config/database.php`
     */
    'default_connection' => null,

    /**
     * The directory where temporary files will be stored.
     */
    'temporary_directory_path' => storage_path('app/laravel-db-snapshots/temp'),

    /*
     * Create dump files that are gzipped
     */
    'compress' => false,
];

Usage

To create a snapshot (which is just a dump from the database) run:

php artisan snapshot:create my-first-dump

Giving your snapshot a name is optional. If you don't pass a name the current date time will be used:

# Creates a snapshot named something like `2017-03-17 14:31`
php artisan snapshot:create

When creating snapshots, you can optionally create compressed snapshots. To do this either pass the --compress option on the command line, or set the db-snapshots.compress configuration option to true:

# Creates a snapshot named my-compressed-dump.sql.gz
php artisan snapshot:create my-compressed-dump --compress

After you've made some changes to the database you can create another snapshot:

php artisan snapshot:create my-second-dump

To load a previous dump issue this command:

php artisan snapshot:load my-first-dump

To load a previous dump to another DB connection:

php artisan snapshot:load my-first-dump --connection=connectionName

To list all the dumps run:

php artisan snapshot:list

A dump can be deleted with:

php artisan snapshot:delete my-first-dump

To remove all backups except the most recent 2

php artisan snapshot:cleanup --keep=2

If you need to pass extra options to the underlying db-dumper, add a dump key to the database connection with a key of addExtraOptions and a value of the option. For example, to prevent the Postgres db dumper from setting the owner, you'd add:

'dump' => [
    'addExtraOption' => '--no-owner',
],

To the pgsql connection in database.php

Events

There are several events fired which can be used to perform some logic of your own:

  • Spatie\DbSnapshots\Events\CreatingSnapshot: will be fired before a snapshot is created
  • Spatie\DbSnapshots\Events\CreatedSnapshot: will be fired after a snapshot has been created
  • Spatie\DbSnapshots\Events\LoadingSnapshot: will be fired before a snapshot is loaded
  • Spatie\DbSnapshots\Events\LoadedSnapshot: will be fired after a snapshot has been loaded
  • Spatie\DbSnapshots\Events\DeletingSnapshot: will be fired before a snapshot is deleted
  • Spatie\DbSnapshots\Events\DeletedSnapshot: will be fired after a snapshot has been deleted

Changelog

Please see CHANGELOG for more information what has changed recently.

Testing

composer test

Contributing

Please see CONTRIBUTING for details.

Security

If you discover any security related issues, please email [email protected] instead of using the issue tracker.

Credits

License

The MIT License (MIT). Please see License File for more information.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].