3 ms·
How do you backup a file like that?
by cm2187 2y ago
How do you backup a file like that?
- antithesis-nl 2y agoUsing the SQLite backup API, which pretty much corresponds to the .backup CLI command. It doesn't block any reads or writes, so the performance impact is minimal, even if you do it directly to slow-ish storage.
- hu3 2y ago> It doesn't block any reads or writes. That's neat! I bet it keeps growing a WAL file while the backup is ongoing right?
- rco8786 2y agoHard to imagine doing it any other way, which is probably fine up until you hit some larger files sizes.
- ncruces 2y agoThat copies the entire file each time (not just deltas). You may find sqlite_rsync better.
- leosanchez 2y agosqlite_rsync is new tool created by sqlite team. It might be useful.
- homebrewer 2y agoI use zfs snapshots, they work in diffs so they're very cheap to store, create, and replicate.
- blitzar 2y agoCtrl-c, Ctrl-v
- MyOutfitIsVague 2y agoThat's not great advice for a large database (and I wouldn't recommend it for small databases either). That incidentally works when the db is small enough that the copy is nearly atomic, but with a big copy, you can end up with a corrupt database. SQLite is designed such that a crashed system at any time does not corrupt a database. It's not designed such that a database can be copied linearly from beginning to end while it's being written to without corruption. Simply copying the database is only good enough if you can ensure that there are no write transactions opened during the entire copy. A reliable backup will need to use the .backup command, the .dump command, the backup API[0], or filesystem or volume snapshots to get an atomic snapshot. [0]: https://www.sqlite.org/backup.html https://www.sqlite.org/backup.html