This is a Laravel package that creates a console command to backup a file to Amazon S3.
Via Composer -
$ composer require escuccim/s3backup
Register the class in config/app.php 'providers' array:
Escuccim\S3Backup\S3BackupServiceProvider::class,
You must specify the credentials to your Amazon S3 bucket in your .env file as follows:
AWS_ACCESS_KEY_ID=
AWS_SECRET_ACCESS_KEY=
AWS_REGION=
AWS_BUCKET=
php artisan backup:db {--path=} {--db=} {--user=} {--dest=} {--keep} {--p} {--pass=}
This will dump the database specified in your .env file to your /database/ directory, upload the dump to S3, and then delete it locally.
Options:
All of these parameters are optional and if not specified defaults will be taken from the .env file.
Note that --p is used to specify if you want to use a password at all, if you do not have a password for the local account or have credentials stored in a .my.cnf file you can omit this.
--pass= is used to specify a password, if you wish to use it you MUST use the --p flag as well. If you use --p with no password specified the password will be taken from the .env file.
php artisan backup:file [file] [--dest=location to upload file to]
{file} is the path to the file to upload relative to your project root. {dest} is the location to upload the file to. The file will keep the same name.
Do not use trailing or leading "/"s on either the file or the destination.
php artisan backup:dir [path] [--dest=location to upload file to] [--ext=file extension]
Where path is the path to the directory relative to the base path and dest is the base key to upload the files to. The final destination of the files will replace the path parameter with the dest parameter.
If you specify a file extension only files matching that will be uploaded.
The MIT License (MIT).