https://github.com/logisticinfotech/laravel-database-snapshot-from-admin-ui
Laravel Database Snapshot from Admin UI
https://github.com/logisticinfotech/laravel-database-snapshot-from-admin-ui
database database-backup laravel laravel-admin snapshot
Last synced: 5 days ago
JSON representation
Laravel Database Snapshot from Admin UI
- Host: GitHub
- URL: https://github.com/logisticinfotech/laravel-database-snapshot-from-admin-ui
- Owner: logisticinfotech
- Created: 2019-04-25T09:07:27.000Z (about 7 years ago)
- Default Branch: master
- Last Pushed: 2023-01-03T20:27:06.000Z (over 3 years ago)
- Last Synced: 2025-01-02T07:10:26.037Z (over 1 year ago)
- Topics: database, database-backup, laravel, laravel-admin, snapshot
- Language: PHP
- Size: 2.86 MB
- Stars: 1
- Watchers: 4
- Forks: 0
- Open Issues: 24
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README

# Laravel Database Snapshot Admin UI
Laravel Database Snapshot Admin UI is one type of admin panel in which you can take a snapshot of the database, show previously taken database snapshot list, download snapshot SQL file and delete the snapshot file.
- **Create a Laravel Project**
Laravel new db-snapshot-admin-UI
- **Install Database Snapshot Package Via Composer**
composer require spatie/laravel-db-snapshots
- **Service Provider Configuration**
If Laravel 5.4 or below version you must add below code otherwise it will be auto-registered.
Open the file config/app.php and then add following service provider
```
'providers' => [
// ...
Spatie\DbSnapshots\DbSnapshotsServiceProvider::class,
];
```
- **Filesystem Configuration**
In config/filesystems.php add following code for creating snapshot disk on which all snapshots will be saved. You can change the driver and root values.
```
// ...
'disks' => [
// ...
'snapshots' => [
'driver' => 'local',
'root' => storage_path('snapshots'),
],
// ...
```
- **Publish The Configuration File**
This is optional, you may publish the configuration file using this command to customize your setting.
php artisan vendor:publish --provider="Spatie\DbSnapshots\DbSnapshotsServiceProvider" --tag="config"
- **Create an admin login using laravel auth**
php artisan make:auth
- **Database configuration**
In Env file, specify the value of host, database name, user name, password.
```
DB_HOST=YOUR_HOST
DB_DATABASE=YOUR_DATABASE
DB_USERNAME=YOUR_USERNAME
DB_PASSWORD=YOUR_PASSWORD
```
- **Create Migrations**
- **Create Database Snapshot**
```
Artisan::call('snapshot:create '.$snapshot_name);
```
- **Download Snapshot file**
return response()->download(storage_path("snapshots/".$snapshot_name.'.sql'));
- **Delete Snapshot file**
Artisan::call('snapshot:delete '.$snapshot_name);
- **Some useful console commands for database snapshot**
```
php artisan snapshot:create file-name // create snapshot with given name
php artisan snapshot:create // current date time used for file name to create snapshot
php artisan snapshot:create file-name --compress // create compressed snapshots
php artisan snapshot:load file-name // Load Snapshot
php artisan snapshot:load file-name --connection=connectionName
//Specify connection name when use multiple db connection
php artisan snapshot:list // List of all snapshots
php artisan snapshot:delete file-name // Delete snapshot
```
- **Some useful events**
```
Spatie\DbSnapshots\Events\CreatingSnapshot // Event will be fired before a snapshot is created
Spatie\DbSnapshots\Events\CreatedSnapshot // Event will be fired after a snapshot has been created
Spatie\DbSnapshots\Events\LoadingSnapshot // Event will be fired before a snapshot is loaded
Spatie\DbSnapshots\Events\LoadedSnapshot // Event will be fired after a snapshot has been loaded
Spatie\DbSnapshots\Events\DeletingSnapshot // Event will be fired before a snapshot is deleted
Spatie\DbSnapshots\Events\DeletedSnapshot // Event will be fired after a snapshot has been deleted
```
[Click here](https://github.com/spatie/laravel-db-snapshots) to view Laravel Database Snapshot Package
For full document please read our [blog](https://www.logisticinfotech.com/blog/laravel-database-snapshot/) here.