1

i am trying to upload backup on google drive using laravel spatie package i followed these steps https://gist.github.com/sergomet/f234cc7a8351352170eb547cccd65011 my backup is created successfully g-drive is integrated successfully but when perform action backup:run it gives this error mostly file not found and in the last it says

backup failed because: unlink C:\xampp\htdocs\newfolder\storage\app/backup-temp\temp\2020-11-07-20-06-19.zip) resource temporarily unavailable enter image description here

and here is my 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,
        ],
    ],
];

my .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
apokryfos
  • 38,771
  • 9
  • 70
  • 114

1 Answers1

1

To fix this error set the name to an empty string in the config/backup.php.

'name' => '',

In the following video link, the solution to this error is explained in detail: https://www.youtube.com/watch?v=6kxXkrlRuJU

I am sure it will be helpful. Or you can also check out the article on -
How To Setup Laravel Backup On Google Drive?

Harish Kumar
  • 218
  • 1
  • 7