by rsync · 3y ago · 0 comments
pg_dump -U postgres db | ssh user@rsync.net "dd of=db_dump"
mysqldump -u mysql db | ssh user@rsync.net "dd of=db_dump"
... but what is the equivalent command for SQLite ?I see that there is a '.dump' command for use within the SQLite console but that wouldn't be suitable for pipelining ... is there not a standalone 'sqlitedump' binary ?
I mention this as I once wasted a bunch of time trying to get a backup created from a '.dump | sqlite3' pipe to work before taking a proper look at the application code, and finally saw that it silently ignored databases without the correct 'application_id' or 'user_version'.
From the SQLite docs:
When a SAVEPOINT is the outer-most savepoint and it is not within a BEGIN...COMMIT then the behavior is the same as BEGIN DEFERRED TRANSACTION
Internally, the .dump command only runs SELECT queries.[0]: https://github.com/sqlite/sqlite/blob/3748b7329f5cdbab0dc486...
echo .dump | sqlite3 db | ssh user@rsync.net "dd of=db_dump"
It worked for me.sqlite3 db .dump | ...
I have added that one-liner to the remote commands page:
https://www.rsync.net/resources/howto/remote_commands.html
... although based on some of your siblings, I changed .dump to .backup ...
As noted '.dump' will work in your pipeline, but with the caveats I and others noted elsewhere.
sqlite3 my_database .dump | gzip -c | ssh foo "dd of=db_dump"
Technically .backup is better because it locks less and batches operations, rather than doing a bunch of selects in a transaction. Do you prefer slowly filling up local disk or locking all writes? sqlite3 /path/to/db.sqlite .dumpI once had a problem where my application couldn't read from a SQLite DB whose file was read-only. Turned out that even a read-only access to the DB required a write access to the directory, for a WAL DB. This was partly fixed years later, but I'd learned the hard way that a SQLite DB may be more than a single file.