4 ms·
SQLite has a ".backup" command that you should always use to backup a SQLite DB. You're risking data loss/corruption using "cp" to backup your database as presc
by infamia 6mo ago
SQLite has a ".backup" command that you should always use to backup a SQLite DB. You're risking data loss/corruption using "cp" to backup your database as prescribed in the article.
https://sqlite.org/cli.html#special_commands_to_sqlite3_dot_commands_ https://sqlite.org/cli.html#special_commands_to_sqlite3_dot_...
- anonzzzies 6mo agoYeah, 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.
- chasil 6mo agoIt's fine if you run the equivalent of "init 1" first. Does your OS have a single-user mode?
- hombre_fatal 6mo agoWell, 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.
- refulgentis 6mo agoYou're confusing a workman's winking complaint about their tool, with, being unfair by not treating AI like a human.
- hombre_fatal 6mo agoI'm making a general observation about this frequent genre of complaint.
- refulgentis 6mo agoAnd I'm lucky enough to be making an observation about your general observation about this frequent genre of complaint
- hombre_fatal 6mo agoI don't get what you're trying to say then.
- HoldOnAMinute 6mo agoIt 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.
- anonzzzies 6mo agoBut we were talking server loads here: anyone runs sqlite server-side not in WAL mode?
- BartjeD 6mo agoThe bottom part of the article mentions they use .backup - did they add that later or did you miss it?
- BartjeD 6mo agoThe post now says they changed it due to feedback from Hacker news. All good.
- qingcharles 6mo ago"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 :)
- warmwaffles 6mo agoYes, especially if you are using a WAL.
- qingcharles 6mo agoTotally. It also explains why I was confused to find the WAL files when I was testing the backups last week.
- rogerbinns 6mo agoRelated, 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 https://sqlite.org/rsync.html