litestream-ruby
litestream-ruby copied to clipboard
Database restore issues in Docker
I'm running a Rails app in a Docker container with Sqlite and I'm using the following command in the Docker entrypoint file:
./bin/rails litestream:restore -- --database=storage/production.sqlite3 --if-replica-exists
A few times now, the database has failed to restore with the following error message:
level=ERROR msg="failed to run" error="cannot apply wal: database disk image is malformed"
What does this error mean and is this the way I should be managing this in a docker environment?
I unfortunately don't use Docker myself, so I'm not sure if that is an important detail or not. We can start debugging by checking the integrity of the database. Open the Rails console and run ActiveRecord::Base.connection.raw_connection.execute "PRAGMA integrity_check;". What output do you see?