Backup 3CX to Google Storage Bucket
Update: 3CX v16 now natively supports backing up to Google Cloud Storage
Automatic Google Cloud Snapshots
Using GoogleCloudPlatform/gcsfuse
Prerequesits:
- Set Storage API scope for Compute Engine to Full (requires VM shutdown)
Install gcsfuse
export GCSFUSE_REPO=gcsfuse-`lsb_release -c -s`
echo "deb http://packages.cloud.google.com/apt $GCSFUSE_REPO main" | sudo tee /etc/apt/sources.list.d/gcsfuse.list
curl https://packages.cloud.google.com/apt/doc/apt-key.gpg | sudo apt-key add -
sudo apt-get update
sudo apt-get install gcsfuse
Edit fuse.conf
sudo nano /etc/fuse.conf
Remove # from
# user_allow_other
Set up mount point for automatic mounting
sudo mkdir /mnt/gbucket
sudo nano /etc/fstab
Add to the end of the file:
999 = phonesystem user required for the 3CX app to have write permissions to the folder
bucketname /mnt/gbucket gcsfuse rw,allow_other,uid=999,gid=999,dir_mode=775,file_mode=775,nonempty
Move existing backups
If migrating from Google Drive you can download them from Google drive and then upload via the Google Cloud Console)
sudo mkdir /mnt/gbucket/Backups
sudo mv /var/lib/3cxpbx/Instance1/Data/Backups/* /mnt/gbucket/Backups/
sudo rm -R /var/lib/3cxpbx/Instance1/Data/Backups/
sudo ln -fs /mnt/gbucket/Backups /var/lib/3cxpbx/Instance1/Data/Backups
Unmount
sudo fusermount -u /mnt/gbucket
To Run manually
sudo gcsfuse -o rw,allow_other,nonempty --uid 999 --gid 999 --dir-mode 775 --file-mode 775 bucketname /mnt/gbucket
Test
Run a manual backup in 3CX and ensure it is created - if you run into I/O or permission errors you have either not set the correct uid / gid or you can try and experiment with different dir-mode / file-mode values. To find out the id of a given user run
id username