-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathexportDhisData.sh
More file actions
51 lines (47 loc) · 5.34 KB
/
exportDhisData.sh
File metadata and controls
51 lines (47 loc) · 5.34 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
#!/bin/bash
HOST=$1
if [ -z "$HOST" ]; then
echo "Specify hostname and port"
else
sudo docker exec $HOST psql -d dhis2 -U postgres -c "COPY categoryoptioncombo TO STDOUT DELIMITER ';' CSV" > categoryoptioncombo.csv
sudo docker exec $HOST psql -d dhis2 -U postgres -c "COPY categorycombo TO STDOUT DELIMITER ';' CSV" > categorycombo.csv
sudo docker exec $HOST psql -d dhis2 -U postgres -c "COPY dataelementcategoryoption TO STDOUT DELIMITER ';' CSV" > dataelementcategoryoption.csv
sudo docker exec $HOST psql -d dhis2 -U postgres -c "COPY dataelementcategory TO STDOUT DELIMITER ';' CSV" > dataelementcategory.csv
sudo docker exec $HOST psql -d dhis2 -U postgres -c "COPY categories_categoryoptions TO STDOUT DELIMITER ';' CSV" > categories_categoryoptions.csv
sudo docker exec $HOST psql -d dhis2 -U postgres -c "COPY categorycombos_categories TO STDOUT DELIMITER ';' CSV" > categorycombos_categories.csv
sudo docker exec $HOST psql -d dhis2 -U postgres -c "COPY categorycombos_optioncombos TO STDOUT DELIMITER ';' CSV" > categorycombos_optioncombos.csv
sudo docker exec $HOST psql -d dhis2 -U postgres -c "COPY categoryoptioncombos_categoryoptions TO STDOUT DELIMITER ';' CSV" > categoryoptioncombos_categoryoptions.csv
sudo docker exec $HOST psql -d dhis2 -U postgres -c "COPY dataelement TO STDOUT DELIMITER ';' CSV" > dataelement.csv
sudo docker exec $HOST psql -d dhis2 -U postgres -c "COPY dataset TO STDOUT DELIMITER ';' CSV" > dataset.csv
sudo docker exec $HOST psql -d dhis2 -U postgres -c "COPY datasetelement TO STDOUT DELIMITER ';' CSV" > datasetelement.csv
sudo docker exec $HOST psql -d dhis2 -U postgres -c "COPY datasetsource TO STDOUT DELIMITER ';' CSV" > datasetsource.csv
sudo docker exec $HOST psql -d dhis2 -U postgres -c "COPY program TO STDOUT DELIMITER ';' CSV" > program.csv
sudo docker exec $HOST psql -d dhis2 -U postgres -c "COPY program_attributes TO STDOUT DELIMITER ';' CSV" > program_attributes.csv
sudo docker exec $HOST psql -d dhis2 -U postgres -c "COPY program_organisationunits TO STDOUT DELIMITER ';' CSV" > program_organisationunits.csv
sudo docker exec $HOST psql -d dhis2 -U postgres -c "COPY programstage TO STDOUT DELIMITER ';' CSV" > programstage.csv
sudo docker exec $HOST psql -d dhis2 -U postgres -c "COPY programstagedataelement TO STDOUT DELIMITER ';' CSV" > programstagedataelement.csv
sudo docker exec $HOST psql -d dhis2 -U postgres -c "COPY trackedentityattribute TO STDOUT DELIMITER ';' CSV" > trackedentityattribute.csv
sudo docker exec $HOST psql -d dhis2 -U postgres -c "COPY trackedentity TO STDOUT DELIMITER ';' CSV" > trackedentity.csv
sudo docker exec $HOST psql -d dhis2 -U postgres -c "COPY dashboard TO STDOUT DELIMITER ';' CSV" > dashboard.csv
sudo docker exec $HOST psql -d dhis2 -U postgres -c "COPY dashboarditem TO STDOUT DELIMITER ';' CSV" > dashboarditem.csv
sudo docker exec $HOST psql -d dhis2 -U postgres -c "COPY eventreport TO STDOUT DELIMITER ';' CSV" > eventreport.csv
sudo docker exec $HOST psql -d dhis2 -U postgres -c "COPY relativeperiods TO STDOUT DELIMITER ';' CSV" > relativeperiods.csv
sudo docker exec $HOST psql -d dhis2 -U postgres -c "COPY dashboard_items TO STDOUT DELIMITER ';' CSV" > dashboard_items.csv
sudo docker exec $HOST psql -d dhis2 -U postgres -c "COPY optionset TO STDOUT DELIMITER ';' CSV" > optionset.csv
sudo docker exec $HOST psql -d dhis2 -U postgres -c "COPY eventreport_columns TO STDOUT DELIMITER ';' CSV" > eventreport_columns.csv
sudo docker exec $HOST psql -d dhis2 -U postgres -c "COPY eventreport_attributedimensions TO STDOUT DELIMITER ';' CSV" > eventreport_attributedimensions.csv
sudo docker exec $HOST psql -d dhis2 -U postgres -c "COPY eventreport_dataelementdimensions TO STDOUT DELIMITER ';' CSV" > eventreport_dataelementdimensions.csv
sudo docker exec $HOST psql -d dhis2 -U postgres -c "COPY eventreport_organisationunits TO STDOUT DELIMITER ';' CSV" > eventreport_organisationunits.csv
sudo docker exec $HOST psql -d dhis2 -U postgres -c "COPY trackedentitydataelementdimension TO STDOUT DELIMITER ';' CSV" > trackedentitydataelementdimension.csv
sudo docker exec $HOST psql -d dhis2 -U postgres -c "COPY trackedentityattributedimension TO STDOUT DELIMITER ';' CSV" > trackedentityattributedimension.csv
sudo docker exec $HOST psql -d dhis2 -U postgres -c "COPY objecttranslation TO STDOUT DELIMITER ';' CSV" > objecttranslation.csv
sudo docker exec $HOST psql -d dhis2 -U postgres -c "COPY datasettranslations TO STDOUT DELIMITER ';' CSV" > datasettranslations.csv
sudo docker exec $HOST psql -d dhis2 -U postgres -c "COPY dataelementtranslations TO STDOUT DELIMITER ';' CSV" > dataelementtranslations.csv
sudo docker exec $HOST psql -d dhis2 -U postgres -c "COPY programtranslations TO STDOUT DELIMITER ';' CSV" > programtranslations.csv
sudo docker exec $HOST psql -d dhis2 -U postgres -c "COPY programstagetranslations TO STDOUT DELIMITER ';' CSV" > programstagetranslations.csv
sudo docker exec $HOST psql -d dhis2 -U postgres -c "COPY trackedentityattributetranslations TO STDOUT DELIMITER ';' CSV" > trackedentityattributetranslations.csv
sudo docker exec $HOST psql -d dhis2 -U postgres -c "COPY categoryoptiontranslations TO STDOUT DELIMITER ';' CSV" > categoryoptiontranslations.csv
rm dhis-data.tar.gz
tar -zcvf dhis-data.tar.gz *
echo "Export completed"
fi