Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 4 additions & 13 deletions recipe/craftcms.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,17 +28,9 @@
]);

// Custom Craft Tasks
desc('Backup DB prior to deployment');
task('craft:backup-db', function () {
writeln('Backing up Craft DB to storage/backups');
craft('db/backup', ['showOutput' => true]);
});

desc('Restore DB after deployment failure');
task('craft:restore-db', function () {
$latest = run("ls -t storage/backups/ | head -n1");
writeln(sprintf('Restoring Craft DB from storage/backups/%s', $latest));
craft(sprintf('db/restore storage/backups/%s', $latest), ['showOutput' => true]);
desc('Output warning after deployment failure');
task('craft:fail-warning', function () {
warning('The Craft deployment failed, please review DB backups (storage/backups) to assess whether you need to restore the database.');
});

// @deprecated Not sure if this is still required
Expand All @@ -56,10 +48,9 @@
task('deploy', [
'deploy:prepare',
'deploy:vendors',
'craft:backup-db',
'craft:up',
'craft:clear-caches/all',
'deploy:publish',
]);

after('deploy:failed', 'craft:restore-db');
after('deploy:failed', 'craft:fail-warning');