summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-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 \