From 53900e322075f2d2ab35673fd5b6b8a469019bf2 Mon Sep 17 00:00:00 2001 From: Bryan Newbold Date: Thu, 13 Sep 2018 14:47:52 -0700 Subject: improvements to ident_table_snapshot.sh --- extra/sql_dumps/ident_table_snapshot.sh | 20 +++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-) (limited to 'extra/sql_dumps') 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 \ -- cgit v1.2.3