diff --git a/.gitignore b/.gitignore index 4f595ae..ab45fa7 100644 --- a/.gitignore +++ b/.gitignore @@ -1 +1,3 @@ -november_2022/ \ No newline at end of file +november_2022/ +*_neurovault_data/ +scratch diff --git a/2025-05-20_neurovault_data.tar.gz b/2025-05-20_neurovault_data.tar.gz new file mode 100644 index 0000000..5e1c5fa Binary files /dev/null and b/2025-05-20_neurovault_data.tar.gz differ diff --git a/README.md b/README.md index a0afa1a..ecbbda4 100644 --- a/README.md +++ b/README.md @@ -51,3 +51,9 @@ cd november_2022 sqlite3 neurovault.sqlite3 ``` + +## Creating the Backup on Prodution + +``` +export PGUSER=; export PGPASSWORD=; export PGHOST=; ./create_export.sh +``` diff --git a/create_export.sh b/create_export.sh new file mode 100755 index 0000000..c62a114 --- /dev/null +++ b/create_export.sh @@ -0,0 +1,23 @@ +#!/bin/bash +############################################################################################ +# For use on neurovault production server to generate tar backups used in this repository. # +############################################################################################ + +set -euxo pipefail + +tables=('statmaps_atlas' 'statmaps_basecollectionitem' 'statmaps_cognitiveatlascontrast' 'statmaps_cognitiveatlastask' 'statmaps_collection_communities' 'statmaps_collection_contributors' 'statmaps_collection' 'statmaps_community' 'statmaps_statisticmap' 'statmaps_image' 'statmaps_nidmresults' 'statmaps_nidmresultstatisticmap') + +if [[ -z "$PGPASSWORD" || -z "$PGHOST" || -z "$PGUSER" ]]; then + echo "Set PGPASSWORD, PGHOST and PGUSER environment variables." + exit 126 +fi + +cd "$(dirname "$0")" +mkdir -p scratch/ + +for table in ${tables[@]}; do + psql -c "COPY (select * from $table) TO STDOUT WITH CSV HEADER" > ./scratch/$table.csv +done + +dname=$(date +%F)_neurovault_data +tar --transform "s/scratch/$dname/" -czf $dname.tar.gz scratch