-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add backup and restore commands (#27)
* Create simple way to ask for site * Initial version of backup command * wip * Restore database as part of restore process * Update Restore.php * Implement backup and restore using terminal commands * Prefer kebab case for backup names * Add notes * wip * Prompt changes * Update Backup.php * Add missing return types * Clean up * Document class * Bail on backup if database export fails * Add docs * Update README.md * Update Backup.php
- Loading branch information
1 parent
09b7ab8
commit 64a050a
Showing
11 changed files
with
475 additions
and
142 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
<?php | ||
|
||
namespace App\Commands; | ||
|
||
use function Laravel\Prompts\error; | ||
use function Laravel\Prompts\text; | ||
|
||
use LaravelZero\Framework\Commands\Command; | ||
|
||
class Backup extends SiteCommand | ||
{ | ||
/** | ||
* The name and signature of the console command. | ||
* | ||
* @var string | ||
*/ | ||
protected $signature = 'backup'; | ||
|
||
/** | ||
* The console command description. | ||
* | ||
* @var string | ||
*/ | ||
protected $description = 'Backup a site'; | ||
|
||
/** | ||
* Execute the console command. | ||
*/ | ||
public function handle(): void | ||
{ | ||
$site = $this->ask_user_for_site('Select a site to backup'); | ||
$name = text( | ||
label: 'Pick a name for the backup', | ||
placeholder: 'backup-name', | ||
required: true, | ||
validate: function (string $value) { | ||
if (!$this->is_valid_kebab_name($value)) { | ||
return 'Only lowercase letters, numbers, and hyphens are allowed'; | ||
} | ||
|
||
return null; | ||
}, | ||
); | ||
$success = $site->backup($name); | ||
|
||
if (!$success) { | ||
error('Unable to run backup'); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.