Skip to content

Instantly share code, notes, and snippets.

@cschell
Created August 8, 2014 09:31
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 2 You must be signed in to fork a gist
  • Save cschell/84a8842ea56855484827 to your computer and use it in GitHub Desktop.
Save cschell/84a8842ea56855484827 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 -
@cschell
Copy link
Author

cschell commented Aug 8, 2014

@lucenarenato
Copy link

Como coloca data no nome do arquivo?
How do you put date in the file name?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment