From ace09bd25a643b274451991d7d6fa037c78163b4 Mon Sep 17 00:00:00 2001 From: Ramon Wenger Date: Wed, 27 Sep 2023 22:55:29 +0200 Subject: [PATCH] Add script to drop and restore a database --- bin/drop-and-restore-database.sh | 13 +++++++++++++ 1 file changed, 13 insertions(+) create mode 100755 bin/drop-and-restore-database.sh diff --git a/bin/drop-and-restore-database.sh b/bin/drop-and-restore-database.sh new file mode 100755 index 00000000..37348309 --- /dev/null +++ b/bin/drop-and-restore-database.sh @@ -0,0 +1,13 @@ +#!/bin/bash + +while getopts d:f: flag +do + case "${flag}" in + d) database=${OPTARG};; + f) filename=${OPTARG};; + esac +done + +psql -c "drop database $database;" +psql -c "create database $database with owner skillbox;" +pg_restore --verbose --clean --no-acl --no-owner -d $database $filename