I have a program which frequently crashes (Zotero), leaving its SQLite database locked and inaccessible for use by the restarted program unless I reboot (which I really want to avoid). So this does not work (using the generic name, db.sqlite
in place of the actual file in my case, zotero.sqlite
):
sqlite3 db.sqlite
sqlite> .backup main backup.sqlite
Error: database is locked
Based on an answer here, I tried:
echo ".dump" | sqlite3 db.sqlite | sqlite3 db.sqlite2
mv db.sqlite2 db.sqlite
db.sqlite2
is 0KB so this obviously did not work. Inspired by another thread, I also tried
echo '.dump' | sqlite3 db.sqlite > db.dump
cat db.dump | sqlite3 db.sqlite2
mv db.sqlite2 db.sqlite
which leads to db.sqlite2
which is slightly smaller in filesize to db.sqlite
, and Zotero (the file which requires the database) was not able to recognize its contents.
So this seems like a very brute force way of doing it, but worked:
cp -pv db.sqlite db.sqlite2
rm -f db.sqlite
mv db.sqlite2 db.sqlite
I wonder if there are any drawbacks to this solution and why the other methods are proposed before this one.
ps -aux | grep zotero
gives me(zotero-bin)
which appears to be a zombie process, and its parent process is1
so I can't kill it. This explains why I have torm -f
it?init
automatically reaps zombies. What is the state (STAT
) of that zotero process?init
? The stat of the(zotero-bin)
is?E
.init
is pid 1.E
is not documented; "exiting" or "error"?