1. Go to this page and download the library: Download smwks/laravel-db-snapshots library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
smwks / laravel-db-snapshots example snippets
'filesystem' => [
'local_disk' => 'local',
'local_path' => 'db-snapshots',
'archive_disk' => 's3', // any configured disk, or 'cloud' to use your default cloud disk
'archive_path' => 'db-snapshots',
],
'plans' => [
'daily' => [
'connection' => null, // null = use default connection; driver auto-detected
'file_template' => 'db-snapshot-daily-{date:Ymd}',
'dump_options' => '--single-transaction --no-tablespaces',
'schema_only_tables' => ['failed_jobs'], // dump structure only, no data
'tables' => [], // empty = all tables
'ignore_tables' => [], // tables to skip entirely
'keep_last' => 1, // number of snapshots to retain during cleanup
'environment_locks' => [
'create' => 'production', // only allow creation in this environment
'load' => 'local', // only allow loading in this environment
],
'post_load_sqls' => [
// SQL to run after loading this plan's snapshot
// 'UPDATE users SET password = "$2y$10$..."',
],
],
],
'plan_groups' => [
'all-daily' => [
'plans' => ['daily-main', 'daily-analytics'],
'post_load_sqls' => [
// SQL to run after ALL plans in the group have loaded
'ANALYZE TABLE users',
],
],
],
'cache_by_default' => false, // set to true to enable smart caching globally