Docs / How-to guides

Hand a Database Between Two Machines

One data directory, two machines, one at a time.

The one rule

One machine runs the database at a time. Locks do not cross between peers, so two servers on one data directory would not see each other. Stop on A, start on B. Never both.

PostgreSQL

Run the database off the shared folder on machine A, stop it, remove its pid file, and start it on machine B. It picks up every row:

# Machine A (Linux)
initdb -D ~/KeibiDrop/Mount/pgdata
pg_ctl -D ~/KeibiDrop/Mount/pgdata start
# ... create tables, insert, update ...
pg_ctl -D ~/KeibiDrop/Mount/pgdata stop
rm ~/KeibiDrop/Mount/pgdata/postmaster.pid

# Machine B (macOS), same data directory, over the wire
pg_ctl -D ~/KeibiDrop/Mount/pgdata start
psql -c "select count(*) from t;"   # all rows are here

The data directory streams on demand; the server reads the pages it needs. This is the demanding case, fsync ordering, random page reads, hundreds of open files, and it round-trips without corruption.

SQLite

Same hand-off shape: close the database on one side before opening it on the other.

sqlite3 ~/KeibiDrop/Mount/data/app.db "PRAGMA journal_mode=DELETE;"

Databases that write through mmap (LMDB and similar) are not supported on the mount at all. Keep those local.

What is verified

The PostgreSQL round-trip is part of KeibiDrop's test battery: a full data directory created on one peer, served cold over a real intercontinental link, delivered byte-identical (matching checksums) and query-consistent under a live PostgreSQL instance on the other side, in repeated runs.

Good for moving a dev database between desktop and laptop, or sharing a working dataset without dump and restore. For the reasons behind the one rule, see Limits and known issues.