Laravel-backup: Copying .zip file failed because: Instances of Aws\S3\S3Client cannot be serialized.

Created on 23 Aug 2016  路  11Comments  路  Source: spatie/laravel-backup

Hey guys getting this error when putting in S3 under destination disks, the local backup works fine. I'm just trying to do the database only backup too, so it's not a big .zip file.

All 11 comments

I cannot reproduce this in the latest version of the package. Please try to set the package up in a vanilla Laravel app to make sure nothing project specific is causing this error.

Reopen if the problem still occurs.

@seivad Did you figure out this problem? I'm getting it at the moment.

I'm still having this issue, haven't figured out the problem yet. local disk works fine, s3 disk throws:

Starting backup...
Dumping database dovetailx...
Gzipping dovetailx...
Determining files to backup...
Zipping 1 files...
Created zip containing 1 files. Size is 39.18 KB
Copying zip to disk named backup...
Successfully copied zip to disk named backup.
Copying zip failed because: Instances of Aws\S3\S3Client cannot be serialized.
Backup failed because Instances of Aws\S3\S3Client cannot be serialized.
#0 [internal function]: Aws\AwsClient->__sleep()
....

Not sure if this is a configuration problem or what.
My config is pretty much default though. S3 config works as I'm saving other stuff there(via media-library).

Just updated all my dependencies, so have latest laravel-backup, aws-sdk, etc on laravel 5.6

Just realized the backup is uploading to S3 fine - success email is sent too.
Then 3 failed emails get sent after that regarding the serialization of S3Client

Getting the same issue here, has anyone solved this yet? Disabling notifications makes the backup run smoothly, but it's like running blind.

Here are the relevant packages I'm requiring.

"laravel/framework": "5.7.*",
"league/flysystem-aws-s3-v3": "^1.0",
"spatie/laravel-backup": "^6.0",

And here's the stack trace I'm getting

```
Backup failed because Instances of Aws\S3S3Client cannot be serialized.

0 [internal function]: Aws\AwsClient->__sleep()

1 /vendor/laravel/framework/src/Illuminate/Queue/Queue.php(138): serialize(Object(Illuminate\Events\CallQueuedListener))

2 /vendor/laravel/framework/src/Illuminate/Queue/Queue.php(110): Illuminate\Queue\Queue->createObjectPayload(Object(Illuminate\Events\CallQueuedListener), 'queues:local')

3 /vendor/laravel/framework/src/Illuminate/Queue/RedisQueue.php(150): Illuminate\Queue\Queue->createPayloadArray(Object(Illuminate\Events\CallQueuedListener), 'queues:local', '')

4 /vendor/laravel/framework/src/Illuminate/Queue/Queue.php(88): Illuminate\Queue\RedisQueue->createPayloadArray(Object(Illuminate\Events\CallQueuedListener), 'queues:local', '')

5 /vendor/laravel/framework/src/Illuminate/Queue/RedisQueue.php(91): Illuminate\Queue\Queue->createPayload(Object(Illuminate\Events\CallQueuedListener), 'queues:local', '')

6 /vendor/laravel/horizon/src/RedisQueue.php(46): Illuminate\Queue\RedisQueue->push(Object(Illuminate\Events\CallQueuedListener), '', NULL)

7 /vendor/laravel/framework/src/Illuminate/Queue/Queue.php(44): Laravel\Horizon\RedisQueue->push(Object(Illuminate\Events\CallQueuedListener), '', NULL)

8 /vendor/laravel/framework/src/Illuminate/Events/Dispatcher.php(485): Illuminate\Queue\Queue->pushOn(NULL, Object(Illuminate\Events\CallQueuedListener))

9 /vendor/laravel/framework/src/Illuminate/Events/Dispatcher.php(444): Illuminate\Events\Dispatcher->queueHandler('App\Listeners\L...', 'handle', Array)

10 [internal function]: Illuminate\Events\Dispatcher->Illuminate\Events{closure}(Object(Illuminate\Notifications\Events\NotificationSent))

11 /vendor/laravel/framework/src/Illuminate/Events/Dispatcher.php(379): call_user_func_array(Object(Closure), Array)

12 /vendor/laravel/framework/src/Illuminate/Events/Dispatcher.php(209): Illuminate\Events\Dispatcher->Illuminate\Events{closure}('Illuminate\Noti...', Array)

13 /vendor/laravel/framework/src/Illuminate/Notifications/NotificationSender.php(147): Illuminate\Events\Dispatcher->dispatch('Illuminate\Noti...')

14 /vendor/laravel/framework/src/Illuminate/Notifications/NotificationSender.php(103): Illuminate\Notifications\NotificationSender->sendToNotifiable(Object(Spatie\Backup\Notifications\Notifiable), '565f063a-a3f3-4...', Object(Spatie\Backup\Notifications\Notifications\BackupHasFailed), 'mail')

15 /vendor/laravel/framework/src/Illuminate/Support/Traits/Localizable.php(19): Illuminate\Notifications\NotificationSender->Illuminate\Notifications{closure}()

16 /vendor/laravel/framework/src/Illuminate/Notifications/NotificationSender.php(105): Illuminate\Notifications\NotificationSender->withLocale(NULL, Object(Closure))

17 /vendor/laravel/framework/src/Illuminate/Notifications/NotificationSender.php(77): Illuminate\Notifications\NotificationSender->sendNow(Array, Object(Spatie\Backup\Notifications\Notifications\BackupHasFailed))

18 /vendor/laravel/framework/src/Illuminate/Notifications/ChannelManager.php(42): Illuminate\Notifications\NotificationSender->send(Array, Object(Spatie\Backup\Notifications\Notifications\BackupHasFailed))

19 /vendor/laravel/framework/src/Illuminate/Notifications/RoutesNotifications.php(18): Illuminate\Notifications\ChannelManager->send(Object(Spatie\Backup\Notifications\Notifiable), Object(Spatie\Backup\Notifications\Notifications\BackupHasFailed))

20 /vendor/spatie/laravel-backup/src/Notifications/EventHandler.php(33): Spatie\Backup\Notifications\Notifiable->notify(Object(Spatie\Backup\Notifications\Notifications\BackupHasFailed))

21 /vendor/laravel/framework/src/Illuminate/Events/Dispatcher.php(360): Spatie\Backup\Notifications\EventHandler->Spatie\Backup\Notifications{closure}(Object(Spatie\Backup\Events\BackupHasFailed))

22 /vendor/laravel/framework/src/Illuminate/Events/Dispatcher.php(209): Illuminate\Events\Dispatcher->Illuminate\Events{closure}('Spatie\Backup\E...', Array)

23 /vendor/laravel/framework/src/Illuminate/Foundation/helpers.php(482): Illuminate\Events\Dispatcher->dispatch('Spatie\Backup\E...')

24 /vendor/spatie/laravel-backup/src/Tasks/Backup/BackupJob.php(274): event(Object(Spatie\Backup\Events\BackupHasFailed))

25 /vendor/spatie/laravel-backup/src/Tasks/Backup/BackupJob.php(266): Spatie\Backup\Tasks\Backup\BackupJob->sendNotification(Object(Spatie\Backup\Events\BackupHasFailed))

26 /vendor/laravel/framework/src/Illuminate/Support/Collection.php(405): Spatie\Backup\Tasks\Backup\BackupJob->Spatie\Backup\Tasks\Backup{closure}(Object(Spatie\Backup\BackupDestination\BackupDestination), 0)

27 /vendor/spatie/laravel-backup/src/Tasks/Backup/BackupJob.php(268): Illuminate\Support\Collection->each(Object(Closure))

28 /vendor/spatie/laravel-backup/src/Tasks/Backup/BackupJob.php(150): Spatie\Backup\Tasks\Backup\BackupJob->copyToBackupDestinations('/Users/luca/Pro...')

29 /vendor/spatie/laravel-backup/src/Commands/BackupCommand.php(52): Spatie\Backup\Tasks\Backup\BackupJob->run()

30 [internal function]: Spatie\Backup\Commands\BackupCommand->handle()

31 /vendor/laravel/framework/src/Illuminate/Container/BoundMethod.php(29): call_user_func_array(Array, Array)

32 /vendor/laravel/framework/src/Illuminate/Container/BoundMethod.php(87): Illuminate\Container\BoundMethod::Illuminate\Container{closure}()

33 /vendor/laravel/framework/src/Illuminate/Container/BoundMethod.php(31): Illuminate\Container\BoundMethod::callBoundMethod(Object(Illuminate\Foundation\Application), Array, Object(Closure))

34 /vendor/laravel/framework/src/Illuminate/Container/Container.php(572): Illuminate\Container\BoundMethod::call(Object(Illuminate\Foundation\Application), Array, Array, NULL)

35 /vendor/laravel/framework/src/Illuminate/Console/Command.php(183): Illuminate\Container\Container->call(Array)

36 /vendor/symfony/console/Command/Command.php(255): Illuminate\Console\Command->execute(Object(Symfony\Component\Console\Input\ArgvInput), Object(Illuminate\Console\OutputStyle))

37 /vendor/laravel/framework/src/Illuminate/Console/Command.php(170): Symfony\Component\Console\Command\Command->run(Object(Symfony\Component\Console\Input\ArgvInput), Object(Illuminate\Console\OutputStyle))

38 /vendor/spatie/laravel-backup/src/Commands/BaseCommand.php(16): Illuminate\Console\Command->run(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))

39 /vendor/symfony/console/Application.php(886): Spatie\Backup\Commands\BaseCommand->run(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))

40 /vendor/symfony/console/Application.php(262): Symfony\Component\Console\Application->doRunCommand(Object(Spatie\Backup\Commands\BackupCommand), Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))

41 /vendor/symfony/console/Application.php(145): Symfony\Component\Console\Application->doRun(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))

42 /vendor/laravel/framework/src/Illuminate/Console/Application.php(89): Symfony\Component\Console\Application->run(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))

43 /vendor/laravel/framework/src/Illuminate/Foundation/Console/Kernel.php(122): Illuminate\Console\Application->run(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))

44 /artisan(37): Illuminate\Foundation\Console\Kernel->handle(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))

45 {main}```

I've found the issue causing the problem to me:
In my EventServiceProvider.php I was listening on the NotificationSent event. The problem was that the listener was implementing ShouldQueue thus creating a problem with serializing the notification. Removing ShouldQueue made everything run fine.

@tobz-nz Just tried to backup to an S3 disk and everything worked fine. Do you still have the serialization problem? If so, can you please test this in a vanilla Laravel application? So we can try to find out what goes wrong without side effects. I will close the issue for now.

Same problem, @lucadegasperi's note pinpointed the issue - I had implemented a NotificationSent Listener that had ShouldQueue. Removed ShouldQueue to be able to continue backups.

@rubenvanassche Sorry I haven't had a chance to check yet - deadlines on other projects.
I think it was still having problems, but need to confirm. Will do asap.

@rubenvanassche Yeah seems to be working without any problems now. 馃憤

Hi, I still have this problem. I have created a custom notifications that not implements ShouldQueue. How can I solve this?

Laravel: 5.8
laravel-backup: 6.10.0

Was this page helpful?
0 / 5 - 0 ratings