diff --git a/app/Console/Commands/BackupToCloud.php b/app/Console/Commands/BackupToCloud.php new file mode 100644 index 000000000..815e23ac3 --- /dev/null +++ b/app/Console/Commands/BackupToCloud.php @@ -0,0 +1,76 @@ +error('Backup disk not configured.'); + $this->error('See https://docs.pixelfed.org/technical-documentation/env.html#filesystem for more information.'); + return Command::FAILURE; + } + + $newest = $backupDestination->newestBackup(); + $name = $newest->path(); + $parts = explode('/', $name); + $fileName = array_pop($parts); + $storagePath = 'backups'; + $path = storage_path('app/'. $name); + $file = $cloudDisk->putFileAs($storagePath, new File($path), $fileName, 'private'); + $this->info("Backup file successfully saved!"); + $url = $cloudDisk->url($file); + $this->table( + ['Name', 'URL'], + [ + [$fileName, $url] + ], + ); + return Command::SUCCESS; + } +} diff --git a/config/filesystems.php b/config/filesystems.php index 0df7cf308..a43e5b470 100644 --- a/config/filesystems.php +++ b/config/filesystems.php @@ -82,7 +82,7 @@ return [ ], 'backup' => [ - 'driver' => env('PF_BACKUP_DRIVER', 'local'), + 'driver' => env('PF_BACKUP_DRIVER', 's3'), 'visibility' => 'private', 'root' => env('PF_BACKUP_DRIVER', 'local') == 'local' ? storage_path('app/backups/') :