Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

jimmck's avatar
jimmck
Best Answer
Level 13

@istables Hi, Installed backup package and it worked out of the box to my AWS server instance. My bucket is jimmck-holmdel. Couple of things. The backup software created a backups subdir inside my bucket.

I think your bucket name is crmple-backups

Don't be confused by the URL of the console dump.

I have the AWS package installed. I also installed the league service and they play nice together!! And thanks to you and the install of the backup package I learned that the config.php file is a source file and the artisan command to publish the config.php file copies that to app/config and renames it aws.php. I put my config info in there and my own s3 code runs using aws.php. So Thanks!! I dont need to edit the vendor config.

And when I setup the filesystem.php with my aws.php creds all is fine.

aws.php file <-- used by default when not directly specified

<?php
return [

    /*
    |--------------------------------------------------------------------------
    | Your AWS Credentials
    |--------------------------------------------------------------------------
    |
    | In order to communicate with an AWS service, you must provide your AWS
    | credentials including your AWS Access Key ID and AWS Secret Access Key.
    |
    | To use credentials from your credentials file or environment or to use
    | IAM Instance Profile credentials, please remove these config settings from
    | your config or make sure they are null. For more information, see:
    | http://docs.aws.amazon.com/aws-sdk-php-2/guide/latest/configuration.html
    |
    */
    'key'    => env('AWS_ACCESS_KEY_ID', 'ABCDEF'),
    'secret' => env('AWS_SECRET_ACCESS_KEY', 'WXWZABCDEF'),

    /*
    |--------------------------------------------------------------------------
    | AWS Region
    |--------------------------------------------------------------------------
    |
    | Many AWS services are available in multiple regions. You should specify
    | the AWS region you would like to use, but please remember that not every
    | service is available in every region. To see what regions are available,
    | see: http://docs.aws.amazon.com/general/latest/gr/rande.html
    |
    */
    'region' => env('AWS_REGION', 'us-west-2'),

    /*
    |--------------------------------------------------------------------------
    | AWS Config File Location
    |--------------------------------------------------------------------------
    |
    | Instead of specifying your credentials and region here, you can specify
    | the location of an AWS SDK for PHP config file to use. These files provide
    | more granular control over what credentials and regions you are using for
    | each service. If you specify a filepath for this configuration setting,
    | the others in this file will be ignored. See the SDK user guide for more
    | information: http://docs.aws.amazon.com/aws-sdk-php-2/guide/latest/configuration.html#using-a-custom-configuration-file
    |
    */
    'config_file' => env('AWS_CONFIG_FILE'),

];

backups is the subdir created in my bucket

My filesystem.php

        's3' => [
            'driver' => 's3',  
            'key'    => 'xxxxxx',
            'secret' => 'xxxxxxxxxxxx',
            'region' => 'us-west-2',
            'bucket' => 'jimmck-holmdel',
        ],

my backup config...

    'destination' => [

        /*
         * The filesystem(s) you on which the backups will be stored. Choose one or more
         * of the filesystems you configured in app/config/filesystems.php
         */
        //'filesystem' => ['local'],
        'filesystem' => ['s3'],
        /*

use what ever region worked in the past. change your bucket name.

Verify your s3 settings on your console.

jimmck's avatar

@istables Here is your url to your s3 storage:

https://crmple-backups.s3-eu-west-1.amazonaws.com

When you hit this in the browser you get this XML message.

<ListBucketResult xmlns="http://s3.amazonaws.com/doc/2006-03-01/">
<Name>crmple-backups</Name>
<Prefix/>
<Marker/>
<MaxKeys>1000</MaxKeys>
<IsTruncated>false</IsTruncated>
<Contents>
<Key>logs/2015-05-08-22-17-48-38540A4C36CCA051</Key>
<LastModified>2015-05-08T22:17:49.000Z</LastModified>
<ETag>"6235f98ed67bd52a148325a1ad3fbec3"</ETag>
<Size>297</Size>
<StorageClass>STANDARD</StorageClass>
</Contents>
<Contents>
<Key>logs/2015-05-08-22-18-25-21FE6DAAC9794384</Key>
<LastModified>2015-05-08T22:18:26.000Z</LastModified>
<ETag>"0d4307769d1d68b8a56d827e65302f0b"</ETag>
<Size>325</Size>
<StorageClass>STANDARD</StorageClass>
</Contents>
<Contents>
<Key>logs/2015-05-08-22-21-20-FAF66A45DFEB382D</Key>
<LastModified>2015-05-08T22:21:21.000Z</LastModified>
<ETag>"35010f9fe4a6a99476982d6b33e9a776"</ETag>
<Size>1265</Size>
<StorageClass>STANDARD</StorageClass>
</Contents>
<Contents>
...

it goes on from there...

What does s3 config look like in filesystems.php? Your URL gets generated off of that.

jimmck's avatar

@istables You need to close your settings. I can put files to your bucket using my creds?

<ListBucketResult xmlns="http://s3.amazonaws.com/doc/2006-03-01/">
<Name>crmple-backups</Name>
<Prefix/>
<Marker/>
<MaxKeys>1000</MaxKeys>
<IsTruncated>false</IsTruncated>
<Contents>
<Key>backups/</Key>
<LastModified>2015-05-09T06:56:07.000Z</LastModified>
<ETag>"d41d8cd98f00b204e9800998ecf8427e"</ETag>
<Size>0</Size>
<StorageClass>STANDARD</StorageClass>
</Contents>
<Contents>
<Key>backups/20150509065038.zip</Key>
<LastModified>2015-05-09T06:50:40.000Z</LastModified>
<ETag>"502dc6e857e42e992a110adc829ab85a"</ETag>
<Size>232</Size>
<StorageClass>STANDARD</StorageClass>
</Contents>
<Contents>
<Key>backups/20150509065605.zip</Key>
<LastModified>2015-05-09T06:56:07.000Z</LastModified>
<ETag>"502dc6e857e42e992a110adc829ab85a"</ETag>
<Size>232</Size>
<StorageClass>STANDARD</StorageClass>
</Contents>

My file system settings are

        's3' => [
            'driver' => 's3',
            'key'    => '<key>',
            'secret' => '<secret>',
            'region' => 'eu-west-1',
            'bucket' => 'crmple-backups',
        ],

They are going into backups dir as specified in backup config file.

jimmck's avatar

@istables Just to make sure I changed the name of the backup location in your bucket to backups-jim and reran artisan command ...

```

crmple-backups 1000 false backups-jim/ 2015-05-09T07:11:07.000Z "d41d8cd98f00b204e9800998ecf8427e" 0 STANDARD backups-jim/20150509071105.zip 2015-05-09T07:11:08.000Z "502dc6e857e42e992a110adc829ab85a" 232 STANDARD

The laravel backup config...
   /*
     * The filesystem(s) you on which the backups will be stored. Choose one or more
     * of the filesystems you configured in app/config/filesystems.php
     */
    //'filesystem' => ['local'],
    'filesystem' => ['s3'],
    /*
     * The path where the backups will be saved. This path
     * is relative to the root you configured on your chosen
     * filesystem(s).
     *
     * If you're using the local filesystem a .gitignore file will
     * be automatically placed in this directory so you don't
     * accidentally end up committing these backups.
     */
    'path' => 'backups-jim',

jimmck's avatar

@istables oops

<ListBucketResult xmlns="http://s3.amazonaws.com/doc/2006-03-01/">
<Name>crmple-backups</Name>
<Prefix/>
<Marker/>
<MaxKeys>1000</MaxKeys>
<IsTruncated>false</IsTruncated>
<Contents>
<Key>backups-jim/</Key>
<LastModified>2015-05-09T07:11:07.000Z</LastModified>
<ETag>"d41d8cd98f00b204e9800998ecf8427e"</ETag>
<Size>0</Size>
<StorageClass>STANDARD</StorageClass>
</Contents>
<Contents>
<Key>backups-jim/20150509071105.zip</Key>
<LastModified>2015-05-09T07:11:08.000Z</LastModified>
<ETag>"502dc6e857e42e992a110adc829ab85a"</ETag>
<Size>232</Size>
<StorageClass>STANDARD</StorageClass>
</Contents>
theUnforgiven's avatar

My laravel-backup.php config looks like:

<?php

return [

    'source' => [

        'files' => [

            /*
             * The list of directories that should be part of the backup. You can
             * specify individual files as well.
             */
            'include' => [
                base_path(),
            ],

            /*
             * These directories will be excluded from the backup.
             * You can specify individual files as well.
             */
            'exclude' => [
                storage_path(),
                base_path('vendor'),
            ],
        ],

        /*
         * Should the database be part of the back up.
         */
        'backup-db' => true,
    ],

    'destination' => [

        /*
         * The filesystem(s) you on which the backups will be stored. Choose one or more
         * of the filesystems you configured in app/config/filesystems.php
         */
        'filesystem' => ['s3'],

        /*
         * The path where the backups will be saved. This path
         * is relative to the root you configured on your chosen
         * filesystem(s).
         *
         * If you're using the local filesystem a .gitignore file will
         * be automatically placed in this directory so you don't
         * accidentally end up committing these backups.
         */
        'path' => '',

        /*
         * By default the backups will be stored as a zipfile with a
         * timestamp as the filename. With these options You can
         * specify a prefix and a suffix for the filename.
         */
        'prefix' => '',
        'suffix' => '',
    ],

    'clean' => [
        /*
         * The clean command will remove all backups on all configured filesystems
         * that are older then this amount of days.
         */
        'maxAgeInDays' => 180,
    ],

    'mysql' => [
        /*
         * The path to the mysqldump binary. You can leave this empty
         * if the binary is installed in the default location.
         */
        'dump_command_path' => '',

        /*
         * If your server supports it you can turn on extended insert.
         * This will result in a smaller dump file and speeds up the backup process.
         *
         * See: https://dev.mysql.com/doc/refman/5.1/en/mysqldump.html#option_mysqldump_extended-insert
         */
        'useExtendedInsert' => false,
    ],
];

theUnforgiven's avatar

Still getting the following error:

  [Aws\S3\Exception\S3Exception]
  The unspecified location constraint is incompatible for the region specific endpoint this request was sent to.

Going to here in management console http://cl.ly/image/3V2G2j1R2u2i to get the access and secret key's from.

theUnforgiven's avatar

It's now working looks like I had wrong creditionals installed (smacks head)

jimmck's avatar

It seems the creds contain region info. But I was able to hit your bucket. see if two files are in there. Did you see the XML records of your bucket URL. When I go to my AWS s3 bucket URL in browser. I get access denied XML response.

Jim

1 like
jimmck's avatar

How do do the screen shot thing? That would come in handy. I see your path is '' ok. Remember to lockdown your bucket!!

1 like
theUnforgiven's avatar

@jimmck to do screenshots within the forum you do ![](path/to/image)

Yeah locked it all done I think and is all working great now.

DO you know how I can get the list of zip files to show in a admin system i'm building with Laravel of course to show a list of them all with the option to download each one individually?

jimmck's avatar

Here is some code from the Filesystem service. Your s3 bucket is still open BTW. What is the exact syntax for the screen capture? The online doc is very brief and needs to expanded. You really need to read the code!

    \Route::get('files', function () {
        // Get a remote list of files.
        $disk = \Storage::disk('s3');
        $files = $disk->allFiles();
        print "<div>";
        foreach ($files as $file) {
            $modified = date(DATE_RFC2822, $disk->lastModified($file));
            $size = $disk->size($file);
            $type = $disk->mimeType($file);
            print "<li> $file : $modified ($size Bytes) : $type</li>";
        }
        print "</div>";
    });

    \Route::get('dirs', function () {
        // Get a remote list of dirs and files.
        $disk = \Storage::disk('s3');
        $dirs = $disk->allDirectories("./");
        print "<div>";
        foreach ($dirs as $dir) {
            print "<h3> $dir </h3>";
            $files = $disk->files($dir);
            foreach ($files as $file) {
                $modified = date(DATE_RFC2822, $disk->lastModified($file));
                $size = $disk->size($file);
                $type = $disk->mimeType($file);
                print "<li> $file : $modified ($size Bytes) : $type</li>";
            }
        }
        print "</div>";
    });

Previous

Please or to participate in this conversation.