diff --git a/web/app/Console/Commands/RunUploadBackupsToRemoteServers.php b/web/app/Console/Commands/RunUploadBackupsToRemoteServers.php index 596cf3f..b3d38ae 100644 --- a/web/app/Console/Commands/RunUploadBackupsToRemoteServers.php +++ b/web/app/Console/Commands/RunUploadBackupsToRemoteServers.php @@ -3,6 +3,7 @@ namespace App\Console\Commands; use App\Models\Backup; +use App\Models\HostingSubscriptionBackup; use App\Models\RemoteBackupServer; use Illuminate\Console\Command; @@ -41,12 +42,21 @@ class RunUploadBackupsToRemoteServers extends Command $findBackups = Backup::where('status', 'completed')->get(); if ($findBackups->count() > 0) { foreach ($findBackups as $backup) { - $uploadStatus = $remoteBackupServer->uploadFile($backup->filepath); + $uploadStatus = $remoteBackupServer->uploadFile($backup->filepath, 'phyre-system-backups'); } } else { $this->info('No backups found to upload.'); } + $findHostingSubscriptionBackups = HostingSubscriptionBackup::where('status', 'completed')->get(); + if ($findHostingSubscriptionBackups->count() > 0) { + foreach ($findHostingSubscriptionBackups as $hostingSubscriptionBackup) { + $uploadStatus = $remoteBackupServer->uploadFile($hostingSubscriptionBackup->filepath, 'phyre-hosting-subscription-backups'); + } + } else { + $this->info('No hosting subscription backups found to upload.'); + } + } } else { $this->info('No remote backup servers found.'); diff --git a/web/app/Models/RemoteBackupServer.php b/web/app/Models/RemoteBackupServer.php index adef308..3ed222a 100644 --- a/web/app/Models/RemoteBackupServer.php +++ b/web/app/Models/RemoteBackupServer.php @@ -73,7 +73,7 @@ class RemoteBackupServer extends Model } - public function uploadFile($filepath) + public function uploadFile($filepath, $directory) { $username = trim($this->username); $password = trim($this->password); @@ -82,12 +82,9 @@ class RemoteBackupServer extends Model if ($this->type == 'ftp') { - $path = trim($this->path); - if ($path == '/') { - $path = ''; - } + $directory = trim($directory); - $uploadCurlCommand = "curl -T $filepath ftp://$username:$password@$hostname:$port "." $path"; + $uploadCurlCommand = "curl -T $filepath ftp://$hostname:$port/$directory/ -u '$username:$password' --ftp-create-dirs"; $uploadCurlCommand = trim($uploadCurlCommand); $uploadCurlProcess = Process::fromShellCommandline($uploadCurlCommand);