› VitalPBX Community Support › General Discussion › Shell script to rsync backup files to a remote server
- This topic has 7 replies, 5 voices, and was last updated 1 month ago by
david500.
- Post
-
- June 25, 2019 at 9:25 pm
I am still new to Linux and the CLI. Until backup via FTP becomes an option, does anyone have any quick and dirty tutorial on writing a shell script and cron job to rsync the contents of /var/lib/ombutel/static/backups/c4cablahblahblah/* to a remote server? I already have a server set up with SSH via cert.
I am trying this method instead of my particular VPS provider’s backup method because the restoration from backup images has not worked, and I have now 20+ VPBX servers to be backed up.
0
- Replies
-
- June 25, 2019 at 9:55 pm
You may use the SCP command, first, you may create a shell script named “backup.sh” under “/var/lib/ombutel/scripts” with the following content
#!/bin/bash
set -e
scp -r /var/lib/ombutel/static/backups/c4cablahblahblah remote_username@10.10.0.2:/remote/directoryAfter create the script you must give it execution permissions:
chmod +x backup.sh
Now, go to “/etc/cron.d” and create a file named “external-backup” with the following content:
0 0 * * 0 root /var/lib/ombutel/scripts/backup.sh
Save the file and restart the crond service
systemctl restart crond.service
With all these steps you will be able to copy backups to an external server every day at midnight
0- June 26, 2019 at 12:41 am
- June 26, 2019 at 1:19 am
- July 1, 2019 at 8:26 pm
For those who might be interested, until we have a GUI option, this is my script to take the nightly backup and drop it onto a remote directory named using the hostname (I have many servers to backup):
scp -i~/.ssh/backupserver /var/lib/ombutel/static/backup/c4ca4238a0b923820dcc509a6f75849b/* amicusvoice@[backupserver]:~/Backups/$(hostname)
I have about 30 servers to backup (fun). Next step is figuring out how to rsync over SSH so my backup server doesn’t fill up every six months.
Thanks for the help Mr R!
0- March 24, 2020 at 12:11 pm
- June 13, 2020 at 3:10 pm
- You must be logged in to reply to this topic.