#!/bin/bash
###################################################################################
# Insert the destination directory for your backups surrounded by quotes below: #
# #
#backuploc="/incredible-backup" #
#backuploc="/mnt/pogoplug/WD My Book 1110/PIAF-Backup" #
###################################################################################
backuploc=""
###################################################################################
# #
# If you wish to use a temporary directory other than the default then #
# insert the path to a directory to be used for creation of temporary #
# files below between the "" below. #
# #
# Example: scratchloc="/mnt/scratch/" #
###################################################################################
scratchloc=""
#
# Copyright (C) 2010 Ward Mundy
#
# IncredibleBackup 1.0 is licensed under the GPL2 license
#
# For a copy of license, visit http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
#
# For additional information, contact us: http://pbxinaflash.com/about/comment.php
#
#
#
clear
echo "IncredibleBackup is free software PROVIDED AS IS subject to GPL2 license."
echo "NO WARRANTIES EXPRESS OR IMPLIED ARE PROVIDED WITH THIS SOFTWARE"
echo "INCLUDING THE IMPLIED WARRANTIES OF FITNESS FOR USE AND MERCHANTABILITY."
echo "YOU AGREE TO ASSUME ALL RISK AND TO DETERMINE SUITABILITY TO MEET YOUR NEEDS."
echo "Before continuing, read the license:"
echo "http://www.gnu.org/licenses/old-licenses/gpl-2.0.html"
echo " "
if [ "$scratchloc" = "" ]; then
echo "Scratch Location is the Default /"
scratchloc="/"
else
# Add the / if it is missing
if [ `echo "$scratchloc" | grep "[^/]$"` ]; then scratchloc="$scratchloc/"; fi
echo "Incredible Backup Scratch Path: $scratchloc"
fi
echo " "
#
if [ ! -d "$scratchloc" ] && [ ! "$scratchloc" = "" ]; then
echo " "
echo "Scratch location not available"
echo "Make sure the scratchloc string is empty (i.e scratchloc='') to use default path or"
echo "Check that your desired path exists and a / is at the end of the scratchloc string"
echo "Make sure if your using a mnt share that it is mounted!"
echo " "
echo "Then run the script again."
echo " "
echo " "
exit
fi
#
if [ -z "$backuploc" ]; then
echo " "
echo "Before using IncredibleBackup, please enter"
echo "the target directory for your backups by editing"
echo "this script: nano -w incrediblebackup"
echo "If storing your backups on this server, do NOT"
echo "use /root or /var/www directory trees for storage!"
echo "Preferably create a new directory, for example:"
echo "mkdir /incredible-backup"
echo "Then run the script again."
echo " "
echo " "
exit
elif [ ! -d "$backuploc" ]; then
echo " "
echo "Backup destination ($backuploc) is NOT on line."
echo "Please correct the problem and try again."
echo " "
echo " "
exit
fi
tstamp=`date +%s`
#
# Comment out the following line if you want to use this backup in a cron job.
# Only comment out the following lines after you agree to the terms of the GPL2 license.
echo "Incredible Backup Destination: $backuploc/$tstamp.tgz"
echo " "
read -p "To proceed at your own risk and agree to license, press Enter. Otherwise Ctrl-C."
#
clear
echo "Incredible Backup starting..."
cd /root
echo "Backing up current FreePBX distro version to /root..."
fpbxver=`sed -n 4p /var/www/html/admin/modules/framework/module.xml | cut -c11-15`
#wget -N http://mirror.freepbx.org/freepbx-2.5.1.tar.gz
#wget -N http://mirror.freepbx.org/freepbx-2.5.2.tar.gz
#wget -N http://mirror.freepbx.org/freepbx-2.6.0.tar.gz
#wget -N http://mirror.freepbx.org/freepbx-2.7.0.tar.gz
wget -N http://mirror.freepbx.org/freepbx-$fpbxver.tar.gz
echo "Stopping services..."
amportal stop
service mysqld stop
service httpd stop
cd $scratchloc
echo "Creating tarball..."
tar -cf $tstamp.tar /var/www/html /var/lib/asterisk /var/lib/mysql /root /etc/asterisk /tftpboot
tar -uf $tstamp.tar /etc/pbx /etc/crontab /etc/sudoers /etc/amportal.conf /etc/odbc.ini /etc/odbcinst.ini
tar -uf $tstamp.tar /var/lib/asterisk/sounds/tts /var/lib/asterisk/sounds/custom /var/spool/asterisk
tar -cf $tstamp.1.tar /etc/hosts /etc/resolv.conf /etc/sysconfig/network-scripts/ifcfg* /etc/sysconfig/iptables /etc/sysconfig/network
tar -uf $tstamp.tar $tstamp.1.tar
rm $tstamp.1.tar
tar -cf $tstamp.2.tar /etc/mail
tar -uf $tstamp.tar $tstamp.2.tar
rm $tstamp.2.tar
tar -cf $tstamp.3.tar /usr/local/bin /usr/local/sbin /usr/src
tar -uf $tstamp.3.tar /usr/sbin/fxotune /usr/sbin/asterisk /usr/sbin/astgenkey /usr/sbin/autosupport /usr/sbin/rasterisk /usr/sbin/aelparse /usr/sbin/astman /usr/sbin/muted /usr/sbin/smsg /usr/sbin/stereorize /usr/sbin/streamplayer /usr/sbin/amportal /usr/sbin/safe_asterisk /usr/sbin/fpga_load /usr/sbin/genzaptelconf /usr/sbin/lszaptel /usr/sbin/xpp_blink /usr/sbin/xpp_sync /usr/sbin/zapconf /usr/sbin/zaptel_hardware /usr/sbin/zt_registration
tar -uf $tstamp.3.tar /usr/sbin/astribank* /usr/sbin/dahdi* /usr/sbin/lsdahdi /usr/sbin/sethdlc /usr/sbin/twinstar
tar -uf $tstamp.tar $tstamp.3.tar
rm $tstamp.3.tar
echo "Starting services..."
service httpd restart
service mysqld restart
amportal start
echo "Compressing tarball..."
gzip $tstamp.tar
echo "Done."
echo "Moving $tstamp.tgz backup to $backuploc directory..."
mv $tstamp.tar.gz "$backuploc/$tstamp.tgz"
echo " "
echo " "
echo "Thank you for using PBX in a Flash and the Incredible PBX."
echo "Incredible Backup is done."
Link up your team and customers Phone System
Live Chat
Video Conferencing
Hosted or Self-managed. Up to 10 users free forever. No credit card. Try risk free.
Check your inbox!
We’ve sent you an email. Click on the button in the email body to verify your email address – (if you can not find it, check your spam folder).
Upon verification you will be directed to the 3CX setup wizard.