Export Csv From Heroku

10 Aug 2019


Background

PlanITDR has a “newish” feature not widely circulated where the app will assign a company a unique @pdr-intg.com email address, and that company can forward their backup status emails to PlanITDR. Then PlanITDR will collect those logs in the database, parse them, and display any alerts, errors, or warnings in FleetView - our single pane of glass for backup status regardless of technology vendor.

When we bring on a new technology vendor, we ask the companies to go ahead and forward the logs to the pdr-intg.com email which is eventually collected in the unprocessed_logs table in the database. Then we can extract them and write the parser for that technology.

Extracting the Emails

# heroku pg:psql -r production
# select count(*) from unprocessed_logs;

 count
--------
  2004	

# \copy (select * from unprocessed_logs) TO unprocessed_logs.csv CSV DELIMITER ',' HEADER

# \q


Tags: development devops planitdr

Published on 10 Aug 2019 Find me on LinkedIn!