2017-05-16 01:48:13 +02:00
|
|
|
#!/bin/sh
|
|
|
|
|
|
|
|
|
|
#database settings
|
|
|
|
|
db_host=127.0.0.1
|
|
|
|
|
db_port=5432
|
|
|
|
|
|
2017-05-16 02:28:04 +02:00
|
|
|
#move to script directory so all relative paths work
|
|
|
|
|
cd "$(dirname "$0")"
|
|
|
|
|
|
|
|
|
|
#includes
|
2017-05-16 02:32:09 +02:00
|
|
|
. ../config.sh
|
2017-05-16 02:28:04 +02:00
|
|
|
|
|
|
|
|
#set the database password
|
|
|
|
|
export PGPASSWORD=$database_password
|
|
|
|
|
|
2017-05-16 01:48:13 +02:00
|
|
|
#set the date
|
|
|
|
|
now=$(date +%Y-%m-%d)
|
|
|
|
|
|
|
|
|
|
#make sure the backup directory exists
|
|
|
|
|
mkdir -p /var/backups/fusionpbx/postgresql
|
|
|
|
|
|
|
|
|
|
#backup the database
|
2019-01-25 04:15:04 +01:00
|
|
|
pg_dump --verbose -Fc --host=$db_host --port=$db_port -U fusionpbx fusionpbx --schema=public -f /var/backups/fusionpbx/postgresql/fusionpbx_auto_$now.sql
|
2017-05-16 01:48:13 +02:00
|
|
|
|
|
|
|
|
#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;";
|