fractaledmind / litestream-ruby

MIT License
71 stars 6 forks source link

Database restore issues in Docker #34

Open darryldaniel opened 1 month ago

darryldaniel commented 1 month ago

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?

fractaledmind commented 1 week ago

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?