aboutsummaryrefslogtreecommitdiffstats
path: root/extra/sql_dumps/ident_table_snapshot.sh
diff options
context:
space:
mode:
authorBryan Newbold <bnewbold@robocracy.org>2018-09-13 00:23:09 -0700
committerBryan Newbold <bnewbold@robocracy.org>2018-09-13 00:23:09 -0700
commit9f25d84accb5a3657cb4c7dd87014d9f13ccf2ef (patch)
tree4854b13512c65fd0bffddfb791c4c014a41088dc /extra/sql_dumps/ident_table_snapshot.sh
parentaa9abbbab67c6344d382a964b3c451e0bf212efe (diff)
downloadfatcat-9f25d84accb5a3657cb4c7dd87014d9f13ccf2ef.tar.gz
fatcat-9f25d84accb5a3657cb4c7dd87014d9f13ccf2ef.zip
improve dump scripts
Diffstat (limited to 'extra/sql_dumps/ident_table_snapshot.sh')
-rwxr-xr-xextra/sql_dumps/ident_table_snapshot.sh24
1 files changed, 24 insertions, 0 deletions
diff --git a/extra/sql_dumps/ident_table_snapshot.sh b/extra/sql_dumps/ident_table_snapshot.sh
new file mode 100755
index 00000000..b887d796
--- /dev/null
+++ b/extra/sql_dumps/ident_table_snapshot.sh
@@ -0,0 +1,24 @@
+#!/bin/bash
+
+set -e -u -o pipefail
+
+DATESLUG="`date +%Y-%m-%d.%H%M%S`"
+DATABASE="fatcat"
+
+echo "Running SQL..."
+psql fatcat < ./dump_idents.sql
+
+CHANGELOG_REV="`head -n1 /tmp/fatcat_ident_latest_changelog.tsv`"
+OUTFILE="fatcat_idents.$DATESLUG.r$CHANGELOG_REV.tar.xz"
+
+echo "Compressing..."
+tar -C /tmp -c --xz --verbose \
+ -f $OUTFILE \
+ fatcat_ident_latest_changelog.tsv \
+ fatcat_ident_containers.tsv \
+ fatcat_ident_creators.tsv \
+ fatcat_ident_files.tsv \
+ fatcat_ident_releases.tsv \
+ fatcat_ident_works.tsv
+
+echo "Done: $OUTFILE"