Restore SQLite database from Litestream backup
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.)
1) Install Litestream and copy the config file that contains the AWS S3 credentials.
2) If you lost the original S3 credentials, you can create a new one from the AWS console. Remember to give the necessary S3 permissions.
3) To restore run the following command.
$ litestream restore -o /path/to/new/db.sqlite3 /path/to/db.sqlite3
4) Once the restoration is completed, you should receive one or more files, including .sqlite, .shm, and .wal
5) Delete the corrupted old database files, and replace them with these new files.
6) Restart your application.
AI Summary
gpt-4o-2024-08-06
2024-12-14 00:39:15
This article provides a step-by-step guide on restoring an SQLite database from a Litestream backup. It includes instructions on installing Litestream, handling AWS S3 credentials, executing the restore command, and replacing the old database files with the new ones before restarting the application.
Chrome On-device AI
2025-01-20 10:44:47
Share Article