Download the PHP package spatie/laravel-db-snapshots without Composer
On this page you can find all versions of the php package spatie/laravel-db-snapshots. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download spatie/laravel-db-snapshots
More information about spatie/laravel-db-snapshots
Files in spatie/laravel-db-snapshots
Package laravel-db-snapshots
Short Description Quickly dump and load databases
License MIT
Homepage https://github.com/spatie/laravel-db-snapshots
Informations about the package laravel-db-snapshots
Quickly dump and load databases
This package provides Artisan commands to quickly dump and load databases in a Laravel application.
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
For PHP 7.x and/or Laravel 6.x, use v1.x of this package.
You can install the package via Composer:
You should add a disk named snapshots
to config/filesystems.php
on which the snapshots will be saved. This would be a typical configuration:
Optionally, you may publish the configuration file with:
This is the content of the published file:
Usage
To create a snapshot (which is just a dump from the database) run:
Giving your snapshot a name is optional. If you don't pass a name the current date time will be used:
Maybe you only want to snapshot a couple of tables. You can do this by passing the --table
multiple times or as a comma separated list:
You may want to exclude some tables from snapshot. You can do this by passing the --exclude
multiple times or as a comma separated list:
Note: if you pass
--table
and--exclude
in the same time it will use--table
to create the snapshot and it's ignore the--exclude
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
:
After you've made some changes to the database you can create another snapshot:
To load a previous dump issue this command:
To load a previous dump to another DB connection:
By default, snapshot:load
will drop all existing tables in the database. If you don't want this behaviour, you can pass the --drop-tables=0
option:
By default, snapshot:load
will load the entire snapshot into memory which may cause problems when using large files. To avoid this, you can pass the --stream
option to stream the snapshot to the database one statement at a time:
To list all the dumps run:
A dump can be deleted with:
To remove all backups except the most recent 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 addExtraOption
and a value of the option. For example, to prevent the Postgres db dumper from setting the owner, you'd add:
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 createdSpatie\DbSnapshots\Events\CreatedSnapshot
: will be fired after a snapshot has been createdSpatie\DbSnapshots\Events\LoadingSnapshot
: will be fired before a snapshot is loadedSpatie\DbSnapshots\Events\LoadedSnapshot
: will be fired after a snapshot has been loadedSpatie\DbSnapshots\Events\DeletingSnapshot
: will be fired before a snapshot is deletedSpatie\DbSnapshots\Events\DeletedSnapshot
: will be fired after a snapshot has been deleted
Testing
Changelog
Please see CHANGELOG for more information on what has changed recently.
Contributing
Please see CONTRIBUTING for details.
Security Vulnerabilities
Please review our security policy on how to report security vulnerabilities.
Credits
- Freek Van der Herten
- All Contributors
License
The MIT License (MIT). Please see License File for more information.
All versions of laravel-db-snapshots with dependencies
illuminate/support Version ^7.0|^8.0|^9.0|^10.0|^11.0
league/flysystem Version ^1.0.41|^2.0|^3.0
spatie/db-dumper Version ^3.3
spatie/laravel-package-tools Version ^1.6
spatie/temporary-directory Version ^2.0