mirror of
https://github.com/timescale/timescaledb.git
synced 2025-05-15 01:53:41 +08:00
Bump year in copyright information to 2022 and adjust same scripts to reference NOTICE that didn't have the reference yet. This patch also removes orphaned test/expected/utils.out.
46 lines
1.3 KiB
Bash
Executable File
46 lines
1.3 KiB
Bash
Executable File
#!/usr/bin/env bash
|
|
|
|
# This file and its contents are licensed under the Apache License 2.0.
|
|
# Please see the included NOTICE for copyright information and
|
|
# LICENSE-APACHE for a copy of the license.
|
|
|
|
# This script is used for restoring a hypertable from a tarball made with
|
|
# ts_dump.sh. It unarchives the tarball, producing a schema file and data file,
|
|
# which are then restore separately.
|
|
|
|
|
|
if [[ -z "$1" || -z "$2" ]]; then
|
|
echo "Usage: $0 hypertable tarfile_name"
|
|
echo " hypertable - Hypertable to restore"
|
|
echo " tarfile_name - Name of the tarball created by ts_dump.sh to restore"
|
|
echo " "
|
|
echo "Any connection options for pg_restore/psql (e.g. -d database, -U username) should be listed at the end"
|
|
exit 1
|
|
|
|
fi
|
|
|
|
HYPERTABLE=$1
|
|
TARFILE=$2
|
|
PREFIX="${TARFILE/.tar.gz/}"
|
|
shift 2
|
|
echo "Unarchiving tarball..."
|
|
tar xvzf $TARFILE
|
|
|
|
echo "Restoring hypertable's schema..."
|
|
if ! psql -q -v "ON_ERROR_STOP=1" "$@" < $PREFIX-schema.sql
|
|
then
|
|
echo "Restoring schema failed, exiting."
|
|
rm $PREFIX-data.csv
|
|
rm $PREFIX-schema.sql
|
|
exit $?
|
|
fi
|
|
|
|
echo "Restoring hypertable's data..."
|
|
if ! psql "$@" -v "ON_ERROR_STOP=1" -c "\COPY $HYPERTABLE FROM $PREFIX-data.csv DELIMITER ',' CSV"
|
|
then
|
|
echo "Restoring data failed, exiting."
|
|
fi
|
|
|
|
rm $PREFIX-data.csv
|
|
rm $PREFIX-schema.sql
|