LinguaCafe icon indicating copy to clipboard operation
LinguaCafe copied to clipboard

v0.14.1 Backups not created

Open kimlika opened this issue 9 months ago • 11 comments

So it seems that the new backup feature is not working for me. The folder storage/backup is empty (there should have been one automatic backup here by now). And when I try to create it manually from the admin page I get this error:

An error has occurred while exporting your database

kimlika avatar Mar 21 '25 06:03 kimlika

Hi!

I have not received this info from others yet, and It works for me and another user. The only issue that comes to my mind is permissions for the storage/backup folder, but in #405 you wrote that you copied them, so I'm not sure what's wrong.

Do you have any errors in /storage/logs/laravel.log or /storage/logs/horizon.log when you click the backup button?

simjanos-dev avatar Mar 22 '25 09:03 simjanos-dev

Hi! I checked both logs right after clicking the backup button.

laravel.log has this:

192.168.0.100 - - [22/Mar/2025:14:42:11 +0000] "GET /backups/create HTTP/1.1" 200 1282 "http://192.168.0.101:9191/admin" sh: 1: Syntax error: ")" unexpected

And horizon.log has this:

In StreamHandler.php line 140:

The stream or file "/var/www/html/storage/logs/laravel.log" could not be opened in append mode: Failed to open stream: Permission denied
The exception occurred while attempting to log: php_network_getaddresses: getaddrinfo for linguacafe-redis failed: Temporary failure in name resolution [tcp://linguacafe-redis:6379]
Context: {"exception":{}}

Yes, I copied permissions recursively but maybe something still got messed up during my attempts to recover the database?

I can live with manually copying linguacafe folder for backup, but I'm concerned that this may mean my database is still messed up in some ways even after successful recovery...

kimlika avatar Mar 22 '25 14:03 kimlika

Yes, I copied permissions recursively but maybe something still got messed up during my attempts to recover the database?

I see 2 problems. One is that the log file is not writable. That is a permission error. I don't know what caused it, maybe the copying. I've only tested it on a fresh ubuntu install, where after installation and updates I had no permission errors. After that when I had permission errors due to copying or somethings, I just used the chmod 777 command that you also mentioned.

getaddrinfo for linguacafe-redis failed: Temporary failure in name resolution

The other issue is that it seems like linguacafe-redis is not found. linguacafe-redis should be a working as a domain name inside the containers. Can you please check if importing text work for you, and if your redis server is running? If the redis container/server does not work, it could be the reason why the database exports did not work.

I can live with manually copying linguacafe folder for backup, but I'm concerned that this may mean my database is still messed up in some ways even after successful recovery...

  • From v0.14 you can have .sql backups, so you won't have to copy-paste the database folder.
  • I've just realized right now, that the current manual still recommends copying the whole linguacafe folder. I'll change this, since It should be enough to only copy the storage folder, and use .sql file for the database imports.

simjanos-dev avatar Mar 22 '25 16:03 simjanos-dev

I seem to be having a similar issue and am getting the same "An error has occurred while exporting your database." message when trying to backup. I am also having another issue with the statistics for chapters (Total, Unique, Known, Highlighted, New) not populating, see screenshot.

Image

I do not see any error occurring in the horizon.log but am seeing this in laravel.log:

[2025-03-22 17:36:42] production.ERROR: League\Flysystem\Filesystem::delete(): Argument #1 ($location) must be of type string, null given, called in /var/www/html/vendor/laravel/framework/src/Illuminate/Filesystem/FilesystemAdapter.php on line 513 {"userId":1,"exception":"[object] (TypeError(code: 0): League\Flysystem\Filesystem::delete(): Argument #1 ($location) must be of type string, null given, called in /var/www/html/vendor/laravel/framework/src/Illuminate/Filesystem/FilesystemAdapter.php on line 513 at /var/www/html/vendor/league/flysystem/src/Filesystem.php:84) [stacktrace] #0 /var/www/html/vendor/laravel/framework/src/Illuminate/Filesystem/FilesystemAdapter.php(513): League\Flysystem\Filesystem->delete(NULL) #1 /var/www/html/app/Services/BackupService.php(41): Illuminate\Filesystem\FilesystemAdapter->delete(Array) #2 /var/www/html/app/Services/BackupService.php(24): App\Services\BackupService->deleteOldBackups('linguacafe_') #3 /var/www/html/app/Console/Commands/CreateBackup.php(32): App\Services\BackupService->createBackup() #4 /var/www/html/vendor/laravel/framework/src/Illuminate/Container/BoundMethod.php(36): App\Console\Commands\CreateBackup->handle() #5 /var/www/html/vendor/laravel/framework/src/Illuminate/Container/Util.php(41): Illuminate\Container\BoundMethod::Illuminate\Container\{closure}() #6 /var/www/html/vendor/laravel/framework/src/Illuminate/Container/BoundMethod.php(93): Illuminate\Container\Util::unwrapIfClosure(Object(Closure)) #7 /var/www/html/vendor/laravel/framework/src/Illuminate/Container/BoundMethod.php(35): Illuminate\Container\BoundMethod::callBoundMethod(Object(Illuminate\Foundation\Application), Array, Object(Closure)) #8 /var/www/html/vendor/laravel/framework/src/Illuminate/Container/Container.php(690): Illuminate\Container\BoundMethod::call(Object(Illuminate\Foundation\Application), Array, Array, NULL) #9 /var/www/html/vendor/laravel/framework/src/Illuminate/Console/Command.php(213): Illuminate\Container\Container->call(Array) #10 /var/www/html/vendor/symfony/console/Command/Command.php(279): Illuminate\Console\Command->execute(Object(Symfony\Component\Console\Input\StringInput), Object(Illuminate\Console\OutputStyle)) #11 /var/www/html/vendor/laravel/framework/src/Illuminate/Console/Command.php(182): Symfony\Component\Console\Command\Command->run(Object(Symfony\Component\Console\Input\StringInput), Object(Illuminate\Console\OutputStyle)) #12 /var/www/html/vendor/symfony/console/Application.php(1047): Illuminate\Console\Command->run(Object(Symfony\Component\Console\Input\StringInput), Object(Symfony\Component\Console\Output\BufferedOutput)) #13 /var/www/html/vendor/symfony/console/Application.php(316): Symfony\Component\Console\Application->doRunCommand(Object(App\Console\Commands\CreateBackup), Object(Symfony\Component\Console\Input\StringInput), Object(Symfony\Component\Console\Output\BufferedOutput)) #14 /var/www/html/vendor/symfony/console/Application.php(167): Symfony\Component\Console\Application->doRun(Object(Symfony\Component\Console\Input\StringInput), Object(Symfony\Component\Console\Output\BufferedOutput)) #15 /var/www/html/vendor/laravel/framework/src/Illuminate/Console/Application.php(162): Symfony\Component\Console\Application->run(Object(Symfony\Component\Console\Input\StringInput), Object(Symfony\Component\Console\Output\BufferedOutput)) #16 /var/www/html/vendor/laravel/framework/src/Illuminate/Foundation/Console/Kernel.php(423): Illuminate\Console\Application->call('app:create-back...', Array, NULL) #17 /var/www/html/vendor/laravel/framework/src/Illuminate/Support/Facades/Facade.php(357): Illuminate\Foundation\Console\Kernel->call('app:create-back...') #18 /var/www/html/app/Http/Controllers/BackupController.php(12): Illuminate\Support\Facades\Facade::__callStatic('call', Array) #19 /var/www/html/vendor/laravel/framework/src/Illuminate/Routing/ControllerDispatcher.php(46): App\Http\Controllers\BackupController->createBackup() #20 /var/www/html/vendor/laravel/framework/src/Illuminate/Routing/Route.php(260): Illuminate\Routing\ControllerDispatcher->dispatch(Object(Illuminate\Routing\Route), Object(App\Http\Controllers\BackupController), 'createBackup') #21 /var/www/html/vendor/laravel/framework/src/Illuminate/Routing/Route.php(206): Illuminate\Routing\Route->runController() #22 /var/www/html/vendor/laravel/framework/src/Illuminate/Routing/Router.php(808): Illuminate\Routing\Route->run() #23 /var/www/html/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(144): Illuminate\Routing\Router->Illuminate\Routing\{closure}(Object(Illuminate\Http\Request)) #24 /var/www/html/app/Http/Middleware/AdminMiddleware.php(24): Illuminate\Pipeline\Pipeline->Illuminate\Pipeline\{closure}(Object(Illuminate\Http\Request)) #25 /var/www/html/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(183): App\Http\Middleware\AdminMiddleware->handle(Object(Illuminate\Http\Request), Object(Closure)) #26 /var/www/html/vendor/laravel/framework/src/Illuminate/Routing/Middleware/SubstituteBindings.php(50): Illuminate\Pipeline\Pipeline->Illuminate\Pipeline\{closure}(Object(Illuminate\Http\Request)) #27 /var/www/html/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(183): Illuminate\Routing\Middleware\SubstituteBindings->handle(Object(Illuminate\Http\Request), Object(Closure)) #28 /var/www/html/vendor/laravel/framework/src/Illuminate/Session/Middleware/AuthenticateSession.php(67): Illuminate\Pipeline\Pipeline->Illuminate\Pipeline\{closure}(Object(Illuminate\Http\Request)) #29 /var/www/html/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(183): Illuminate\Session\Middleware\AuthenticateSession->handle(Object(Illuminate\Http\Request), Object(Closure)) #30 /var/www/html/vendor/laravel/framework/src/Illuminate/Auth/Middleware/Authenticate.php(64): Illuminate\Pipeline\Pipeline->Illuminate\Pipeline\{closure}(Object(Illuminate\Http\Request)) #31 /var/www/html/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(183): Illuminate\Auth\Middleware\Authenticate->handle(Object(Illuminate\Http\Request), Object(Closure)) #32 /var/www/html/vendor/laravel/framework/src/Illuminate/Foundation/Http/Middleware/VerifyCsrfToken.php(88): Illuminate\Pipeline\Pipeline->Illuminate\Pipeline\{closure}(Object(Illuminate\Http\Request)) #33 /var/www/html/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(183): Illuminate\Foundation\Http\Middleware\VerifyCsrfToken->handle(Object(Illuminate\Http\Request), Object(Closure)) #34 /var/www/html/vendor/laravel/framework/src/Illuminate/View/Middleware/ShareErrorsFromSession.php(49): Illuminate\Pipeline\Pipeline->Illuminate\Pipeline\{closure}(Object(Illuminate\Http\Request)) #35 /var/www/html/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(183): Illuminate\View\Middleware\ShareErrorsFromSession->handle(Object(Illuminate\Http\Request), Object(Closure)) #36 /var/www/html/vendor/laravel/framework/src/Illuminate/Session/Middleware/StartSession.php(121): Illuminate\Pipeline\Pipeline->Illuminate\Pipeline\{closure}(Object(Illuminate\Http\Request)) #37 /var/www/html/vendor/laravel/framework/src/Illuminate/Session/Middleware/StartSession.php(64): Illuminate\Session\Middleware\StartSession->handleStatefulRequest(Object(Illuminate\Http\Request), Object(Illuminate\Session\Store), Object(Closure)) #38 /var/www/html/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(183): Illuminate\Session\Middleware\StartSession->handle(Object(Illuminate\Http\Request), Object(Closure)) #39 /var/www/html/vendor/laravel/framework/src/Illuminate/Cookie/Middleware/AddQueuedCookiesToResponse.php(37): Illuminate\Pipeline\Pipeline->Illuminate\Pipeline\{closure}(Object(Illuminate\Http\Request)) #40 /var/www/html/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(183): Illuminate\Cookie\Middleware\AddQueuedCookiesToResponse->handle(Object(Illuminate\Http\Request), Object(Closure)) #41 /var/www/html/vendor/laravel/framework/src/Illuminate/Cookie/Middleware/EncryptCookies.php(75): Illuminate\Pipeline\Pipeline->Illuminate\Pipeline\{closure}(Object(Illuminate\Http\Request)) #42 /var/www/html/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(183): Illuminate\Cookie\Middleware\EncryptCookies->handle(Object(Illuminate\Http\Request), Object(Closure)) #43 /var/www/html/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(119): Illuminate\Pipeline\Pipeline->Illuminate\Pipeline\{closure}(Object(Illuminate\Http\Request)) #44 /var/www/html/vendor/laravel/framework/src/Illuminate/Routing/Router.php(807): Illuminate\Pipeline\Pipeline->then(Object(Closure)) #45 /var/www/html/vendor/laravel/framework/src/Illuminate/Routing/Router.php(786): Illuminate\Routing\Router->runRouteWithinStack(Object(Illuminate\Routing\Route), Object(Illuminate\Http\Request)) #46 /var/www/html/vendor/laravel/framework/src/Illuminate/Routing/Router.php(750): Illuminate\Routing\Router->runRoute(Object(Illuminate\Http\Request), Object(Illuminate\Routing\Route)) #47 /var/www/html/vendor/laravel/framework/src/Illuminate/Routing/Router.php(739): Illuminate\Routing\Router->dispatchToRoute(Object(Illuminate\Http\Request)) #48 /var/www/html/vendor/laravel/framework/src/Illuminate/Foundation/Http/Kernel.php(200): Illuminate\Routing\Router->dispatch(Object(Illuminate\Http\Request)) #49 /var/www/html/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(144): Illuminate\Foundation\Http\Kernel->Illuminate\Foundation\Http\{closure}(Object(Illuminate\Http\Request)) #50 /var/www/html/vendor/laravel/framework/src/Illuminate/Foundation/Http/Middleware/TransformsRequest.php(21): Illuminate\Pipeline\Pipeline->Illuminate\Pipeline\{closure}(Object(Illuminate\Http\Request)) #51 /var/www/html/vendor/laravel/framework/src/Illuminate/Foundation/Http/Middleware/ConvertEmptyStringsToNull.php(31): Illuminate\Foundation\Http\Middleware\TransformsRequest->handle(Object(Illuminate\Http\Request), Object(Closure)) #52 /var/www/html/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(183): Illuminate\Foundation\Http\Middleware\ConvertEmptyStringsToNull->handle(Object(Illuminate\Http\Request), Object(Closure)) #53 /var/www/html/vendor/laravel/framework/src/Illuminate/Foundation/Http/Middleware/TransformsRequest.php(21): Illuminate\Pipeline\Pipeline->Illuminate\Pipeline\{closure}(Object(Illuminate\Http\Request)) #54 /var/www/html/vendor/laravel/framework/src/Illuminate/Foundation/Http/Middleware/TrimStrings.php(51): Illuminate\Foundation\Http\Middleware\TransformsRequest->handle(Object(Illuminate\Http\Request), Object(Closure)) #55 /var/www/html/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(183): Illuminate\Foundation\Http\Middleware\TrimStrings->handle(Object(Illuminate\Http\Request), Object(Closure)) #56 /var/www/html/vendor/laravel/framework/src/Illuminate/Http/Middleware/ValidatePostSize.php(27): Illuminate\Pipeline\Pipeline->Illuminate\Pipeline\{closure}(Object(Illuminate\Http\Request)) #57 /var/www/html/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(183): Illuminate\Http\Middleware\ValidatePostSize->handle(Object(Illuminate\Http\Request), Object(Closure)) #58 /var/www/html/vendor/laravel/framework/src/Illuminate/Foundation/Http/Middleware/PreventRequestsDuringMaintenance.php(110): Illuminate\Pipeline\Pipeline->Illuminate\Pipeline\{closure}(Object(Illuminate\Http\Request)) #59 /var/www/html/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(183): Illuminate\Foundation\Http\Middleware\PreventRequestsDuringMaintenance->handle(Object(Illuminate\Http\Request), Object(Closure)) #60 /var/www/html/vendor/laravel/framework/src/Illuminate/Http/Middleware/HandleCors.php(62): Illuminate\Pipeline\Pipeline->Illuminate\Pipeline\{closure}(Object(Illuminate\Http\Request)) #61 /var/www/html/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(183): Illuminate\Http\Middleware\HandleCors->handle(Object(Illuminate\Http\Request), Object(Closure)) #62 /var/www/html/vendor/laravel/framework/src/Illuminate/Http/Middleware/TrustProxies.php(57): Illuminate\Pipeline\Pipeline->Illuminate\Pipeline\{closure}(Object(Illuminate\Http\Request)) #63 /var/www/html/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(183): Illuminate\Http\Middleware\TrustProxies->handle(Object(Illuminate\Http\Request), Object(Closure)) #64 /var/www/html/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(119): Illuminate\Pipeline\Pipeline->Illuminate\Pipeline\{closure}(Object(Illuminate\Http\Request)) #65 /var/www/html/vendor/laravel/framework/src/Illuminate/Foundation/Http/Kernel.php(175): Illuminate\Pipeline\Pipeline->then(Object(Closure)) #66 /var/www/html/vendor/laravel/framework/src/Illuminate/Foundation/Http/Kernel.php(144): Illuminate\Foundation\Http\Kernel->sendRequestThroughRouter(Object(Illuminate\Http\Request)) #67 /var/www/html/public/index.php(51): Illuminate\Foundation\Http\Kernel->handle(Object(Illuminate\Http\Request)) #68 {main} "}

giuseppebaldi avatar Mar 22 '25 17:03 giuseppebaldi

Yes, I copied permissions recursively but maybe something still got messed up during my attempts to recover the database?

I see 2 problems. One is that the log file is not writable. That is a permission error. I don't know what caused it, maybe the copying. I've only tested it on a fresh ubuntu install, where after installation and updates I had no permission errors. After that when I had permission errors due to copying or somethings, I just used the chmod 777 command that you also mentioned.

I now deleted the old log files (backed them up in case) and restarted the server. Now the new horizon.log doesn't show any errors.

getaddrinfo for linguacafe-redis failed: Temporary failure in name resolution

The other issue is that it seems like linguacafe-redis is not found. linguacafe-redis should be a working as a domain name inside the containers. Can you please check if importing text work for you, and if your redis server is running? If the redis container/server does not work, it could be the reason why the database exports did not work.

Importing works fine, I've imported a couple of texts already. Portainer shows that redis is working and healthy. Since the new log is normal, I now suspect that it may have been an older error from when I attempted to recover the database and did multiple restarts.

I also looked through the laravel.log again. The line sh: 1: Syntax error: ")" unexpected appears several times and seems not to be connected with the backup attempts.

Unlike giuseppebaldi, I don't have any issues with statistics.

kimlika avatar Mar 23 '25 10:03 kimlika

It has occurred to me that I have another issue that may or may not be related. When I restart the browser, some settings revert to default: reader settings and the number of rows in the library. It doesn't happen with themes and admin settings.

It happens when the browser I use for reading is restarted, also after updates. Doesn't happen when I log out and back in, doesn't happen when the server is restarted.

Why I think it may not be related: it was also happening for me in v0.13.

kimlika avatar Mar 23 '25 18:03 kimlika

When I restart the browser, some settings revert to default: reader settings and the number of rows in the library. It doesn't happen with themes and admin settings.

Those settings are used to be stored in cookies in v0.13, and now are stored in local storage. I don't know why they are being deleted, unless a browser is set up to do just that.

also after updates

In v0.14 due to the change from cookies to local storage, everyone lost their settings.

simjanos-dev avatar Mar 24 '25 18:03 simjanos-dev

Those settings are used to be stored in cookies in v0.13, and now are stored in local storage. I don't know why they are being deleted, unless a browser is set up to do just that.

You were right, the browser was doing it. I found an option deep in Chromium settings that was set to automatically delete local storage on close. Didn't even know this was the default. Now linguacafe settings are fine.

So this was really unrelated to the backup issue that still exists.

kimlika avatar Mar 28 '25 18:03 kimlika

Didn't even know this was the default.

Me neither, and I've used chromium in the past for years.

simjanos-dev avatar Mar 30 '25 15:03 simjanos-dev

For the record, I finally fixed this backup issue. Apparently, my database password was the cause. It had some special characters; I know almost nothing about mysql databases, so I thought escaping them was enough. I was wrong - neither escaping nor using quotes was enough.

After some discussion with ChatGPT, I managed to change my database password. Now backups work as intended.

And, apparently, this line in logs was the only clue to what was happening:

sh: 1: Syntax error: ")" unexpected

I also tested the restore process by importing backup sql file, and everything worked fine.

kimlika avatar Jun 01 '25 09:06 kimlika

For the record, I finally fixed this backup issue. Apparently, my database password was the cause. It had some special characters; I know almost nothing about mysql databases, so I thought escaping them was enough. I was wrong - neither escaping nor using quotes was enough.

@kimlika What were the characters causing the issue? It should be simple to add some error handling for this.

cblanken avatar Aug 25 '25 16:08 cblanken