Skip to content

Instantly share code, notes, and snippets.

@KhodeN
Created January 28, 2016 09:37
Show Gist options
  • Save KhodeN/26cd4c967bf6cfb5f17b to your computer and use it in GitHub Desktop.
Save KhodeN/26cd4c967bf6cfb5f17b to your computer and use it in GitHub Desktop.
dump psql by cron
#!/bin/bash
now=$(date +"%Y-%m-%d_%H:%M")
cd /projects/datamarket
pg_dump -U postgres dm | gzip > backups/dm_dump_$now.sql.gz
# use this row to backup every hour
# crontab -e
# * */1 * * * /projects/datamarket/dump.sh
# set password for ~/.pgpass (chmod 600)
# localhost:5432:*:postgres:myPassword
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment