Skip to content

Commit

Permalink
Fix: Import db task with ddev
Browse files Browse the repository at this point in the history
  • Loading branch information
jonnitto authored Mar 3, 2022
1 parent 7674626 commit 5c5bec8
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 6 deletions.
3 changes: 3 additions & 0 deletions Installer/Distribution/Defaults/deploy.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -13,5 +13,8 @@ domain.tld:
# Put here the ssh repository
repository: git@github.com:__OWNER__/__REPOSITORY__.git

# Set this to true if you use ddev for local development
ddev: false

# Add here the slack webhook (optional)
# slack_webhook: https://hooks.slack.com/services/__YOUR/SLACK/WEBHOOK__
5 changes: 5 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -169,6 +169,10 @@ Run these tasks with `dep COMMAND`. If you want to list all commands, enter `dep
| `config:dump` | Print host configuration |
| `config:hosts` | Print all hosts |

## Usage with ddev

If you use [ddev] for local development, the task `dep flow:import` will not work. You have to enable the setting `ddev` to `true` to make it work. Please run this task not inside the container.

## Slack notifications

The parameter `slack_webhook` accepts an array with strings beside a simple string.
Expand Down Expand Up @@ -392,6 +396,7 @@ git_commit_types:
[deployer]: https://deployer.org
[neos cms]: https://www.neos.io
[example]: example
[ddev]: https://ddev.com
[slack webhook]: https://slack.com/oauth/authorize?&client_id=113734341365.225973502034&scope=incoming-webhook
[let's encrypt]: https://letsencrypt.org
[uberspace]: https://uberspace.de/
Expand Down
16 changes: 10 additions & 6 deletions functions/database.php
Original file line number Diff line number Diff line change
Expand Up @@ -111,12 +111,16 @@ function dbBackup(): void
*/
function importLocalDb(): void
{
// Create a dump from the local installation
$yaml = runLocally("./flow configuration:show --type Settings --path Neos.Flow.persistence.backendOptions");
$settings = Yaml::parse($yaml);
$port = $settings['port'] ?? '3306';
runLocally("mysqldump -h {$settings['host']} -P {$port} -u {$settings['user']} -p{$settings['password']} {$settings['dbname']} | xz > dump.sql.xz");

if (get('ddev')) {
// Create a dump with ddev
runLocally("ddev export-db > dump.sql.xz");
} else {
// Create a dump from the local installation
$yaml = runLocally("./flow configuration:show --type Settings --path Neos.Flow.persistence.backendOptions");
$settings = Yaml::parse($yaml);
$port = $settings['port'] ?? '3306';
runLocally("mysqldump -h {$settings['host']} -P {$port} -u {$settings['user']} -p{$settings['password']} {$settings['dbname']} | xz > dump.sql.xz");
}
// Upload file, extract it and remove dump files
upload('dump.sql.xz', '{{release_path}}');
cd('{{release_path}}');
Expand Down

0 comments on commit 5c5bec8

Please sign in to comment.