mirror of
https://github.com/pixelfed/pixelfed.git
synced 2024-12-25 22:43:18 +00:00
commit
c19cd49523
3 changed files with 78 additions and 1 deletions
|
@ -5,6 +5,7 @@
|
||||||
### Added
|
### Added
|
||||||
- Manual email verification requests. ([bc659387](https://github.com/pixelfed/pixelfed/commit/bc659387))
|
- Manual email verification requests. ([bc659387](https://github.com/pixelfed/pixelfed/commit/bc659387))
|
||||||
- Added StatusMentionService, fixes #3026. ([e5387d67](https://github.com/pixelfed/pixelfed/commit/e5387d67))
|
- 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
|
||||||
- Updated NotificationService, fix 500 bug. ([4a609dc3](https://github.com/pixelfed/pixelfed/commit/4a609dc3))
|
- Updated NotificationService, fix 500 bug. ([4a609dc3](https://github.com/pixelfed/pixelfed/commit/4a609dc3))
|
||||||
|
|
76
app/Console/Commands/BackupToCloud.php
Normal file
76
app/Console/Commands/BackupToCloud.php
Normal file
|
@ -0,0 +1,76 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Console\Commands;
|
||||||
|
|
||||||
|
use Illuminate\Http\File;
|
||||||
|
use Illuminate\Console\Command;
|
||||||
|
use Illuminate\Support\Facades\Storage;
|
||||||
|
use Spatie\Backup\BackupDestination\BackupDestination;
|
||||||
|
|
||||||
|
class BackupToCloud extends Command
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* The name and signature of the console command.
|
||||||
|
*
|
||||||
|
* @var string
|
||||||
|
*/
|
||||||
|
protected $signature = 'backup:cloud';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The console command description.
|
||||||
|
*
|
||||||
|
* @var string
|
||||||
|
*/
|
||||||
|
protected $description = 'Send backups to cloud storage';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Create a new command instance.
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function __construct()
|
||||||
|
{
|
||||||
|
parent::__construct();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Execute the console command.
|
||||||
|
*
|
||||||
|
* @return int
|
||||||
|
*/
|
||||||
|
public function handle()
|
||||||
|
{
|
||||||
|
$localDisk = Storage::disk('local');
|
||||||
|
$cloudDisk = Storage::disk('backup');
|
||||||
|
$backupDestination = new BackupDestination($localDisk, '', 'local');
|
||||||
|
|
||||||
|
if(
|
||||||
|
empty(config('filesystems.disks.backup.key')) ||
|
||||||
|
empty(config('filesystems.disks.backup.secret')) ||
|
||||||
|
empty(config('filesystems.disks.backup.endpoint')) ||
|
||||||
|
empty(config('filesystems.disks.backup.region')) ||
|
||||||
|
empty(config('filesystems.disks.backup.bucket'))
|
||||||
|
) {
|
||||||
|
$this->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;
|
||||||
|
}
|
||||||
|
}
|
|
@ -82,7 +82,7 @@ return [
|
||||||
],
|
],
|
||||||
|
|
||||||
'backup' => [
|
'backup' => [
|
||||||
'driver' => env('PF_BACKUP_DRIVER', 'local'),
|
'driver' => env('PF_BACKUP_DRIVER', 's3'),
|
||||||
'visibility' => 'private',
|
'visibility' => 'private',
|
||||||
'root' => env('PF_BACKUP_DRIVER', 'local') == 'local' ?
|
'root' => env('PF_BACKUP_DRIVER', 'local') == 'local' ?
|
||||||
storage_path('app/backups/') :
|
storage_path('app/backups/') :
|
||||||
|
|
Loading…
Reference in a new issue