sprint-digital/sprint-backup

This is my package sprint-backup

11.0.1 2024-04-12 04:35 UTC

README

Latest Version on Packagist GitHub Tests Action Status GitHub Code Style Action Status Total Downloads

Back up and secure database to AWS S3. Then redistribute the backup to other team environments.

DO NOT SKIP THIS STEP!!! please read AWS setup HERE.

Installation

You can install the package via composer:

composer require sprint-digital/sprint-backup

Add environment variables to your .env file:

BACKUP_AWS_ACCESS_KEY_ID=
BACKUP_AWS_SECRET_ACCESS_KEY=
BACKUP_AWS_DEFAULT_REGION=ap-southeast-2
BACKUP_AWS_BUCKET=sprint-db-bucket
BACKUP_AWS_USE_PATH_STYLE_ENDPOINT=false
BACKUP_ARCHIVE_PASSWORD="{zipSecret}"
BACKUP_AWS_PATH="{repoName}"
BACKUP_MASTER_PASSWORD="{userPassword}"

Add the following to your config/filesystems.php in disks array:

's3-backup' => [
    'driver' => 's3',
    'key' => env('BACKUP_AWS_ACCESS_KEY_ID'),
    'secret' => env('BACKUP_AWS_SECRET_ACCESS_KEY'),
    'region' => env('BACKUP_AWS_DEFAULT_REGION'),
    'bucket' => env('BACKUP_AWS_BUCKET'),
    'url' => env('BACKUP_AWS_URL') . '/' . env('BACKUP_AWS_PATH'),
    'endpoint' => env('BACKUP_AWS_ENDPOINT'),
    'use_path_style_endpoint' => env('BACKUP_AWS_USE_PATH_STYLE_ENDPOINT', false),
    'throw' => false,
],

You can publish the config file with:

php artisan backup:install

Backup database:

php artisan backup:to-sprint

Restore database:

php artisan backup:restore
# or auto run the last backup
php artisan backup:restore --last-backup

In some cases the .sql file is too large to be restored. You need to increase the memory limit in your php.ini file.

Production / Staging

You might have to install mysql on your server. (ie. worker servers)

sudo apt-get install -y default-mysql-client

Testing

composer test

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

License

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