From 3515a98e551b2d8ce423bc1689d71f34aebcd875 Mon Sep 17 00:00:00 2001 From: Daniel Supernault Date: Tue, 14 Dec 2021 20:08:44 -0700 Subject: [PATCH 1/2] Add Cloud Backups, a command to store backups on S3 or compatible filesystems --- app/Console/Commands/BackupToCloud.php | 76 ++++++++++++++++++++++++++ config/filesystems.php | 2 +- 2 files changed, 77 insertions(+), 1 deletion(-) create mode 100644 app/Console/Commands/BackupToCloud.php 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/') : From 7ca63f2eb62008fcc600d1b8fb75bd3a25ea4111 Mon Sep 17 00:00:00 2001 From: Daniel Supernault Date: Tue, 14 Dec 2021 20:27:17 -0700 Subject: [PATCH 2/2] Update changelog --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index b7e29ac07..8f3493f81 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,7 @@ ### Added - Manual email verification requests. ([bc659387](https://github.com/pixelfed/pixelfed/commit/bc659387)) - Added StatusMentionService, fixes #3026. ([e5387d67](https://github.com/pixelfed/pixelfed/commit/e5387d67)) +- Cloud Backups, a command to store backups on S3 or compatible filesystems. [#3037](https://github.com/pixelfed/pixelfed/pull/3037) ([3515a98e](https://github.com/pixelfed/pixelfed/commit/3515a98e)) ### Updated - Updated NotificationService, fix 500 bug. ([4a609dc3](https://github.com/pixelfed/pixelfed/commit/4a609dc3))