spatie / laravel-backup

A package to backup your Laravel app
https://spatie.be/docs/laravel-backup
MIT License
5.65k stars 763 forks source link

Dropbox issues with listing & monitoring #339

Closed mansouralex closed 7 years ago

mansouralex commented 7 years ago

Hello @freekmurze

We had problem with backups on dropbox disk. As show in the attached screenshot the backup is completed successfully but backup:list not considering it.

Also the backup:monitor fire the UnHealthyBackupWasFound-event

What is the issue or miss-configuration that we may had?

Please note that we already had the same config on another instance of the app but we are not having this issue.

image

freekmurze commented 7 years ago

Are you using the latest version? Could you post your laravel-backup config file?

mansouralex commented 7 years ago

`<?php

return [

'backup' => [

    /*
     * The name of this application. You can use this name to monitor
     * the backups.
     */
    'name' => env('APP_NAME'),

    'source' => [

        'files' => [

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

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

            /*
             * Determines if symlinks should be followed.
             */
            'followLinks' => false,
        ],

        /*
         * The names of the connections to the databases that should be part of the backup.
         * Currently only MySQL- and PostgreSQL-databases are supported.
         */
        'databases' => [
            'mysql',
        ],
    ],

    'destination' => [

        /*
         * The disk names on which the backups will be stored.
         */
        'disks' => [
            'local', 'dropbox'
        ],
    ],
],

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

    'defaultStrategy' => [

        /*
         * The amount of days that all 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 cleaning up the backups remove the oldest backup until
         * this amount of megabytes has been 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' => env('APP_NAME'),
        'disks' => ['local', 'dropbox'],
        'newestBackupsShouldNotBeOlderThanDays' => 1,
        'storageUsedMayNotBeHigherThanMegabytes' => 5000,
    ],

    /*
    [
        'name' => 'name of the second app',
        'disks' => ['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", "slack",
     * "pushover", and "telegram".
     *
     * Slack requires the installation of the maknz/slack package.
     * Telegram requires the installation of the irazasyed/telegram-bot-sdk package.
     */
    'events' => [
        'whenBackupWasSuccessful'     => explode(',', env('SUCCESSFUL_BACKUP_NOTIFIER')),
        'whenCleanupWasSuccessful'    => ['log'],
        'whenHealthyBackupWasFound'   => ['log'],
        'whenBackupHasFailed'         => ['log', 'mail'],
        'whenCleanupHasFailed'        => ['log', 'mail'],
        'whenUnhealthyBackupWasFound' => ['log', 'mail'],
    ],

    /*
     * Here you can specify how emails should be sent.
     */
    'mail' => [
        'from' => env('MAIL_FROM_ADDRESS'),
        'to'   => explode(',', env('BACKUP_EMAILS')),
    ],

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

    /*
     * Here you can specify how messages should be sent to Pushover.
     */
    'pushover' => [
        'token'  => env('PUSHOVER_APP_TOKEN'),
        'user'   => env('PUSHOVER_USER_KEY'),
        'sounds' => [
            'success' => env('PUSHOVER_SOUND_SUCCESS', 'pushover'),
            'error'   => env('PUSHOVER_SOUND_ERROR', 'siren'),
        ],
    ],

    /*
     * Here you can specify how messages should be sent to Telegram Bot API.
     */
    'telegram' => [
        'bot_token' => env('TELEGRAM_BOT_TOKEN'),
        'chat_id'   => env('TELEGRAM_CHAT_ID'),
        'async_requests' => env('TELEGRAM_ASYNC_REQUESTS', false),
        'disable_web_page_preview' => env('TELEGRAM_DISABLE_WEB_PAGE_PREVIEW', true),
    ],
],

]; `

mansouralex commented 7 years ago

@freekmurze I'm using version 3.0.0 and on Laravel 5.2.45

freekmurze commented 7 years ago

The UnHealthyBackupWasFound event contains a $backupDestinationStatus property on which you can call isReachable(). Does that method return true?

If it returns false, try calling $backupDestinationStatus->getConnectionError(). Hopefully that'll return a specific error message.

freekmurze commented 7 years ago

Were you able to get a specific error message?

mansouralex commented 7 years ago

Didn't try it yet. Will be doing soon. Will keep you posted.

mansouralex commented 7 years ago

@freekmurze We just tried it out and the isReachable retrning true any thoughts?

freekmurze commented 7 years ago

Don't have any clue atm. You stated that you have another instance running with the some laravel-backup config that is running ok. I'd try to find out what the differences are between those two instances.

mansouralex commented 7 years ago

@freekmurze What is the cases occur that the UnHealthyBackupWasFound-event happen?

freekmurze commented 7 years ago

My hunch is that your instance with troubles can't read dropbox correctly, so the package fires the UnHealthyBackupWasFound event, because no backups were found.