VitalPBX Call Recordings and Backups in Amazon S3

I hope that I am correct with my conclusions, but anyone please feel free to correct me.

I wanted to follow the original guide here Seamlessly Store VitalPBX Call Recordings In Amazon S3 and while looking for it I found a forum post that ran into issues with playing the call recordings back after following the steps, Using Amazon Bucket for Call Recordings. After some research there seems to be a potential issue with the s3 mounting commands in the original guide that may cause issues with how the permissions are being set on new recordings made after migrating the call recordings to the s3 Bucket.

Before:

sudo s3fs YOUR_BUCKET_NAME /mnt/s3bucket -opasswd_file=/root/.passwd-s3fs -ourl=https://s3.YOUR_REGION.amazonaws.com -o allow_other -ouse_cache=/tmp

After:

sudo s3fs YOUR_BUCKET_NAME /mnt/s3bucket -opasswd_file=/root/.passwd-s3fs -ourl=https://s3.YOUR_REGION.amazonaws.com -o allow_other -ouse_cache=/tmp -o umask=0002

Before:

s3fs#YOUR_BUCKET_NAME /mnt/s3bucket fuse _netdev,allow_other,passwd_file=/root/.passwd-s3fs,url=https://s3.YOUR_REGION.amazonaws.com,use_cache=/tmp 0 0

After:

s3fs#YOUR_BUCKET_NAME /mnt/s3bucket fuse _netdev,allow_other,passwd_file=/root/.passwd-s3fs,url=https://s3.YOUR_REGION.amazonaws.com,use_cache=/tmp,umask=0002 0 0

I have also plagiarised the original post :grimacing: and added steps to the original instructions for also sending your VitalPBX Backups to the s3 Bucket :grin:


**

Seamlessly Store VitalPBX Call Recordings and Backups in Amazon S3

**

Efficient management of call recordings has become a cornerstone for businesses leveraging VoIP systems.

This comprehensive guide unveils a game-changing solution for VitalPBX users: configuring s3fs to seamlessly store Asterisk call recordings directly in Amazon S3.

By harnessing the power of cloud storage, this integration offers unparalleled scalability, robust reliability, and optimized cost-effectiveness.

Whether you’re a small business looking to streamline operations or a large enterprise aiming to enhance data management, this step-by-step tutorial will empower you to elevate your VitalPBX system to new heights of efficiency and accessibility.

Why Use Amazon S3 for Call Recordings?

  • Scalability: S3 provides virtually unlimited storage capacity.
  • Durability: Amazon S3 is designed for 99.999999999% durability.
  • Cost-effective: Pay only for the storage you use.
  • Accessibility: Access your recordings from anywhere with an internet connection.

Step-by-Step Configuration Guide

1. Install s3fs-fuse

First, we need to install the s3fs-fuse package, which allows us to mount an S3 bucket as a local filesystem:

sudo apt update

sudo apt install s3fs

2. Set Up AWS Credentials

Create a credentials file with your AWS Access Key and Secret Key:

  1. Create a password file to store AWS credentials (only accessible to root):

sudo echo ‘ACCESS_KEY:SECRET_KEY’ > /root/.passwd-s3fs

sudo chmod 600 /root/.passwd-s3fs

Replace ACCESS_KEY and SECRET_KEY with your AWS credentials.

3. Create the Mount Point

Create a directory where the S3 bucket will be mounted.

sudo mkdir -p /mnt/s3bucket/

4. Mount the S3 Bucket

Use s3fs to mount your S3 bucket:

Replace YOUR_BUCKET_NAME and YOUR_REGION with your S3 bucket name and AWS region.

sudo s3fs YOUR_BUCKET_NAME /mnt/s3bucket -opasswd_file=/root/.passwd-s3fs -ourl=https://s3.YOUR_REGION.amazonaws.com -o allow_other -ouse_cache=/tmp -o umask=0002

5. Set Up Symlink for Asterisk Recordings

Create a symbolic link for Asterisk to access recordings from the S3-mounted directory:

  1. Create the monitor folder in your bucket

mkdir -p /mnt/s3bucket/monitor/

  1. Backup existing recordings

mv /var/spool/asterisk/monitor/* /mnt/s3bucket/monitor/

  1. Remove any existing directory at the target location after backing up the recordings:

sudo rm -rf /var/spool/asterisk/monitor

  1. Create the symbolic link to the S3 bucket:

sudo ln -s /mnt/s3bucket/monitor /var/spool/asterisk/monitor

6. Set Proper Permissions

Ensure asterisk has the necessary permissions to read and write to the S3-mounted directory.

sudo chown -R asterisk:asterisk /mnt/s3bucket/monitor

sudo chmod -R 770 /mnt/s3bucket/monitor

7. Set Up Symlink for VitalPBX Backups

Create a symbolic link for Asterisk to access recordings from the S3-mounted directory:

  1. Create the monitor folder in your bucket

mkdir -p /mnt/s3bucket/backup/

  1. Backup existing backups

mv /var/lib/vitalpbx/backup/* /mnt/s3bucket/backup/

  1. Remove any existing directory at the target location after backing up the recordings:

sudo rm -rf /var/lib/vitalpbx/backup

  1. Create the symbolic link to the S3 bucket:

sudo ln -s /mnt/s3bucket/backup /var/lib/vitalpbx/backup

8. Set Proper Permissions

Ensure asterisk has the necessary permissions to read and write to the S3-mounted directory.

sudo chown -R www-root: www-root /mnt/s3bucket/backup

sudo chmod -R 770 /mnt/s3bucket/backup

9. Configure Auto-mounting (Optional)

For automatic mounting on system boot, add this line to /etc/fstab:

  1. Open /etc/fstab:

sudo nano /etc/fstab

  1. Add the following line (replacing placeholders with your values):

s3fs#YOUR_BUCKET_NAME /mnt/s3bucket fuse _netdev,allow_other,passwd_file=/root/.passwd-s3fs,url=https://s3.YOUR_REGION.amazonaws.com,use_cache=/tmp,umask=0002 0 0

10. Verify the Setup

To verify the Backup to s3 changes:

Create a new Backup Plan with the smallest possible options, I chose to not include and Add-os, CDR Records, Call Recordings or Voicemail, I only included Faxes

Save the backup plan and run it

To verify the call recordings to s3 changes:

Restart Asterisk and test recording functionality to confirm files are stored in /mnt/s3bucket/monitor.

sudo systemctl restart asterisk

Conclusion

By following this guide, you’ve successfully configured your VitalPBX system to store call recordings in Amazon S3. This setup offers improved scalability, reliability, and accessibility for your call recordings, allowing your business to manage its communication data more effectively.

Remember to regularly check your S3 bucket usage and implement appropriate lifecycle policies to manage your storage costs efficiently. Happy recording!

1 Like

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.