Laravel Spatie备份保存到S3文件夹而不创建子目录

huangapple go评论49阅读模式
英文:

Laravel Spatie backup save to s3 folder without creating subdirectory

问题

I have spatie/laravel-backup v8.1.7 and I want to save to a s3 folder named backups

To acheive this in filesystems.php I've added the following:

'backups' => [
    'driver' => 's3',
    'key' => env('AWS_ACCESS_KEY_ID'),
    'secret' => env('AWS_SECRET_ACCESS_KEY'),
    'region' => env('AWS_DEFAULT_REGION'),
    'bucket' => env('AWS_BUCKET'),
    'root' => 'backups', // specify the root directory for backups
],

In backup.php config file under destination I have:

'destination' => [
    'filename_prefix' => 'backup_',
    'disks' => [
        'backups',
    ],
],

Now when it get saved to s3, it seems to first create a subdirectory using the name => env('APP_NAME', 'laravel-backup'), config variable and inside that it creates the backup file e.g. backups/laravel-backup/backup_2023-03-03-14-41-58.zip

How do i configure it so that is creates the backup directly in the s3 backup folder without creating a further subdirectory e.g. backups/backup_2023-03-03-14-41-58.zip

英文:

I have spatie/laravel-backup v8.1.7 and I want to save to a s3 folder named backups

To acheive this in filesystems.php I've added the following:

'backups' => [
        'driver' => 's3',
        'key' => env('AWS_ACCESS_KEY_ID'),
        'secret' => env('AWS_SECRET_ACCESS_KEY'),
        'region' => env('AWS_DEFAULT_REGION'),
        'bucket' => env('AWS_BUCKET'),
        'root' => 'backups', // specify the root directory for backups
 ],

In backup.php config file under destination I have:

'destination' => [

        'filename_prefix' => 'backup_',

        'disks' => [
            'backups',
        ],
      
],

Now when it get saved to s3, it seems to first create a subdirectory using the 'name' => env('APP_NAME', 'laravel-backup'), config variable and inside that it creates the backup file e.g. backups/laravel-backup/backup_2023-03-03-14-41-58.zip

How do i configure it so that is creates the backup directly in the s3 backup folder without creating a further subdirectory e.g. backups/backup_2023-03-03-14-41-58.zip

答案1

得分: 1

成功解决了,只需将以下变量重命名为:

'name' => env('APP_NAME', 'laravel-backup')

改为

'name' => env('BACKUP_FOLDER', 'backups')

这样,我也不需要在filesystem.php文件中配置备份磁盘 - 我可以直接使用已在其中定义的现有S3配置。

英文:

Managed to resolve by simply renaming the following variable:

'name' => env('APP_NAME', 'laravel-backup')

To

'name' => env('BACKUP_FOLDER', 'backups')

This way i don't need to configure the backup disk in the filesystem.php file either - I can just use my existing s3 configuration that already defined in there.

huangapple
  • 本文由 发表于 2023年3月3日 23:25:25
  • 转载请务必保留本文链接:https://go.coder-hub.com/75628954.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定