Skip to content

Instantly share code, notes, and snippets.

@tsohr
Created August 14, 2014 00:21
Show Gist options
  • Select an option

  • Save tsohr/cbe3765df9d4ded46b68 to your computer and use it in GitHub Desktop.

Select an option

Save tsohr/cbe3765df9d4ded46b68 to your computer and use it in GitHub Desktop.
#!/bin/bash
if [ -z "$1" ]; then
echo "$0: need an input set file";
exit 1;
fi
if [ ! -f "$1" ]; then
echo "$0: file not found '$1'";
exit 1;
fi
systemctl stop postgresql.service
rm -rf /srv/pgsql/data/
su -c "initdb /srv/pgsql/data" postgres
systemctl start postgresql.service
cat "$1" | gunzip | su -c "psql --echo-hidden" postgres
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment