Skip to content

Accept closure for backup/restore commands#14897

Merged
brandonkelly merged 6 commits into4.9from
feature/backup-restore-closure
Apr 29, 2024
Merged

Accept closure for backup/restore commands#14897
brandonkelly merged 6 commits into4.9from
feature/backup-restore-closure

Conversation

@timkelty
Copy link
Copy Markdown
Contributor

@timkelty timkelty commented Apr 29, 2024

Description

  • adds \Closure as an accepted type for \craft\config\GeneralConfig::$restoreCommand and \craft\config\GeneralConfig::$backupCommand
    • function(ShellCommand $command) => ShellCommand
  • adds \craft\config\GeneralConfig::$backupCommandFormat (pg only) for using archive format
    • also changes restore to use pg_restore to be compatible with create dumps
    • changes extension to be .dump

Example usage

<?php
use craft\config\GeneralConfig;

return GeneralConfig::create()
    ->backupCommandFormat('custom')
    ->backupCommand(fn(\mikehaertl\shellcommand\Command $command) => $command
        ->addArg('--clean')
        ->addArg('--if-exists')
    );

Related issues

Replaces #14586

Notes

  • For MySQL, both the "schema dump" and the "data dump" get passed through the \Callable. This would allow someone to have different behavior in either one by looking for --no-data or --no-create-info.
  • It might make more sense to have backupCommandFormat be in \craft\config\DbConfig, but it felt weird to have it separated from backupCommand.

@timkelty timkelty changed the base branch from 5.x to 4.9 April 29, 2024 20:45
Comment thread src/console/controllers/DbController.php
@brandonkelly brandonkelly merged commit 7f8c1fb into 4.9 Apr 29, 2024
@brandonkelly brandonkelly deleted the feature/backup-restore-closure branch April 29, 2024 23:17
brandonkelly added a commit that referenced this pull request Apr 29, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants