Back up PostgreSQL with pg_dump
Datark's exports move data around; for a backup you can restore from, use pg_dump.
Datark can export a table as CSV, JSON, SQL and other formats. That is for moving and sharing data. It is not a backup: it does not capture roles, extensions or every object, and it does not promise you can rebuild the database from it. Datark has no backup feature. Use the engine’s own tool, which for PostgreSQL is pg_dump.
Take a backup
From a computer with PostgreSQL’s client tools installed:
pg_dump --format=custom --file=app.dump "postgresql://app_user@db.example.com:5432/app"
pg_dump asks for the password, or reads it from your ~/.pgpass file. Avoid putting the password in the command, where it can end up in your shell history.
The custom format is compressed and lets you restore selected objects. For a plain SQL script you can read, use --format=plain instead.
Restore it
Create an empty database, then restore into it:
createdb app_restored
pg_restore --dbname=app_restored app.dump
Test a restore before you need one.
Run it from Datark’s terminal
If the database server is one you can open an SSH shell on, you can run pg_dump there from the Terminal workspace on Mac, iPhone or iPad:
pg_dump --format=custom --file=/var/backups/app.dump app
Datark has no SFTP browser, so copy the file off the server with scp or rsync from another computer.
Other engines
- MySQL and MariaDB:
mysqldump. - SQLite: the
.backupcommand in thesqlite3shell, or the SQLite backup API. - MongoDB:
mongodump.
Related
Download Datark. It's free.
Free for Mac, iPhone and iPad. No account required.