Skip to content

Instantly share code, notes, and snippets.

@eignatov
Forked from cschell/postgres_ftp_backup.sh
Created February 5, 2020 19:41
Show Gist options
  • Save eignatov/e8ebe2e50afaceb36d9cf7f8fdca1603 to your computer and use it in GitHub Desktop.
Save eignatov/e8ebe2e50afaceb36d9cf7f8fdca1603 to your computer and use it in GitHub Desktop.
Backup gziped postgresql dump to a ftp server
# shell command:
pg_dump <db_name> -U <db_user> -h <db_host> | gzip | curl -u <ftp_user>:<ftp_password> ftp://<ftp_host>/`date '+%Y-%m-%d_%H-%M'`/db_backup.sql.gz --ftp-create-dirs -T -
# if you want to execute it through cron, be sure to escape all %!
# for crontab:
pg_dump <db_name> -U <db_user> -h <db_host> | gzip | curl -u <ftp_user>:<ftp_password> ftp://<ftp_host>/`date '+\%Y-\%m-\%d_\%H-\%M'`/db_backup.sql.gz --ftp-create-dirs -T -
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment