Backup up Postgres Databases
April 22, 2018
I wanted to dump the contents of some postgres databases into files, complete with a date timestamp. I also wanted to gzip the files to save disk space.
This can be done with the following in the postgres user crontab file:
0 4 *** pg_dump databasename | gzip > /home/drumcoder/db/database-`date '+%Y%m%d%H%M%S'`.sql.gz