mirror of
https://github.com/snipe/snipe-it.git
synced 2024-11-09 23:24:06 -08:00
Added ability to skip backup
Signed-off-by: snipe <snipe@snipe.net>
This commit is contained in:
parent
060e2126e2
commit
41bc802e8c
33
upgrade.php
33
upgrade.php
|
@ -36,6 +36,9 @@ if ($argc > 1){
|
|||
case '--no-interactive':
|
||||
$no_interactive = true;
|
||||
break;
|
||||
case '--skip-backup':
|
||||
$skip_backup = true;
|
||||
break;
|
||||
default: // for legacy support from before we started using --branch
|
||||
$branch = $argv[$arg];
|
||||
$branch_override = true;
|
||||
|
@ -396,12 +399,20 @@ if ($dirs_not_writable!='') {
|
|||
echo "--------------------------------------------------------\n";
|
||||
echo "STEP 4: Backing up database: \n";
|
||||
echo "--------------------------------------------------------\n\n";
|
||||
$backup = exec('php artisan snipeit:backup', $backup_results, $return_code);
|
||||
echo '-- ' . implode("\n", $backup_results) . "\n\n";
|
||||
if ($return_code > 0) {
|
||||
die("Something went wrong with your backup. Aborting!\n\n");
|
||||
|
||||
if (!$skip_backup) {
|
||||
|
||||
try {
|
||||
$return_code = backup();
|
||||
} catch (Exception $e) {
|
||||
echo 'Caught exception: '. $e->getMessage(). "\n";
|
||||
unset($return_code);
|
||||
}
|
||||
|
||||
} else {
|
||||
echo "Upgrader was run with --skip-backup, so no backup will be run.\n";
|
||||
}
|
||||
unset($return_code);
|
||||
|
||||
|
||||
echo "--------------------------------------------------------\n";
|
||||
echo "STEP 5: Putting application into maintenance mode: \n";
|
||||
|
@ -567,5 +578,17 @@ function str_ends($haystack, $needle) {
|
|||
return (substr_compare($haystack, $needle, -strlen($needle)) === 0);
|
||||
}
|
||||
|
||||
function backup() {
|
||||
|
||||
exec('php artisan snipeit:backup', $backup_results, $return_code);
|
||||
echo '-- ' . implode("\n", $backup_results) . "\n\n";
|
||||
|
||||
if ($return_code > 0) {
|
||||
throw new Exception('Something went wrong with your backup. Aborting!\n\n');
|
||||
}
|
||||
|
||||
return $return_code;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
|
Loading…
Reference in a new issue