Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1 +1,3 @@
november_2022/
november_2022/
*_neurovault_data/
scratch
Binary file added 2025-05-20_neurovault_data.tar.gz
Binary file not shown.
6 changes: 6 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -51,3 +51,9 @@ cd november_2022

sqlite3 neurovault.sqlite3
```

## Creating the Backup on Prodution

```
export PGUSER=<user>; export PGPASSWORD=<password>; export PGHOST=<psql host>; ./create_export.sh
```
23 changes: 23 additions & 0 deletions create_export.sh
Original file line number Diff line number Diff line change
@@ -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