/
Radar Backup

Radar Backup

Database Dump

To dump a radar database from a remote server (live in this example) to a local file you can use the following command from a local terminal

pg_dump -U radar -h 10.38.181.78 -Fc -d radar > /path/to/file/radar.dump

You can dump to an existing file or point it at a directory and it will create the file for you.

The flags used are as follows;

  • -U = user
  • -h = host
  • -d = database name
  • -F = format

If the database is being dumped for local testing purposes it is worth considering the size of the logs table. It is considerably bigger than all the other tables combined. If it is surplus to requirements for the dump you can exclude the table by adding

--exclude-table-data=logs

In its current state, this significantly reduces the time required to dump and restore the database.

Details of the available flags and corresponding options can be found in the pg_dump documentation

Database Restore

To restore the database to a remote server (stagging in this example) from a local file you can use the following command from a local terminal

pg_restore -U radar -h 10.38.181.94 -d radar /path/to/file/radar.dump

It's worth noting that most of the flags can still be applied to this command but on the whole are not necessary. pg_restore will automatically detect most of the settings from the dump file.

Further details of pg_restore are available in the pg_restore documentation