From df1a274a6ddbe48306eb30478a77b0157df10f1c Mon Sep 17 00:00:00 2001 From: FusionPBX Date: Mon, 15 May 2017 17:48:13 -0600 Subject: [PATCH] Create empty.sh --- debian/resources/postgresql/empty.sh | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) create mode 100644 debian/resources/postgresql/empty.sh diff --git a/debian/resources/postgresql/empty.sh b/debian/resources/postgresql/empty.sh new file mode 100644 index 0000000..5602e73 --- /dev/null +++ b/debian/resources/postgresql/empty.sh @@ -0,0 +1,18 @@ +#!/bin/sh + +#database settings +db_host=127.0.0.1 +db_port=5432 + +#set the date +now=$(date +%Y-%m-%d) + +#make sure the backup directory exists +mkdir -p /var/backups/fusionpbx/postgresql + +#backup the database +pg_dump --verbose -Fc --host=$db_host --port=$db_port -U fusionpbx fusionpbx --schema=public -f /var/backups/fusionpbx/postgresql/fusionpbx_pgsql_$now.sql + +#empty the fusionpbx database +sudo -u postgres psql -d fusionpbx -c "drop schema public cascade;"; +sudo -u postgres psql -d fusionpbx -c "create schema public;";