Last active
October 8, 2018 21:13
-
-
Save adam704a/f0f224826e4063cd49cef5b4830c85ae to your computer and use it in GitHub Desktop.
export postgres query to s3 as CSV
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
psql -h localhost hhis -U hhis -c "\copy (SELECT * FROM _view_events) to './dhis2-export.tsv' WITH NULL AS ''" | |
aws s3 cp dhis2-export.tsv s3://spla-dhis2/dhis2-export.tsv |
Author
adam704a
commented
Oct 4, 2017
•
- create a .pgpass in ~ to automate the authentication (this is the format hostname:port:database:username:password)
- schedule with cron (i.e. 0 0 * * * /home/dhis_ro/utils/export.sh)
- configure aws cli like this: aws configure
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment