Guides
dump_data_dir() checkpoints the database and writes
the current data directory into a tar archive.
let db = pglite::PGlite::open("./data").await?;
db.dump_data_dir("./backup.tar").await?;
db.close().await?;
Restore into a directory before opening it:
pglite::PGlite::restore_data_dir("./backup.tar", "./restored")?;
let db = pglite::PGlite::open("./restored").await?;
The restore helper removes postmaster.pid after
unpacking.
Operational notes
- Dump while the database handle is open.
- Close or drop clients before replacing a live data directory.
- Keep feature compatibility in mind. For example, an ICU-initialized data directory needs an ICU-capable build.
