如何将 spatie laravel 存储的备份上传到谷歌驱动器?

Posted

技术标签:

【中文标题】如何将 spatie laravel 存储的备份上传到谷歌驱动器?【英文标题】:how to upload spatie laravel stored backup to google drive? 【发布时间】:2021-02-20 14:19:38 【问题描述】:

我正在尝试使用 laravel spatie 包在谷歌驱动器上上传备份我遵循了这些步骤 https://gist.github.com/sergomet/f234cc7a8351352170eb547cccd65011 我的备份已成功创建 g-drive 已成功集成,但是在执行操作时 backup:run 它给出了这个错误,主要是找不到文件,最后它说

备份失败,因为:取消链接 C:\xampp\htdocs\newfolder\storage\app/backup-temp\temp\2020-11-07-20-06-19.zip) 资源暂时不可用

这是我的 config/backup.php

<?php

return [

    'backup' => [
      'name' => config('GOOGLE_DRIVE_FOLDER_ID' , 'laravel-backup'),

        'source' => [

            'files' => [
                'include' => [
                ],
                'exclude' => [
                    base_path('vendor'),
                    base_path('node_modules'),
                ],
                'followLinks' => false,
            ],

            'databases' => [
                'mysql',
            ],
        ],
        'database_dump_compressor' => null,

        'destination' => [
            'filename_prefix' => '',
            'disks' => [
                'local' , 'google'
            ],
        ],
        'temporary_directory' => storage_path('app/backup-temp'),
    ],

    'notifications' => [

        'notifications' => [
            \Spatie\Backup\Notifications\Notifications\BackupHasFailed::class         => ['mail'],
            \Spatie\Backup\Notifications\Notifications\UnhealthyBackupWasFound::class => ['mail'],
            \Spatie\Backup\Notifications\Notifications\CleanupHasFailed::class        => ['mail'],
            \Spatie\Backup\Notifications\Notifications\BackupWasSuccessful::class     => ['mail'],
            \Spatie\Backup\Notifications\Notifications\HealthyBackupWasFound::class   => ['mail'],
            \Spatie\Backup\Notifications\Notifications\CleanupWasSuccessful::class    => ['mail'],
        ],

        'notifiable' => \Spatie\Backup\Notifications\Notifiable::class,

        'mail' => [
        ],

        'slack' => [
            'webhook_url' => '',
            'channel' => null,

            'username' => null,

            'icon' => null,

        ],
    ],
    'monitorBackups' => [
        [
            'name' => env('GOOGLE_DRIVE_FOLDER_ID' , 'laravel-backup'),
            'disks' => ['local'],
            'newestBackupsShouldNotBeOlderThanDays' => 1,
            'storageUsedMayNotBeHigherThanMegabytes' => 5000,
        ],
    ],

    'cleanup' => [
        'strategy' => \Spatie\Backup\Tasks\Cleanup\Strategies\DefaultStrategy::class,

        'defaultStrategy' => [
            'keepAllBackupsForDays' => 7,
            'keepDailyBackupsForDays' => 16,
            'keepWeeklyBackupsForWeeks' => 8,
            'keepMonthlyBackupsForMonths' => 4,
            'keepYearlyBackupsForYears' => 2,

            'deleteOldestBackupsWhenUsingMoreMegabytesThan' => 5000,
        ],
    ],
];

我的.env

GOOGLE_DRIVE_CLIENT_ID=183462809528-gqhvm96rpsvhccp4lll55soms.apps.googleusercontent.com
GOOGLE_DRIVE_CLIENT_SECRET=T7OaNoN5t2GBHU4hvBVKX
GOOGLE_DRIVE_REFRESH_TOKEN="1//04Z70eIYBuRvgCgYIARAAGAQSNwF-L9Ir1riNcqKpwiOYeFdP6LlXhpcRgDPiMLbZvZS0UKQtDrEpqizRpLwah-Y2-WdmOs"
GOOGLE_DRIVE_FOLDER_ID=1245H1fYLxa8q0LJD1uTAe-chX8W44ALJ

【问题讨论】:

【参考方案1】:

要修复此错误,请将name 设置为config/backup.php 中的空字符串。

'name' => '',

在下面的视频链接中,详细解释了这个错误的解决方法: https://www.youtube.com/watch?v=6kxXkrlRuJU

我相信它会有所帮助。或者您也可以查看 -How To Setup Laravel Backup On Google Drive?

上的文章

【讨论】:

以上是关于如何将 spatie laravel 存储的备份上传到谷歌驱动器?的主要内容,如果未能解决你的问题,请参考以下文章

如何使用 laravel 8 +jetstream + spatie 为注册用户分配角色

如何在登录具有 Spatie 的 Laravel 权限的用户之前检查用户角色?

Spatie / Laravel cors在生产中的问题[重复]

它是如何工作的 ?使用 Spatie/laravel-cronless-schedule 自定义的 Laravel 时间表

如何使用 spatie/laravel-query-builder 过滤/搜索具有关系的数据? (拉拉维尔)

我如何在 laravel 中为 spatie 包(ACL 管理)中的其他角色分配用户列表权限?