Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Exception when running backup:monitor #77

Closed
georgeboot opened this issue Mar 8, 2016 · 21 comments
Closed

Exception when running backup:monitor #77

georgeboot opened this issue Mar 8, 2016 · 21 comments

Comments

@georgeboot
Copy link

[Symfony\Component\Debug\Exception\FatalThrowableError]
  Type error: Argument 1 passed to Spatie\Backup\Tasks\Monitor\BackupDestinationStatusFactory::Spatie\Backup\Tasks\Monitor\{closure}() mu
  st be an instance of Spatie\Backup\Tasks\Monitor\BackupDestinationStatus, instance of Illuminate\Support\Collection given, called in /h
  ome/vagrant/Code/entry-system-customdomain/vendor/laravel/framework/src/Illuminate/Support/Collection.php on line 795

Am I doing something wrong?

I am using version 3.

My config:

<?php

return [

    'backup' => [

        /*
         * The name of this application. You can use this name to monitor
         * the backups.
         */
        'name' => 'Entry System Customdomain',

        'source' => [

            'files' => [

                /*
                 * The list of directories that should be part of the backup. You can
                 * specify individual files as well.
                 */
                'include' => [
                    storage_path('app'),
                    storage_path('logs'),
                ],

                /*
                 * These directories will be excluded from the backup.
                 * You can specify individual files as well.
                 */
                'exclude' => [
                    //
                ],
            ],

            /*
             * The names of the connections to the databases  that should be part of the backup.
             * Currently only MySQL-databases are supported.
             */
            'databases' => [
                'dbjump',
                'entry',
                'finance',
                'photo',
                'status',
                'website',
            ],
        ],

        'destination' => [

            /*
             * The filesystems you on which the backups will be stored. Choose one or more
             * of the filesystems you configured in app/config/filesystems.php
             */
            'filesystems' => [
                'stack',
                's3',
            ],
        ],
    ],

    'cleanup' => [
        /*
         * The strategy that will be used to cleanup old backups.
         * The youngest backup wil never be deleted.
         */
        'strategy' => \Spatie\Backup\Tasks\Cleanup\Strategies\DefaultStrategy::class,

        'defaultStrategy' => [

            /*
             * The amount of days that all daily backups must be kept.
             */
            'keepAllBackupsForDays' => 7,

            /*
             * The amount of days that all daily backups must be kept.
             */
            'keepDailyBackupsForDays' => 16,

            /*
             * The amount of weeks of which one weekly backup must be kept.
             */
            'keepWeeklyBackupsForWeeks' => 8,

            /*
             * The amount of months of which one monthly backup must be kept.
             */
            'keepMonthlyBackupsForMonths' => 4,

            /*
             * The amount of years of which one yearly backup must be kept
             */
            'keepYearlyBackupsForYears' => 2,

            /*
             * After clean up the backups remove the oldest backup until
             * this amount of megabytes is reached.
             */
            'deleteOldestBackupsWhenUsingMoreMegabytesThan' => 5000
        ]
    ],


    /*
     *  In this array you can specify which backups should be monitored.
     *  If a backup does not meet the specified requirements the
     *  UnHealthyBackupWasFound-event will be fired.
     */
    'monitorBackups' => [
        [
            'name' => 'Entry System Customdomain',
            'filesystems' => ['stack', 's3'],
            'newestBackupsShouldNotBeOlderThanDays' => 1,
            'storageUsedMayNotBeHigherThanMegabytes' => 5000,
        ],

        /*
        [
            'name' => 'name of the second app',
            'filesystems' => ['local', 's3'],
            'newestBackupsShouldNotBeOlderThanDays' => 1,
            'storageUsedMayNotBeHigherThanMegabytes' => 5000,
        ],
        */
    ],

    'notifications' => [

        /*
         * This class will be used to send all notifications.
         */
        'handler' => Spatie\Backup\Notifications\Notifier::class,

        /*
         * Here you can specify the ways you want to be notified when certain
         * events take place. Possible values are "log", "mail" and "slack".
         *
         * Slack requires the installation of the maknz/slack package
         */
        'events' => [
            'whenBackupWasSuccessful'     => ['log'],
            'whenCleanupWasSuccessful'    => ['log'],
            'whenHealthyBackupWasFound'   => ['log'],
            'whenBackupHasFailed'         => ['log', 'mail'],
            'whenCleanupHasFailed'        => ['log', 'mail'],
            'whenUnHealthyBackupWasFound' => ['log', 'mail']
        ],

        /*
         * Here you can specify how mails should be sent.
         */
        'mail' => [
            'from' => '[email protected]',
            'to' => '[email protected]',
        ],

        /*
         * Here you can how messages should be sent to Slack.
         */
        'slack' => [
            'channel'  => '#backups',
            'username' => 'Backup bot',
            'icon'     => ':robot:',
        ],
    ]
];
@freekmurze
Copy link
Member

How can this error be triggered?

@georgeboot
Copy link
Author

The only thing I do is running php artisan backup:monitor

@freekmurze
Copy link
Member

Lemme take a look

@freekmurze
Copy link
Member

Could you post the contents of the monitorBackups key in the config file?

@georgeboot
Copy link
Author

Just edited the original post with the full config.

@freekmurze
Copy link
Member

Could you make sure that you have configured disks named stack and s3 in app/config/filesystems.php? Please mind that this can be another value the driver name.

If all is ok, could you please update to 3.0.1 which was tagged a few minutes ago.

@georgeboot
Copy link
Author

Double checked and it is ok. Updated to version 3.0.1 but still the same issue.

Though there might be something wrong with the storage adapters so changed the filesystem to local, but without luck.

@georgeboot
Copy link
Author

A 2nd issue: when I run php artisan backup:run it outputs Starting backup. and then quits. No errors, nothing, like it's expected behaviour. Might be related.

I was previously on v2, that worked fine. Saw your message about v3 being released so thought let's update!

@freekmurze
Copy link
Member

What Laravel and PHP version are you using? Sorry for all these questions, but i'm have trouble recreating your issue.

@georgeboot
Copy link
Author

Laravel Framework version 5.1.31 (LTS)

PHP 7.0.1-1+deb.sury.org~trusty+2 (cli) ( NTS )
Copyright (c) 1997-2015 The PHP Group
Zend Engine v3.0.0, Copyright (c) 1998-2015 Zend Technologies
    with Zend OPcache v7.0.6-dev, Copyright (c) 1999-2015, by Zend Technologies

Currently running on Homestead box.

@freekmurze
Copy link
Member

I certainly isn't expected behaviour for the backup:run command to just stop. The last line should read Backup completed! Can you try to run the monitor and backup commands with verbose output (-vvv) and post the output here?

@georgeboot
Copy link
Author

php artisan -vvv backup:run
Starting backup.
php artisan -vvv backup:monitor


  [Symfony\Component\Debug\Exception\FatalThrowableError]
  Type error: Argument 1 passed to Spatie\Backup\Tasks\Monitor\BackupDestinationStatusFactory::Spatie\Backup\Tasks\Monitor\{closure}() must be an instance of Spatie\Backup
  \Tasks\Monitor\BackupDestinationStatus, instance of Illuminate\Support\Collection given, called in /home/vagrant/Code/entry-system-customdomain/vendor/laravel/framework/
  src/Illuminate/Support/Collection.php on line 795


Exception trace:
 () at /home/vagrant/Code/entry-system-customdomain/vendor/spatie/laravel-backup/src/Tasks/Monitor/BackupDestinationStatusFactory.php:21
 Spatie\Backup\Tasks\Monitor\BackupDestinationStatusFactory::Spatie\Backup\Tasks\Monitor\{closure}() at /home/vagrant/Code/entry-system-customdomain/vendor/laravel/framework/src/Illuminate/Support/Collection.php:795
 Illuminate\Support\Collection->sortBy() at /home/vagrant/Code/entry-system-customdomain/vendor/spatie/laravel-backup/src/Tasks/Monitor/BackupDestinationStatusFactory.php:23
 Spatie\Backup\Tasks\Monitor\BackupDestinationStatusFactory::createForMonitorConfig() at /home/vagrant/Code/entry-system-customdomain/vendor/spatie/laravel-backup/src/Commands/MonitorCommand.php:24
 Spatie\Backup\Commands\MonitorCommand->handle() at n/a:n/a
 call_user_func_array() at /home/vagrant/Code/entry-system-customdomain/vendor/laravel/framework/src/Illuminate/Container/Container.php:507
 Illuminate\Container\Container->call() at /home/vagrant/Code/entry-system-customdomain/vendor/laravel/framework/src/Illuminate/Console/Command.php:150
 Illuminate\Console\Command->execute() at /home/vagrant/Code/entry-system-customdomain/vendor/symfony/console/Command/Command.php:256
 Symfony\Component\Console\Command\Command->run() at /home/vagrant/Code/entry-system-customdomain/vendor/laravel/framework/src/Illuminate/Console/Command.php:136
 Illuminate\Console\Command->run() at /home/vagrant/Code/entry-system-customdomain/vendor/spatie/laravel-backup/src/Commands/BaseCommand.php:22
 Spatie\Backup\Commands\BaseCommand->run() at /home/vagrant/Code/entry-system-customdomain/vendor/symfony/console/Application.php:841
 Symfony\Component\Console\Application->doRunCommand() at /home/vagrant/Code/entry-system-customdomain/vendor/symfony/console/Application.php:189
 Symfony\Component\Console\Application->doRun() at /home/vagrant/Code/entry-system-customdomain/vendor/symfony/console/Application.php:120
 Symfony\Component\Console\Application->run() at /home/vagrant/Code/entry-system-customdomain/vendor/laravel/framework/src/Illuminate/Foundation/Console/Kernel.php:107
 Illuminate\Foundation\Console\Kernel->handle() at /home/vagrant/Code/entry-system-customdomain/artisan:35

@freekmurze
Copy link
Member

Good news, I could recreate your issue by just using your entire config file. Now trying to see where the exact error is.

@georgeboot
Copy link
Author

Great 👍

@freekmurze
Copy link
Member

Ok, found something.

Are you sure that these are databases connection names? (and not just the name of the databases)

'dbjump', 'entry', 'finance', 'photo', 'status', 'website',

@georgeboot
Copy link
Author

Ah yes, that must be the issue! 2 of them were missing, stupid me! The backup now runs successfully 👍

The monitor command however still fails with the same error as before.

@freekmurze
Copy link
Member

Owkey, one down, one to go... I'll try to recreate that issue

And I'll also make sure the backup outputs a sensible message when providing a wrong db name

@freekmurze
Copy link
Member

Hi, i might have fix for you in the current dev-master. Could you pull that it and let me know the output of the backup:monitor-command?

@georgeboot
Copy link
Author

No sorry, still the same issue :-(

@freekmurze
Copy link
Member

Pretty sure v3.0.4 will fix your issue. If not, reopen this issue.

@georgeboot
Copy link
Author

It is fixed, thanks!!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants