Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Accept closure for backup/restore commands #14897

Merged
merged 6 commits into from
Apr 29, 2024

Conversation

timkelty
Copy link
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.

@brandonkelly brandonkelly merged commit 7f8c1fb into 4.9 Apr 29, 2024
8 checks passed
@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.

None yet

2 participants