Skip to content

Commit 6a50cac

Browse files
Update Backup.php
1 parent a2d9d8d commit 6a50cac

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

web/app/Models/Backup.php

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,11 @@ public static function boot()
2929
$model->checkCronJob();
3030
});
3131

32+
static::deleting(function ($model) {
33+
if (is_dir($model->path)) {
34+
shell_exec('rm -rf ' . $model->path);
35+
}
36+
});
3237
}
3338

3439
private function checkCronJob()
@@ -99,7 +104,7 @@ public function startBackup()
99104
$findHostingSubscription = HostingSubscription::where('id', $this->hosting_subscription_id)->first();
100105
if ($findHostingSubscription) {
101106

102-
$backupFileName = Str::slug($findHostingSubscription->domain .'-'. date('Y-m-d-H-i-s')) . '.zip';
107+
$backupFileName = Str::slug($findHostingSubscription->domain .'-'. date('Y-m-d-H-i-s')) . '.tar.gz';
103108
$backupFilePath = $backupPath.'/'.$backupFileName;
104109

105110
$backupLogFileName = 'backup.log';
@@ -111,7 +116,7 @@ public function startBackup()
111116
$shellFileContent .= 'echo "Backup filename: '.$backupFileName. PHP_EOL;
112117
$shellFileContent .= 'cp -r /home/'.$findHostingSubscription->system_username.' '.$backupTempPath.PHP_EOL;
113118

114-
$shellFileContent .= 'cd '.$backupTempPath .' && zip -r '.$backupFilePath.' ./* '. PHP_EOL;
119+
$shellFileContent .= 'cd '.$backupTempPath .' && tar -czvf '.$backupFilePath.' ./* '. PHP_EOL;
115120

116121
$shellFileContent .= 'rm -rf '.$backupTempPath.PHP_EOL;
117122
$shellFileContent .= 'echo "Backup complete"' . PHP_EOL;

0 commit comments

Comments
 (0)