Create empty.sh

This commit is contained in:
FusionPBX 2017-05-15 17:48:13 -06:00 committed by GitHub
parent d772720eb3
commit df1a274a6d
1 changed files with 18 additions and 0 deletions

18
debian/resources/postgresql/empty.sh vendored Normal file
View File

@ -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;";