Database Reference
In-Depth Information
Backing up the database
Havingfunctionalbackupsofyourdataandworkisprobablytheleastappreciated,yet
themostimportantthingyoucandoforyourproductivity(andstresslevel).Youmay
think that you don't need to have backups of your PostGIS database because you
have the original data imported to the database. But, do you remember all the work
you did to develop the final product? How about the intermediary products? Even if
youremembereverystepintheprocess,howmuchtimewillittaketocreatethein-
termediary and final products?
Ifanyofthesequestionsgivesyoupause,youneedtocreateabackupforyourdata.
Fortunately,PostgreSQLmakesthebackupprocesspainlessoratleastlesspainful
than the alternatives.
Getting ready
Inthisrecipe,weusePostgreSQL's pg_dump utility.The pg_dump utilityensuresthat
the data being backed up is consistent, even if it is currently in use.
How to do it...
Use the following steps to back up a database.
1. Startbybackingupthe chapter10 databasebyexecutingthefollowingcom-
mand:
> pg_dump -f chapter10.backup -F custom
chapter10
We use the -f flag to specify that the backup should be placed in the
chapter10.backup file. We also use the -F flag to set the format of the
backup output as custom by default, the most flexible and compressed of
pg_dump's output formats.
2. InspectthebackupfilebyoutputtingthecontentsontoaSQLfilebyexecuting
the following command:
Search WWH ::




Custom Search