Home » Incredible PBX » CentOS/SL Platform » Incredible PBX Backup & Restore for Cloud-Based Servers

The Most Versatile VoIP Provider: FREE PORTING

Incredible PBX Backup & Restore for Cloud-Based Servers

One of the perplexing realities with VoIP-based servers is how few people actually back up their systems. For anyone who has ventured into the IT world over the past 40 years, there’s one maxim worth remembering: "It’s not a question of whether your server will fail. It’s only a question of when." Incredible PBX® always has provided a backup mechanism in standalone servers to recover from disasters. But then cloud-based computing came along. Two of our favorite providers, Digital Ocean and Vultr, offer a backup snapshot option for 20% of the monthly cost of your platform. But many others do not. And snapshots in the same facility only insulate you from catastrophic failures that don’t take down the entire facility. Think: DNS, bombs, floods, earthquakes, hurricanes, and disgruntled employees.

We obviously can’t solve all of the world’s problems. But what we can do is provide a generic backup mechanism that will work with most cloud implementations of Incredible PBX. It allows you to make a complete backup of your server, copy the image off site, and restore it at another cloud location or by deploying a virtual machine in your home or office with VirtualBox®. Today we’ll show you how.

Methodology. We’re assuming you are using the latest Incredible PBX 13-13 platform with either CentOS® or Scientific Linux™ 6 or 7 running Asterisk® 13. We’re also assuming your primary server is cloud-based. Your backup server can be cloud-based or a virtual machine running under VirtualBox on a desktop PC. The trick is to build the backup platform at or near the creation time of your primary server so that both are using nearly identical Linux components, the same version of Asterisk, the same version of Incredible PBX, and the same versions of the 1,000+ packages that comprise an Incredible PBX VoIP platform. This is easy at the time you create your primary server. It’s much more difficult 5 or 10 years down the road. So don’t be a procrastinator. Build your backup platform. And do it now! In the case of VirtualBox, you can create the virtual machine and turn it off until that rainy day occurs. It won’t cost you a dime other than a little disk storage space.

Overview. Here are the 5 Steps to put your backup implementation plan into place:

  1. Build & Configure Incredible PBX 13-13 Primary Server in the Cloud
  2. Build Barebones Incredible PBX 13-13 Server at Secondary Site
  3. Make a Backup of Your Primary Server Every Week
  4. Copy Weekly Backup Image to One or More Off-Site Locations
  5. Periodically Test Restoring Backup to Secondary Server

1. Build & Configure Primary Server

We’ve covered the procedure for building an Incredible PBX 13-13 server starting from a CentOS platform or from the Incredible PBX 13-13 ISO. We continue to recommend the CentOS or Scientific Linux 6.9 platform. Whether to create a Lean, Mean implementation or the Whole Enchilada is your call to make. Configure your Extensions, Trunks, and Routes, and you’re ready for business.

2. Build a Barebones Secondary Server

The hardest part of Step #2 is deciding where to build your secondary Incredible PBX 13-13 server. It doesn’t need to be in the cloud unless you prefer that option. Part of this decision may turn on how many servers you actually support. If you have a dozen primary servers, then it probably makes sense to add #13 as your backup server. Then it will be available in case of a failure of any of the other servers. Just make sure it’s in a location 1,000+ miles away from the primary server which should provide ample protection from North Korea’s Rocket Man. You can install the Lean, Mean version of Incredible PBX 13-13 with no additional configuration. Make sure the version of CentOS or Scientific Linux matches your primary server. As noted, VirtualBox is a perfectly adequate backup platform.

3. Make a Weekly Backup of Primary Server

We’re offering the following script for your use pursuant to the GPL2 license. By using the script at no cost, you agree to assume all risks and absolve us from any liability regarding bugs, performance, or any other failure in the code. If that’s acceptable to you, copy the commands below and create a backup-full script in the /root folder of your primary server. After saving the script, make it executable: chmod +x backup-full.

#!/bin/bash
# backup-full for Incredible PBX, Copyright (c) 2008-2018, Ward Mundy & Associates, LLC
# Licensed pursuant to GPL2. See /root/COPYING on any Incredible PBX server for details
amportal stop
service mysqld stop
service httpd stop
service sendmail stop
cd /
tar -cf /tmp/backup.tar /bin /etc /home /lib /lib64 /media /mnt /opt /root /sbin /usr /var
service sendmail start
service httpd start
service mysqld start
amportal start
tar --delete -f /tmp/backup.tar etc/udev/rules.d
tar --delete -f /tmp/backup.tar etc/sysconfig/network-scripts
tar --delete -f /tmp/backup.tar var/lib/dhclient
tar --delete -f /tmp/backup.tar etc/fstab
tar --delete -f /tmp/backup.tar etc/resolv.conf
tar --delete -f /tmp/backup.tar etc/hosts
tar --delete -f /tmp/backup.tar etc/hostname
gzip /tmp/backup.tar
echo "Your backup is available: /tmp/backup.tar.gz"
echo "Copy it and test it in a safe place OFF SITE"
echo " "


To run the script, execute the following command: /root/backup-full

We recommend running the backup-full script during hours when your PBX is not in active use since Asterisk and other services typically are shut down for 5-10 minutes. Depending upon the size and performance of your server, the backup typically takes 15-20 minutes. Once the backup script finishes, copy /tmp/backup.tar.gz to a safe place away from the primary server every week. You can automate the backup and the copying procedure with a cron job if desired. If your primary PBX doesn’t change regularly, alter the backup schedule.

UPDATE: As many of you appreciate, VMware platforms are a very different beast. The same is true of some cloud platforms which don’t play nicely with full backups from other environments. The telltale sign is abrupt reboots when you attempt to login to the web GUI using a browser. If you will be backing up FROM or restoring TO a VMware virtual machine or some other incompatible platform, here’s a workaround. The backup methodology needs to be adjusted to collect all of your PBX configuration data without messing with the underlying operating system configuration. This is similar to the original Incredible Backup methodology. You may also find it handy whenever you have a backup cloud server that is similarly configured to your main cloud server.

First, you need to assure that your versions of the major components are the same on both your primary and backup server. As noted before, the easiest way to do this is to build the two platforms simultaneously. If you plan to use either the Full Enchilada or Incredible Fax add-ons on your primary server, then they also need to be installed and configured on your backup server. Once the two servers are operational, you can shut down the backup server for the time being. Then make your customizations on the primary server and make a backup. The backup script above will work with the exception of the tar command line which should be replaced with the following (as a single line command):

tar -cf /tmp/backup.tar /var/www /var/lib/mysql /var/lib/asterisk /root /etc/asterisk /etc/crontab /etc/pbx /var/spool/asterisk /etc/freepbx.conf /etc/amportal.conf

The restore scenario outlined below will be the same for VMware-style backups except your passwords on the restored platform will be your original backup server passwords with the exception of your FreePBX® GUI and Apache web passwords which will be inherited from the primary server at the time of the backup image.

4. Copy Backup Image to Off-Site Location(s)

Once the backup script finishes, copy /tmp/backup.tar.gz to a safe place away from the primary server every week. You can automate the backup and the copying procedure with a cron job if desired. If your primary PBX doesn’t change regularly, alter the backup schedule.

5. How to Restore Backup to Secondary Server

Before patting yourself on the back from having made a successful backup, let’s try restoring it to your secondary server to be sure everything still works. Here are a couple of tips before we get started. First, in the event of an actual emergency, you will find recovery is simplified if you use fully-qualified domain names in registering extensions to your primary server. In this way, you can simply alter the IP address of the FQDN in your DNS server to point to the backup server without having to reconfigure every extension on your PBX. Second, trunks that are registered from your primary PBX will automatically be registered from your secondary PBX when you bring it on line. For that reason, test your secondary server during non-working hours and always be sure to shut down Asterisk on the primary server (amportal stop) before bringing up your secondary server. Finally, trunks that are supported by IP address configuration rather than registration will need to be manually reconfigured with the secondary IP address before they will be available for use.

We’re offering the following script for your use pursuant to the GPL2 license. By using the script at no cost, you agree to assume all risks and absolve us from any liability regarding bugs, performance, or any other failure in the code. If that’s acceptable to you, copy the commands below and create a restore-full script in the /root folder of your backup server(s). After saving the script, make it executable: chmod +x restore-full.

#!/bin/bash
# restore-full for Incredible PBX, Copyright (c) 2008-2018, Ward Mundy & Associates, LLC
# Licensed pursuant to GPL2. See /root/COPYING on any Incredible PBX server for details
amportal stop
service mysqld stop
service httpd stop
service sendmail stop
chattr +i /etc/resolv.conf
cd /
tar zxvf /tmp/backup.tar.gz
echo "Shut off Asterisk on primary server now."
read -p "Press any key to continue with reboot..."
reboot

To restore the backup, begin by copying the backup.tar.gz file to /tmp on your backup server. Then run the script you created above: /root/restore-full.

Once the restore is completed, your server will reboot. Log back in using the credentials from your primary server and make sure everything is working.

NOTE: If your primary server is using eth0 for its Ethernet connection and your backup server is using venet0, then you’ll need to modify /etc/sysconfig/knockd and then restart PortKnocker on the backup platform: service knockd restart. The command to add looks like this:

OPTIONS="-i venet0:0"

If you’re backing up from a venet0 platform and restoring to an eth0 platform, then you’d need to reverse the process by removing the above entry from /etc/sysconfig/knockd and restarting PortKnocker. Enjoy!

Published: Tuesday, January 23, 2018



NEW YEAR’S TREAT: If you could use one or more free DIDs in the U.S. with unlimited inbound calls and unlimited simultaneous channels, then today’s your lucky day. TelecomsXChange and Bluebird Communications have a few hundred thousand DIDs to give away so you better hurry. You have your choice of DID locations including New York, New Jersey, California, Texas, and Iowa. The DIDs support Voice, Fax, Video, and even Text Messaging (by request). The only requirement at your end is a dedicated IP address for your VoIP server. Once you receive your welcome email with your number, be sure to whitelist the provider’s IP address in your firewall. For Incredible PBX servers, use add-ip to whitelist the UDP SIP port, 5060, using the IP address provided in your welcoming email.

Here’s the link to order your DIDs.

Your DID Trunk Setup in your favorite GUI should look like this:

Trunk Name: IPC
Peer Details:
type=friend
qualify=yes
host={IP address provided in welcome email}
context=from-trunk

Your Inbound Route should specify the 10-digit DID. Enjoy!



Need help with Asterisk? Visit the PBX in a Flash Forum.


 

Special Thanks to Our Generous Sponsors


FULL DISCLOSURE: ClearlyIP, Skyetel, Vitelity, DigitalOcean, Vultr, VoIP.ms, 3CX, Sangoma, TelecomsXchange and VitalPBX have provided financial support to Nerd Vittles and our open source projects through advertising, referral revenue, and/or merchandise. As an Amazon Associate and Best Buy Affiliate, we also earn from qualifying purchases. We’ve chosen these providers not the other way around. Our decisions are based upon their corporate reputation and the quality of their offerings and pricing. Our recommendations regarding technology are reached without regard to financial compensation except in situations in which comparable products at comparable pricing are available from multiple sources. In this limited case, we support our sponsors because our sponsors support us.

BOGO Bonaza: Enjoy state-of-the-art VoIP service with a $10 credit and half-price SIP service on up to $500 of Skyetel trunking with free number porting when you fund your Skyetel account. No limits on number of simultaneous calls. Quadruple data center redundancy. $25 monthly minimum spend required. Tutorial and sign up details are here.

The lynchpin of Incredible PBX 2020 and beyond is ClearlyIP components which bring management of FreePBX modules and SIP phone integration to a level never before available with any other Asterisk distribution. And now you can configure and reconfigure your new Incredible PBX phones from the convenience of the Incredible PBX GUI.

VitalPBX is perhaps the fastest-growing PBX offering based upon Asterisk with an installed presence in more than 100 countries worldwide. VitalPBX has generously provided a customized White Label version of Incredible PBX tailored for use with all Incredible PBX and VitalPBX custom applications. Follow this link for a free test drive!
 

Special Thanks to Vitelity. Vitelity is now Voyant Communications and has halted new registrations for the time being. Our special thanks to Vitelity for their unwavering financial support over many years and to the many Nerd Vittles readers who continue to enjoy the benefits of their service offerings. We will keep everyone posted on further developments.
 



Some Recent Nerd Vittles Articles of Interest…