From Jittery Hornbill, 7 Years ago, written in Plain Text.
- go back
Embed
Viewing differences between and Untitled
  1. #!/bin/sh
  2.  
  3. #export PGPASSWORD="zzz"
  4. db_host=127.0.0.1
  5. db_port=5432
  6.  
  7. now=$(date +%Y-%m-%d)
  8. mkdir -p /var/backups/fusionpbx/postgresql
  9.  
  10. echo "Backup Started"
  11.  
  12. #delete postgres backups
  13. find /var/backups/fusionpbx/postgresql/fusionpbx_pgsql* -mtime +4 -exec rm {} \;
  14.  
  15. #delete the main backup
  16. find /var/backups/fusionpbx/*.tgz -mtime +2 -exec rm {} \;
  17.  
  18. #backup the database
  19. pg_dump --verbose -Fc --host=$db_host --port=$db_port -U fusionpbx fusionpbx --schema=public -f /var/backups/fusionpbx/postgresql/fusionpbx_pgsql_$now.sql
  20.  
  21. #package
  22. 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/$
  23.  
  24. #source
  25. #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 $
  26.  
  27. echo "Backup Completed"
  28.