From 4bf5794b2cb971902dd54d78b6e7f42edaa86736 Mon Sep 17 00:00:00 2001 From: FusionPBX Date: Mon, 24 Oct 2016 20:16:42 -0600 Subject: [PATCH] Create fusionpbx-backup.sh --- debian/resources/backup/fusionpbx-backup.sh | 27 +++++++++++++++++++++ 1 file changed, 27 insertions(+) create mode 100644 debian/resources/backup/fusionpbx-backup.sh diff --git a/debian/resources/backup/fusionpbx-backup.sh b/debian/resources/backup/fusionpbx-backup.sh new file mode 100644 index 0000000..000ee55 --- /dev/null +++ b/debian/resources/backup/fusionpbx-backup.sh @@ -0,0 +1,27 @@ +#!/bin/sh + +export PGPASSWORD="zzz" +db_host=127.0.0.1 +db_port=5432 + +now=$(date +%Y-%m-%d) +mkdir -p /var/backups/fusionpbx/postgresql + +echo "Backup Started" + +#delete postgres backups +find /var/backups/fusionpbx/postgresql/fusionpbx_pgsql* -mtime +4 -exec rm {} \; + +#delete the main backup +find /var/backups/fusionpbx/*.tgz -mtime +2 -exec rm {} \; + +#backup the database +pg_dump -Fc --host=$db_host --port=$db_port -U fusionpbx fusionpbx --schema=public -f /var/backups/fusionpbx/postgresql/fusionpbx_pgsql_$now.sql + +#package +tar -zvcf /var/backups/fusionpbx/backup_$now.tgz /var/backups/fusionpbx/postgresql/fusionpbx_pgsql_$now.sql /var/www/fusionpbx /usr/share/freeswitch/scripts /var/lib/freeswitch/storage /var/lib/freeswitch/recordings /etc/fusionpbx /etc/freeswitch + +#source +#tar -zvcf /var/backups/fusionpbx/backup_$now.tgz /var/backups/fusionpbx/postgresql/fusionpbx_pgsql_$now.sql /var/www/fusionpbx /usr/local/freeswitch/scripts /usr/local/freeswitch/storage /usr/local/freeswitch/recordings /etc/fusionpbx /usr/local/freeswitch/conf + +echo "Backup Completed"