Skip to content

bash script to export all data from one organisation

Vincent Agnano requested to merge feature/dump-sql-for-organisation-2 into master

Created by: adipasquale

https://trello.com/c/NVvX8hOR/1030-dump-complet-des-donn%C3%A9es-par-organisation

new version of #822 , pure bash script without gem dependency and ruby script

./scripts/full_orga_sql_dump.sh 83 postgresql://localhost/rdv-sol-prod-dump

  • outputs one CSV file per table
  • outputs one global full_dump_organisation_XX.sql file that contains both the schema and data.

in order to do it, the script creates a temporary postgres db on the local machine, but it's dropped before the end of the script

@guillett this is not my most beautiful looking code , sorry. I'm far from being a bash expert 😨 so it's a lot of hacks.

there are a few tricky workarounds to deal with weird cases in the prod db where there's some incoherent data, and also some twists so that foreign keys constraints are respected when the csv files are imported back into a temporary db.

TODO :

  • export the versions table
  • double check that it's exhaustive and doesn't leak data

Merge request reports