upvote
Related, there is also sqlite3_rsync that lets you copy a live database to another (optionally) live database, where either can be on the network, accessed via ssh. A snapshot of the origin is used so writes can continue happening while the sqlite3_rsync is running. Only the differences are copied. The documentation is thorough:

https://sqlite.org/rsync.html

reply
"I know about the .backup command, there's no way I'm using cp to backup the SQLite db from production."

Oh.

Guess I know what I'm fixing before lunch. Thank you :)

reply
Yes, especially if you are using a WAL.
reply
Totally. It also explains why I was confused to find the WAL files when I was testing the backups last week.
reply
Yeah, using cp to backup sqlite is a very bad idea. And yet, unless you know this, this is what Claude etc will implement for you. Every friggin' time.
reply
It works fine as long as no one is writing to the sqlite file and you are not in WAL mode, which is not the default.
reply
Well, humans also default to 'cp' until they learn the better pattern or find out their backup is missing data.

Also, my n=1 is that I told Claude to create a `make backup` task and it used .backup.

I don't understand the double standard though. Why do we pretend us humans are immaculate in these AI convos? If you had the prescience to be the guy who looked up how to properly back up an sqlite db, you'd have the prescience to get Claude to read docs. It's the same corner cut.

There's this weird contradiction where we both expect and don't expect AI to do anything well. We expect it to yolo the correct solution without docs since that's what we tried to make it do. And if it makes the error a human would make without docs, of course it did, it's just AI. Or, it shouldn't have to read docs, it's AI.

reply
It's fine if you run the equivalent of "init 1" first.

Does your OS have a single-user mode?

reply
The bottom part of the article mentions they use .backup - did they add that later or did you miss it?
reply
The post now says they changed it due to feedback from Hacker news. All good.
reply