Skip to content

Instantly share code, notes, and snippets.

@ivawzh
Last active March 15, 2017 05:49
Show Gist options
  • Save ivawzh/297d79b3850e9d1e4a35616f55cc3d21 to your computer and use it in GitHub Desktop.
Save ivawzh/297d79b3850e9d1e4a35616f55cc3d21 to your computer and use it in GitHub Desktop.
download file via ssh & psql

login to server in private subnet hence we can talk to db:

ssh example_server

connect database

psql example_db_url -U example_user example_database

Export data to CSV file

\copy (select * from todo_tasks order by created_at desc) To '/tmp/output.csv' With CSV HEADER

Download the CSV file to local off the server:

  1. In another terminal tab
scp example_server:/tmp/output.csv ./output.csv
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment