I manage a few other PBX systems, and most can create a Cron Job and a Task that will push backups to a remote site. When can this become an option.
Where do you want to store your backups? It’s pretty easy to write a Shell script and put it in a crown that would FTP or transfer your files to another server or site.
If we could specify an s3 bucket and a rotation period, it would be convenient. For this I also keep a script running to do this for all my servers to send backup files multiple times daily to a Linode object storage bucket.
Do you mind sharing the script, please?
Would be great if it could be implemented in vitalPbx
Thanks a lot
Don’t mind at all, since ChatGPT did 90% of the work for me (I’m no programmer). I am sure others here can refine it, such as adding in a few more echo lines just for more efficient logging.
This script assumes several things, so you might have to adjust it if your conditions differ:
• Each of my servers has only one client, and has the url [client].[my_company_domain].
• My s3 buckets are courtesy of Linode (to whom, alongside VitalPBX, all due credit must be given for having saved my a$$ once Kerio started cratering several years ago).
• My servers have the s3cmd installed and configured for my region and bucketname.
Here is how I set it up for my busier servers:
• Create the script in /var/lib/vitalpbx/scripts/s3backup_server.sh
• Make it executable and give it right permissions:
sudo chmod +x /var/lib/vitalpbx/scripts/s3backup_server.sh
sudo chown www-data:www-data /var/lib/vitalpbx/scripts
• Create two cron profiles: the first for VitalPBX backups to run 4x daily, and a second to run 4x daily but 30 minutes later.
• Set VitalPBX’s Backup to run 4x daily, retaining only one backup file.
• Create a task using the second cron profile to run 30 minutes after the VitalPBX backup runs.
The script as it is written will:
- Sync the backup file to s3:/bucketname/backupfolder/clientname
- Delete any files in that target older than 7 days
- Retain the most recent backup file regardless of age
S3 Backup Script to be tested.txt (1.1 KB)
I do a pull of the backups to sync the VitalPBX backups, however, push should also be possible
- Setup SSH login keys
ssh-keygen
ssh-copy-id user@remotemachine
- Script to pull (modify to push?) to the central backup server
do_sync.sh – on central backup server
#set -x
#set -e
BACKUPBASEDIR='/opt/CompanyPhoneSystems/VitalPBX_Backup'
cd $BACKUPBASEDIR
echo "Syncing Remote Machine 1"
rsync -vr user@remotemachine:/var/lib/vitalpbx/backup/* RemoteMachine1/
Pull works for me as the backups are in the same source location
- Add a cron job
crontab -e
then paste
@hourly /opt/CompanyPhoneSystems/VitalPBX_Backup/do_sync.sh #hourly sync of VitalPBXsModify @hourly to @daily or other times, but since power/connectivity at the remote servers is often a problem afterhours, the rsync hourly means it will sync at the next opportunity