A small helper Plugin for CraftCMS to download the DB over HTTP requiring authorization.
This plugin requires Craft CMS 3.0.0-beta.23 or later.
To install the plugin, follow these instructions.
-
Open your terminal and go to your Craft project:
cd /path/to/project
-
Then tell Composer to load the plugin:
composer require pjanser/craft-db-extract
-
In the Control Panel, go to Settings → Plugins and click the “Install” button for craft-db-extract.
This plugin makes a web controller action available to pull the database export.
The controller action requires an admin login. Provide your credentials in the Authoirization header with basic authentication.
HTTP Header:
Authorization: Basic xxxxxxxxxxxx
Tip: If you experience 401 Unauthorized eventhough you provide correct admin credentials, you can try to add the following line to your .htaccess
:
SetEnvIf Authorization (.+) HTTP_AUTHORIZATION=$0
Pulling the database in *.sql format:
GET YOUR_WEBSITE/actions/craft-db-extract/db-export
Pulling the database in *.sql.gz format:
GET YOUR_WEBSITE/actions/craft-db-extract/db-export?compression=gzip
Some things to do, and ideas for potential features:
- Authorization with user token
- Add different compressions
- Configurable filename for response
Brought to you by P. Janser