Next: , Previous: , Up: Top   [Contents][Index]


10 Database Backup

Backup just the schema, no data:

$ pg_dump --schema-only --no-owner --no-privileges trip > schema.sql

Backup just the data, keeping the invariably large tile table separate:

$ pg_dump --data-only --no-owner --no-privileges --exclude-table=tile
trip \
> test-data.sql
$ pg_dump --data-only --no-owner --no-privileges --table=tile trip \
> tiles.sql

Backup schema, data and privileges, including commands to recreate tables, excluding the tile data:

$ pg_dump --clean --if-exists --no-owner --exclude-table-data=tile trip
\
> test-schema-data.sql

The above backup is suitable for every-day backup. If you intend to restore from the backup as part of your development and test cycle, remove the tile table data exclusion so that the cache is not lost.