wearejh/stripped-db-provider

There is no license information available for the latest version (1.3.2) of this package.

Stripped DB Provider for Magento 2

Installs: 6 718

Dependents: 0

Suggesters: 0

Security: 0

Stars: 0

Watchers: 8

Forks: 0

Open Issues: 0

Type:magento2-module

1.3.2 2024-08-14 08:45 UTC

README

This module can be configured to automatically send stripped databases periodically into an Amazon S3 Bucket in the cloud.

Installation

Add the following repositories to the repositories section of your composer.json

{"type": "vcs", "url": "git@github.com:WeareJH/stripped-db-provider.git"},

Then install like any regular composer package

composer require wearejh/stripped-db-provider

Configuration

There are two areas of configuration. The first is project specific config, which is set in config.php and gets commited to the repository. The second is environment specific configuration which is added to the env.php file directly on the server.

Project Specific Configuration

All databases are stripped by default but you can define project specific tables whose data you wish to not be included in the dump by adding the following to your config.php file:

'system' => [
        'default' => [
            'stripped_db_provider' => [
                'dump' => [
                    'project_ignore_tables' => ['example_table_a', 'example_table_b']
                ]
            ]
        ]
    ]

Where project_ignore_tables is a list of project specfic tables.

Environment Specific Configuration

Once Installed and deployed to production, you will want to configure it so that it automatically sends stripped DBs to the S3 Bucket. You would ned to add access_key_id & secret_access_key as encrypted value. So you can mention these values in admin which will auto encrypt these values. Edit the env.php file manually and set the following config (values below are examples):

'system' => [
        'default' => [
            'stripped_db_provider' => [
                'general' => [
                    'enabled' => '1',
                    'project_name' => 'example-project',
                    'cron_expr' => '0 4 * * 0'
                ],
                'storage' => [
                    'bucket_name' => 'example-bucket-name',
                    'region' => 'example-bucket-region',
                    'access_key_id' => 'example-bucket-access-key',
                    'secret_access_key' => 'example-bucket-secret-access-key'
                ]
            ]
        ]
    ]

You can add access_key_id, secret_access_key, bucket_name, region from admin also by logging in admin. Go to Store->Configuration->Advanced->Stripped DB Provider

Values are described in the following table:

The Amazon S3 Bucket Details should be in LastPass. Ask your fellow developers if you can't find it or need help setting up.

After you have edited the env.php file, run the following command immediately :

bin/magento app:config:import

Run upload manually

You can also manually trigger the stripped database upload from the command line by running the following command :

bin/magento wearejh:stripped-db-provider:upload-to-remote 

To do a full DB dump

bin/magento wearejh:stripped-db-provider:upload-to-remote --full

Import a remote dump locally

You can use the module to import a dump from S3 directly to your local. It will back up your local admin accounts and reimport them

bin/magento wearejh:stripped-db-provider:import-from-remote PROJECT NAME 

To skip admin accounts backup

bin/magento wearejh:stripped-db-provider:import-from-remote PROJECT NAME --no-admin-backup=1 

Config backup

The config-backup option accepts 3 values:

  • skip - skips the backup of local config and imports everything from the remote
  • merge - backs up only the paths configured under stripped_db_provider/dump/config_paths_keep (accepts MySQL wildcards %), imports everything from the remote and merges the backed up config with the remote config
  • preserve-local - backs up the whole core_config_data and restores it after the DB import from remote
bin/magento wearejh:stripped-db-provider:import-from-remote PROJECT NAME --config-backup=merge

Issues / Feature Request

Please open github issues for any issues you encounter or feature requests you want to see. PRs are of course welcomed.

Troubleshooting

If any project has 0.3.3 version installed of this module, getting a dependency error related to module: ifsnop/mysqldump-php ^2.12 while upgrading module to latest version then remove the below line from composer.json file of project root folder: { "type": "vcs", "url": "git@github.com:maciejslawik/mysqldump-php.git" }