So it works or it does not work?
Laravel 8 spatie backup not working on server
hi, I'm using Laravel 8. when I call Artisan::call('backup:run'); in controller, it's worked on localhost but it's not working on the server. it's showing me this error message Address in mailbox given [] does not comply with RFC 2822, 3.6.2.
To the server i changed MAIL_MAILER smtp to sendmail in .env and mail.php and mail is sending without any issue. I'm using laravel 8 version. Thanks in advanced
now I configured the mail recipients properly now it's showing The file "" does not exist
@codelumina We need some more information. What gives that error? What is the full error?
i'm using this code
$path = storage_path('app/Laravel/*'); $latest_ctime = 0; $latest_filename = ''; $files = glob($path); foreach($files as $file) { if (is_file($file) && filectime($file) > $latest_ctime) { $latest_ctime = filectime($file); $latest_filename = $file; } } return response()->download($latest_filename);
It's showing me The file "" does not exist
@codelumina Please format your code by adding ``` on the line before and after it
Try wrapping the first part here in () to force early evaluation
if ((is_file($file)) && filectime($file) > $latest_ctime) {
@Sinnbeck not it's showing blank
$path = storage_path('app/Laravel/*');
$latest_ctime = 0;
$latest_filename = '';
$files = glob($path);
if ((is_file($file)) && filectime($file) > $latest_ctime) {
foreach($files as $file)
{
if (is_file($file) && filectime($file) > $latest_ctime)
{
$latest_ctime = filectime($file);
$latest_filename = $file;
}
}
return response()->download($latest_filename);
}
@codelumina Why are you wrapping the foreach in a check on $file with it isnt set?
$path = storage_path('app/Laravel/*');
$latest_ctime = 0;
$latest_filename = '';
$files = glob($path);
foreach($files as $file)
{
if ((is_file($file)) && filectime($file) > $latest_ctime)
{
$latest_ctime = filectime($file);
$latest_filename = $file;
}
}
return response()->download($latest_filename);
And if you are still getting an error, it should point out what line the error is on
@Sinnbeck now showing The file "" does not exist
@codelumina what line?
And if you are still getting an error, it should point out what line the error is on
there is no line error only showing The file "" does not exist
@codelumina Can you post a screenshot of the error? Upload to imgur.com and post a link
i just realized when i call Artisan::call('backup:run'); than no zip file is creating in storage/app/Laravel
@codelumina What about if you run it on the cli ? php artisan backup:run
imgur.com/a/dz23dxr
@codelumina If you look to the left there is a row in the stack trace. 46 app/Http/Controllers..etc. Click that and see which line it is
imgur.com/a/Ipltwj3
@codelumina Ah yes. So if no file is found, you cannot download any
if (! $latest_filename) {
return 'NO FILES EXISTS!';
}
return response()->download($latest_filename);
@Sinnbeck understand but why file not found i already called Artisan::call('backup:run');
@codelumina Didnt you already say why that is?
i just realized when i call Artisan::call('backup:run'); than no zip file is creating in storage/app/Laravel
why it's not creating zip and showing no error
@codelumina I do not know. I dont use the package. Does it create the file locally?
yes in the local it's creating zip files
@codelumina Did some digging. Try this in production
Artisan::call('backup:run');
dd(Artisan::output());
Should give you the output of the command. My bet is that it fails. Maybe it does not have write access to the Laravel folder
Did that give you anything useful?
can you please tell me another way to get database backup
@codelumina I personally use the backup service that is included with ploi.io. They setup my servers, handle my deployments and backups (+ many other things)
ok thanks for your response
Please or to participate in this conversation.