forked from norman/fusionpbx-install.sh-github-mirror
Start working on Ubuntu
This commit is contained in:
27
ubuntu/resources/backup/fusionpbx-backup
Executable file
27
ubuntu/resources/backup/fusionpbx-backup
Executable file
@@ -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 --verbose -Fc --host=$db_host --port=$db_port -U fusionpbx fusionpbx --schema=public -f /var/backups/fusionpbx/postgresql/fusionpbx_pgsql_$now.sql
|
||||
|
||||
#package
|
||||
tar --exclude='/var/lib/freeswitch/recordings/*/archive' -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 /usr/share/freeswitch/sounds/music/
|
||||
|
||||
#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 /usr/local/freeswitch/sounds/music/
|
||||
|
||||
echo "Backup Completed"
|
||||
65
ubuntu/resources/backup/fusionpbx-maintenance
Executable file
65
ubuntu/resources/backup/fusionpbx-maintenance
Executable file
@@ -0,0 +1,65 @@
|
||||
#!/bin/sh
|
||||
|
||||
#settings
|
||||
export PGPASSWORD="zzz"
|
||||
db_host=127.0.0.1
|
||||
db_port=5432
|
||||
switch_package=true # true or false
|
||||
|
||||
#set the date
|
||||
now=$(date +%Y-%m-%d)
|
||||
|
||||
#make sure the directory exists
|
||||
mkdir -p /var/backups/fusionpbx/postgresql
|
||||
|
||||
#show message to the console
|
||||
echo "Maintenance Started"
|
||||
|
||||
#delete freeswitch logs older 7 days
|
||||
if [ .$switch_package = .true ]; then
|
||||
find /var/log/freeswitch/freeswitch.log.* -mtime +7 -exec rm {} \;
|
||||
else
|
||||
find /usr/local/freeswitch/log/freeswitch.log.* -mtime +7 -exec rm {} \;
|
||||
fi
|
||||
|
||||
#delete fax older than 90 days
|
||||
if [ .$switch_package = .true ]; then
|
||||
echo ".";
|
||||
#find /var/lib/freeswitch/storage/fax/* -name '*.tif' -mtime +90 -exec rm {} \;
|
||||
#find /var/lib/freeswitch/storage/fax/* -name '*.pdf' -mtime +90 -exec rm {} \;
|
||||
else
|
||||
echo ".";
|
||||
#find /usr/local/freeswitch/storage/fax/* -name '*.tif' -mtime +90 -exec rm {} \;
|
||||
#find /usr/local/freeswitch/storage/fax/* -name '*.pdf' -mtime +90 -exec rm {} \;
|
||||
fi
|
||||
#delete from the database
|
||||
#psql --host=127.0.0.1 --username=fusionpbx -c "delete from v_fax_files WHERE fax_date < NOW() - INTERVAL '90 days'"
|
||||
|
||||
#delete call recordings older than 90 days
|
||||
if [ .$switch_package = .true ]; then
|
||||
find /var/lib/freeswitch/recordings/*/archive/* -name '*.wav' -mtime +90 -exec rm {} \;
|
||||
find /var/lib/freeswitch/recordings/*/archive/* -name '*.mp3' -mtime +90 -exec rm {} \;
|
||||
else
|
||||
find /usr/local/freeswitch/recordings/*/archive/* -name '*.wav' -mtime +90 -exec rm {} \;
|
||||
find /usr/local/freeswitch/recordings/*/archive/* -name '*.mp3' -mtime +90 -exec rm {} \;
|
||||
fi
|
||||
psql --host=127.0.0.1 --username=fusionpbx -c "delete from v_call_recordings WHERE call_recording_date < NOW() - INTERVAL '90 days'"
|
||||
|
||||
|
||||
#delete voicemail older than 90 days
|
||||
if [ .$switch_package = .true ]; then
|
||||
echo ".";
|
||||
#find /var/lib/freeswitch/storage/voicemail/default/* -name 'msg_*.wav' -mtime +90 -exec rm {} \;
|
||||
#find /var/lib/freeswitch/storage/voicemail/default/* -name 'msg_*.mp3' -mtime +90 -exec rm {} \;
|
||||
else
|
||||
echo ".";
|
||||
#find /usr/local/freeswitch/storage/voicemail/* -name 'msg_*.wav' -mtime +90 -exec rm {} \;
|
||||
#find /usr/local/freeswitch/storage/voicemail/* -name 'msg_*.mp3' -mtime +90 -exec rm {} \;
|
||||
fi
|
||||
#psql --host=127.0.0.1 --username=fusionpbx -c "delete from v_voicemail_messages WHERE to_timestamp(created_epoch) < NOW() - INTERVAL '90 days'"
|
||||
|
||||
#delete call detail records older 90 days
|
||||
#psql --host=127.0.0.1 --username=fusionpbx -c "delete from v_xml_cdr WHERE start_stamp < NOW() - INTERVAL '90 days'"
|
||||
|
||||
#completed message
|
||||
echo "Maintenance Completed";
|
||||
Reference in New Issue
Block a user