Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

rhand's avatar
Level 6

Post Server Migration Laravel Backups run but no data sent to DO Spaces

I moved to a new server with Hetzner and set up all with Ploi and set up cron schedule, Horizon daemon and what not. But 4-5 hrs ago several jobs should have run to backup projects and application but nothing got sent to Digital Ocean Spaces . Using Spatie Backup "spatie/laravel-backup": "^8.1",.

I checked the schedule / crontab and things do run:

php artisan schedule:list |grep backup
  0    1 * * *  php artisan backup:clean ........ Next Due: 19 hours from now
  0    2 * * *  php artisan backup:run .......... Next Due: 20 hours from now
  0    2 * * *  php artisan backup:projects ..... Next Due: 20 hours from now
  0    0 * * 7  php artisan backup-client:projects  Next Due: 18 hours from now
  0    1 * * *  php artisan clean:backup ........ Next Due: 19 hours from now
date
Sat Apr  8 05:04:43 CEST 2023

I checked cat ~/staging.site.com/current/storage/logs/laravel.log but no errors related to backups.

Data in .env as as before migration for storing at DO Spaces:

DO_KEY=key
DO_SECRET=secret_key
DO_REGION=ams3
DO_BUCKET=smt-client-projects
DO_ENDPOINT=https://ams3.digitaloceanspaces.com
DO_URL=https://some-thing-nice.ams3.cdn.digitaloceanspaces.com

DO_BACKUP_BUCKET=smtapp

I did not get notification though still set in backup.php

'notifications' => [

 'notifications' => [
\Spatie\Backup\Notifications\Notifications\BackupHasFailedNotification::class => ['mail'],
\Spatie\Backup\Notifications\Notifications\UnhealthyBackupWasFoundNotification::class => ['mail'],
\Spatie\Backup\Notifications\Notifications\CleanupHasFailedNotification::class => ['mail'],
\Spatie\Backup\Notifications\Notifications\BackupWasSuccessfulNotification::class => ['mail'],
\Spatie\Backup\Notifications\Notifications\HealthyBackupWasFoundNotification::class => ['mail'],
\Spatie\Backup\Notifications\Notifications\CleanupWasSuccessfulNotification::class => ['mail'],
    ],

but emails on initial project are sent with these same settings and port:

MAIL_DRIVER=smtp
MAIL_HOST=smtp.sendgrid.net
MAIL_PORT=587

and Hetzner only blocks on other ports

Outgoing traffic to ports 25 and 465 are blocked by default on all Cloud Servers PAGE_CONTENT.LIMITS.REQUEST_FORBIDDEN.WARNING

so it seems that email via Sendgrid works just fine. Even checked Sendgrid logs and welcome emails are being sent without issues.

Tried to run a notification via Tinker but got stuck on values needed to test a failure and I am also not sure if this would work via Tinker..

php artisan tinker
Psy Shell v0.11.12 (PHP 8.1.17 — cli) by Justin Hileman
> use Spatie\Backup\Notifications\Notifications\BackupHasFailedNotification;
> $user = App\Models\Auth\User::find(1);
= App\Models\Auth\User {#5070
    id: 1,
    role_id: 3,
    company_id: 1,
    user_group_id: null,
...
    email: "[email protected]",
    avatar: null,
    ....
    deleted_at: null,
    is_sent_welcome: 1,
    lang: null,
    first_name: null,
    last_name: null,
  }

> $exception = new \Exception('Backup has failed due to an error.');
= Exception {#5064
    #message: "Backup has failed due to an error.",
    #file: "/home/ploi/staging.site.com/releases/11/vendor/psy/psysh/src/ExecutionLoopClosure.php(53) : eval()'d code",
    #line: 1,
  }

> $user->notify(new BackupHasFailedNotification($exception));

   TypeError  Spatie\Backup\Notifications\Notifications\BackupHasFailedNotification::__construct(): Argument #1 ($event) must be of type Spatie\Backup\Events\BackupHasFailed, Exception given, called in /home/ploi/staging.sitecomeval()'d code on line 1.

So why do I not get backups at Digital Ocean Spaces and why no emails on failure nor success?

0 likes
1 reply
rhand's avatar
rhand
OP
Best Answer
Level 6

I just tested manual run of php artisan backup:projects on staging and that does backup projects. But I do not get any notifications . And this then also means that the scheduler fails to run this same command even though I ran as ploi and scheduler runs as ploi also:

php /home/ploi/default/artisan schedule:run
* * * * * via user ploi

So perhaps path is not correct here as suggested earlier . Shall test using

php /home/ploi/staging.site.com/current/artisan schedule:run

tonight. But still, the schedule when checked with php artisan schedule:list showed earlier that path with default also was working. I mean, the schedule was listed.. And checking cron logs I saw lines like

Apr  7 23:10:01 site-w1 CRON[174852]: (ploi) CMD (php /home/ploi/default/artisan schedule:run > /home/ploi/.ploi/scheduled-108180.log 2>&1)

so that would mean it is running, right? Yes. But when I checked that path

php /home/ploi/default/artisan schedule:list
Could not open input file: /home/ploi/default/artisan

it did not work. This must be the issue. But no error reported by Laravel so did not realize this could be it. Will wait for tonight for run schedule with new path.

Please or to participate in this conversation.