The old adage “Don't put all your eggs in one basket” also applies to your 3CX backups and recordings. Having a single copy of any important file can leave you with no option if the file gets lost or corrupted. This short article guides you on how to setup rsync on another machine or a cloud instance and safely keep redundant copies of your 3CX backups and recordings.

Better Safe Than Sorry

Rsync schema to create redundant copies of 3CX backups and recordings.

For this method to work, you need to have configured your 3CX PBX to backup and/or archive recordings on a remote machine. Then you can use rsync to mirror your backups and recordings on another Linux host. This schema provides optimal redundancy and can help you recover your 3CX PBX based on the synced data, if a disaster strikes.

How To Setup Rsync

The rsync command is a valuable utility in the admin’s toolbox, so let’s see how to set it up:

  1. Install rsync on the remote Linux machine holding your 3CX backups and/or archived recordings, i.e. the primary node or source. Enter this command as the root user or via sudo:
    • apt install rsync
  2. Use the same command to install rsync on another Linux machine for storing the redundant copies, i.e. the secondary node or destination.
  3. Verify that rsync is available on both machines by running rsync in test run mode (--dry-run) on the primary / source node. Ensure that you have proper user permissions on both the source and destination directories:
    • rsync --dry-run -avr /your/remote/3cx/backup/dir [email protected]:/home/3cxrsync/redundant_backups
  4. When prompted, enter the password for the user on the secondary / destination node to proceed and test the rsync transfer. If all goes to plan, the rsync test run transfer should be successful, displaying the transfer size and related stats.

Use rsync to copy 3CX backups and recordings.

Keep in mind that the rsync syntax is "rsync [options] [source] [destination]". In our example:

  • Options are chained as “--dry-run -avr”, i.e. “--dry-run” for test run, “a” for archive mode, “v” for verbose operation, “r” to recurse into the source directory.
  • Source is the local directory on the remote 3CX backup location, e.g. “/home/3cxbak/backups”.
  • Destination is the directory, e.g. “/home/3cxrsync/redundant_backups”. The destination directory needs to be on the rsync secondary node, e.g. ”rsyncsrv.example.com” and accessible by the specified user, e.g. “3cxrsync”. If you need to create a directory, use the “mkdir” command, e.g. “mkdir backups”.

Note that rsync operation can be configured with a multitude of options, e.g. “-o” and “-g” preserve the owner and group permissions on the transferred files. You can also add “z” for compression during transfer and “--progress” for status updates while transferring. To study all the rsync options in detail run:

rsync --help

Mirror Your Backups and Archived Recordings

After verifying that rsync works on both machines, you are ready to mirror your 3CX data. To copy your backups from the remote backup / source machine to the secondary / destination node, simply issue your command based on this example:

rsync -navzhr /your/remote/3cx/backup/dir [email protected]:/home/3cxrsync/redundant_backups

Again, you need to update all paths, user and host specifications to fit your network environment. When finished, you can repeat the command for your archived recordings, making sure to update appropriately the source and destination for the transfer.

Congratulations! You should now be able to keep your 3CX PBX safe with redundant copies for both backups and archived recordings.What’s more, the rsync transfer can be automatically scheduled, but we will cover this in another post.

Opening Your Rsync Server to the Internet

To ensure your rsync server is Internet-accessible, you need to open port 873 on your router or firewall and forward it to the rsync machine's internal IP. Restrict access to this port only for the IPs and hosts that will use rsync to backup. Also, if you prefer you can opt to use rsync via SSH (Secure SHell) for extra security. This way file transfers are encrypted and can be done via the exposed SSH service port. As an example, you can use this command for rsync over SSH:

rsync -navzhr -e ssh /your/remote/3cx/backup/dir [email protected]:/home/3cxrsync/redundant_backups

If you don’t currently have a spare SSH server don’t worry, read this guide and you’ll have one up and running in no time! And make sure you check out the new backup options in v16 Update 4 Beta. Stay safe.