summaryrefslogtreecommitdiffstats
path: root/extra/sql_dumps/ident_table_snapshot.sh
diff options
context:
space:
mode:
authorBryan Newbold <bnewbold@robocracy.org>2018-09-13 14:47:52 -0700
committerBryan Newbold <bnewbold@robocracy.org>2018-09-13 14:47:52 -0700
commit53900e322075f2d2ab35673fd5b6b8a469019bf2 (patch)
tree376a6e318f3569ba34e754a0972617f9eadf3257 /extra/sql_dumps/ident_table_snapshot.sh
parentc204b81f548d632a3956f4ec67a6436128bf1494 (diff)
downloadfatcat-53900e322075f2d2ab35673fd5b6b8a469019bf2.tar.gz
fatcat-53900e322075f2d2ab35673fd5b6b8a469019bf2.zip
improvements to ident_table_snapshot.sh
Diffstat (limited to 'extra/sql_dumps/ident_table_snapshot.sh')
-rwxr-xr-xextra/sql_dumps/ident_table_snapshot.sh20
1 files changed, 15 insertions, 5 deletions
diff --git a/extra/sql_dumps/ident_table_snapshot.sh b/extra/sql_dumps/ident_table_snapshot.sh
index b887d796..f53c29f5 100755
--- a/extra/sql_dumps/ident_table_snapshot.sh
+++ b/extra/sql_dumps/ident_table_snapshot.sh
@@ -1,18 +1,28 @@
#!/bin/bash
+DATABASE_URI="${DATABASE_URI:-fatcat}"
+OUTPUT_DIR="${1:-.}"
set -e -u -o pipefail
+# This script needs to be run from the directory with the 'dump_idents.sql'
+# script in it.
+
+# The DATABASE_URI env variable is optional, defaults to 'fatcat' (meaning,
+# local postgres, database named 'fatcat')
+
+# An optional argument is a path to a directory to save output.
+
DATESLUG="`date +%Y-%m-%d.%H%M%S`"
-DATABASE="fatcat"
-echo "Running SQL..."
-psql fatcat < ./dump_idents.sql
+echo "Will move output to '${OUTPUT_DIR}'"
+echo "Running SQL (from '${DATABASE_URI}')..."
+psql $DATABASE_URI < ./dump_idents.sql
CHANGELOG_REV="`head -n1 /tmp/fatcat_ident_latest_changelog.tsv`"
-OUTFILE="fatcat_idents.$DATESLUG.r$CHANGELOG_REV.tar.xz"
+OUTFILE="${OUTPUT_DIR}/fatcat_idents.$DATESLUG.r$CHANGELOG_REV.tar.xz"
echo "Compressing..."
-tar -C /tmp -c --xz --verbose \
+tar -C /tmp -c --gzip --verbose \
-f $OUTFILE \
fatcat_ident_latest_changelog.tsv \
fatcat_ident_containers.tsv \