diff --git a/.gitignore b/.gitignore index a17970c..c7592b8 100644 --- a/.gitignore +++ b/.gitignore @@ -3,6 +3,8 @@ .env.sh .env +composer.lock + # COMPOSER /vendor diff --git a/CHANGELOG.md b/CHANGELOG.md index cb724bb..afffd2a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -44,4 +44,48 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/) and this p ### Changed -- Change name to env-sync to avoid name collision with the plugin store \ No newline at end of file +- Change name to env-sync to avoid name collision with the plugin store + +## 1.0.7 - 2020-01-23 + +### Changed + +- Fixed small typos in readme and license +- Changed branding and updated versioning string to correspond with Craft plugin naming + +## 1.0.8 - 2020-01-24 + +### Changed + +- Created custom database backup + +## 1.0.9 - 2020-01-25 + +### Changed + +- Fixed issues with volumes + +## 1.0.10 - 2020-01-25 + +### Changed + +- Improved error messages + +## 1.0.11 - 2020-01-25 + +### Changed + +- Bugfixes + +## 1.0.12 - 2020-01-29 + +### Changed + +- Fixed restore bug + +## 1.0.13 - 2020-02-06 + +### Changed + +- Add missing console command +- Updated docs diff --git a/README.md b/README.md index 4cca837..26f8a05 100644 --- a/README.md +++ b/README.md @@ -68,10 +68,36 @@ AWS_BUCKET_PREFIX = "craft-backups/my-site" ![Craft Env Sync Utilities Screenshot](resources/img/utilities-screenshot.png) +### Control Panel + Once you have entered your settings variables you should be able to use the "sync" tab on the "utilities" section of the control panel. There are two broad sections: one for the database and one for volume assets. Each section has four options to create a local backup, push that local backup to S3, pull all remote backups _from_ S3 and finally to restore a particular backup. +### Command Line + +There are also console commands available for creating, pushing and pulling backups: + +```sh +- env-sync/database Sync database backups + env-sync/database/create-backup Create a local database backup + env-sync/database/pull Pull remote database backups from cloud + env-sync/database/push Push local database backups to cloud + +- env-sync/volumes Sync volumes backup + env-sync/volumes/create-backup Create a local volumes backup + env-sync/volumes/pull Pull remote volume backups from cloud + env-sync/volumes/push Push local volume backups to cloud +``` + +For example: + +```sh +./craft env-sync/database/create-backup +``` + +These commands can be used alongside cron or your deployment scripts to automatically/periodically create backups. + ## Functionality All local backups are stored in the existing `storage/backups` folder that Craft uses for its own database backup script. @@ -84,11 +110,4 @@ For volume assets backups, we simply create a versioned zip file containing the If you are getting errors when you try to pull/push databases or assets, the first thing to check is the Craft logs at `storage/logs/web.log`. All errors should be logged here. The most likely issue is with your credentials, so double check that those are OK. -## Roadmap - -Some things to do, and ideas for potential features: - -- Add a "test details" button in the settings page to immediately test S3 connection -- Add more providers - -Brought to you by [Feral](https://weareferal.com) +Brought to you by [Feral](https://weareferal.com). Any issues email [timmy@weareferal.com](mailto:timmy@weareferal.com?subject=Craft%20Env%20Sync%20Question) diff --git a/src/console/controllers/DatabaseController.php b/src/console/controllers/DatabaseController.php index f44adc3..a9a3908 100644 --- a/src/console/controllers/DatabaseController.php +++ b/src/console/controllers/DatabaseController.php @@ -28,6 +28,22 @@ */ class DatabaseController extends Controller { + /** + * Create a local database backup + */ + public function actionCreateBackup() + { + try { + Sync::getInstance()->sync->createDatabaseBackup(); + } catch (\Exception $e) { + Craft::$app->getErrorHandler()->logException($e); + $this->stderr('error: ' . $e->getMessage() . PHP_EOL, Console::FG_RED); + return ExitCode::UNSPECIFIED_ERROR; + } + $this->stdout("Created local database backup" . PHP_EOL, Console::FG_GREEN); + return ExitCode::OK; + } + /** * Push local database backups to cloud */