mirror of
https://github.com/PhyreApps/PhyrePanel.git
synced 2024-11-21 23:20:24 +00:00
Update HostingSubscriptionBackup.php
This commit is contained in:
parent
a26d1c1cf1
commit
ed4798b531
1 changed files with 11 additions and 19 deletions
|
@ -146,21 +146,9 @@ class HostingSubscriptionBackup extends Model
|
|||
}
|
||||
|
||||
$storagePath = storage_path('backups');
|
||||
if (! is_dir($storagePath)) {
|
||||
mkdir($storagePath);
|
||||
}
|
||||
$backupPath = $storagePath.'/'.$this->backup_type.'/'.$this->id;
|
||||
if (!is_dir(dirname($backupPath))) {
|
||||
mkdir(dirname($backupPath));
|
||||
}
|
||||
if (! is_dir($backupPath)) {
|
||||
mkdir($backupPath);
|
||||
}
|
||||
$backupPath = $storagePath.'/hosting_subscriptions/'.$this->backup_type.'/'.$this->id;
|
||||
$backupTempPath = $backupPath.'/temp';
|
||||
if (! is_dir($backupTempPath)) {
|
||||
mkdir($backupTempPath);
|
||||
}
|
||||
dd($backupPath, $backupTempPath);
|
||||
shell_exec('mkdir -p ' . $backupTempPath);
|
||||
|
||||
if ($this->backup_type == 'full') {
|
||||
|
||||
|
@ -170,6 +158,8 @@ class HostingSubscriptionBackup extends Model
|
|||
$backupLogFileName = 'backup.log';
|
||||
$backupLogFilePath = $backupPath.'/'.$backupLogFileName;
|
||||
|
||||
$backupTargetPath = $findMainDomain->domain_root . '/backups/'.$backupFileName;
|
||||
|
||||
$backupTempScript = '/tmp/backup-script-'.$this->id.'.sh';
|
||||
$shellFileContent = '';
|
||||
$shellFileContent .= 'echo "Backup up domain: '.$findHostingSubscription->domain . PHP_EOL;
|
||||
|
@ -181,7 +171,10 @@ class HostingSubscriptionBackup extends Model
|
|||
$shellFileContent .= 'rm -rf '.$backupTempPath.PHP_EOL;
|
||||
$shellFileContent .= 'echo "Backup complete"' . PHP_EOL;
|
||||
$shellFileContent .= 'touch ' . $backupPath. '/backup.done' . PHP_EOL;
|
||||
$shellFileContent .= 'rm -rf ' . $backupTempScript;
|
||||
$shellFileContent .= 'rm -rf ' . $backupTempScript . PHP_EOL;
|
||||
|
||||
$shellFileContent .= 'mkdir -p '. $findMainDomain->domain_root . '/backups'.PHP_EOL;
|
||||
$shellFileContent .= 'mv '.$backupFilePath.' '. $backupTargetPath.PHP_EOL;
|
||||
|
||||
file_put_contents($backupTempScript, $shellFileContent);
|
||||
|
||||
|
@ -190,15 +183,14 @@ class HostingSubscriptionBackup extends Model
|
|||
|
||||
if ($processId > 0 && is_numeric($processId)) {
|
||||
|
||||
$this->path = $backupPath;
|
||||
$this->filepath = $backupFilePath;
|
||||
$this->path = $findMainDomain->domain_root . '/backups';
|
||||
$this->filepath = $backupTargetPath;
|
||||
$this->status = 'processing';
|
||||
$this->queued = true;
|
||||
$this->queued_at = now();
|
||||
$this->process_id = $processId;
|
||||
$this->save();
|
||||
|
||||
dd($this);
|
||||
return [
|
||||
'status' => 'processing',
|
||||
'message' => 'Backup started'
|
||||
|
|
Loading…
Reference in a new issue