Skip to content
This repository has been archived by the owner on Jul 23, 2020. It is now read-only.

Commit

Permalink
Merge pull request #13 from weareferal/develop
Browse files Browse the repository at this point in the history
Added missing database backup command
  • Loading branch information
timmyomahony authored Feb 6, 2020
2 parents c64f628 + 0120bc4 commit 1164442
Show file tree
Hide file tree
Showing 4 changed files with 90 additions and 9 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
.env.sh
.env

composer.lock

# COMPOSER
/vendor

Expand Down
46 changes: 45 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
- 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
35 changes: 27 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand All @@ -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 [[email protected]](mailto:[email protected]?subject=Craft%20Env%20Sync%20Question)
16 changes: 16 additions & 0 deletions src/console/controllers/DatabaseController.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
*/
Expand Down

0 comments on commit 1164442

Please sign in to comment.