Asterisk Backup Shell Script
From KlavoWiki
This section details the way I currently backup my Asterisk server. The script will create a tar.gz file with all the required files and then copy them to a Windows computer where I can store/archive the backups. If I ever need to restore a file or rebuild the server I can easily restore the configuration by decompressing the tar.gz file.
strCurDate=$(date +%Y%m%d-%H%M) mysqldump asterisk -p"mypassword" >/root/$strCurDate-asterisk.sql zip -r /root/$strCurDate /etc/dahdi zip -r /root/$strCurDate /etc/asterisk/* zip -r /root/$strCurDate /var/spool/asterisk/* zip -r /root/$strCurDate /var/lib/asterisk/agi-bin/* zip -r /root/$strCurDate /var/lib/asterisk/ivr/* zip -r /root/$strCurDate /var/lib/asterisk/moh/* zip /root/$strCurDate /var/lib/asterisk/astdb zip /root/$strCurDate /var/lib/asterisk/sounds/announce zip /root/$strCurDate /var/lib/asterisk/sounds/ivr zip /root/$strCurDate /var/lib/asterisk/sounds/au zip -r /root/$strCurDate /var/log/asterisk/* zip -r /root/$strCurDate /var/www/html/* zip -r /root/$strCurDate /usr/src/op_panel-0.29/* zip /root/$strCurDate /usr/lib/asterisk/modules/* zip /root/$strCurDate /root/$strCurDate-asterisk.sql zip /root/$strCurDate /opt/lumenvox/licenseserver/bin/*.bts rm -f /root/$strCurDate-asterisk.sql # Make temporary mount point /bin/mkdir /tmp/smbmountpoint /bin/mount -t smbfs -o workgroup=WORKGROUP,username=accountname,password=mypassword //pc.mycomputer.com/c$ /tmp/smbmountpoint #strCurDate=$(date +%Y%m%d) mkdir -p /tmp/smbmountpoint/Backup/Asterisk # Move the backup file into the $strSiteName folder /bin/mv /root/*.zip /tmp/smbmountpoint/Backup/Asterisk/ # Clean up by unmounting mount point and deleting temporary files /bin/umount /tmp/smbmountpoint /bin/rmdir /tmp/smbmountpoint