This article is a continuation of the previous articles below:
- https://calvin.my/posts/migrating-a-rails-app-from-mysql-to-sqlite-database
- https://calvin.my/posts/backup-sqlite-databases-with-litestream
This article shows how to restore an SQLite database from a backup using Litestream.
Restore your backup
(If you are running from the same machine, skip steps 1 and 2.)
-
Install Litestream and copy the config file that contains the AWS S3 credentials.
-
If you lost the original S3 credentials, you can create a new one from the AWS console. Remember to give the necessary S3 permissions.
-
To restore run the following command.
$ litestream restore -o /path/to/new/db.sqlite3 /path/to/db.sqlite3 -
Once the restoration is completed, you should receive one or more files, including .sqlite, .shm, and .wal
-
Delete the corrupted old database files, and replace them with these new files.
-
Restart your application.