Please add the option for backup to ftp/smb/s3/cloud/external storage etc.
Thank you.
Please add the option for backup to ftp/smb/s3/cloud/external storage etc.
Thank you.
In the meantime you could do it with rclone and a shell script.
Some hints:
rclone config
rclone copy /var/lib/vitalpbx/static/backup/xxxxxxx RemoteName:/BackupFolderRemote
rclone delete RemoteName:/BackupFolderRemote --min-age 30d --dry-run
–min-age 30d are files that are older then 30 days
–dry-run is for testing which files would be deleted
rclone can encrypt too.
VitalPBX Task Manager Addon will help you execute your script easily.
I’m trying to setup Rclone to do offsite backup from VitalPBX backup files, using
sudo rclone copy /var/lib/vitalpbx/backup/ backup:
running this in the command line works, running the file with the command via
bash /var/lib/vitalpbx/scripts/filename
works.
but it’s not working when scheduling it via VitalPBX task scheduler.
You probably have to specify to full path to the command as it’s running under the cron user.
Was a combination of two-issue
The script file name was two words and it only used one.
Also, the script file didn’t have the write permissions.
Now it works!
Thanks, @mo10 for the idea.
I would say its pretty essential to have a vitalpbx cloud backup and hopefully this feature is added soon.
But I wanted to get this going now - not later and I wanted to use the Telnyx S3 compatible storage bucket as they are really cost effective!
So this is how I did it…
In Telnyx - Setup a S3 Compatible Storage Bucket and get an API Key (save the key to text file)
SSH into VitalPBX server
Install rclone:
sudo -v ; curl https://rclone.org/install.sh | sudo bash
Setup rclone:
rclone config
Go through setup with the following options:
n
S3Telnyx (The name of this backup connection - note it down if you change it as its required later)
4 (Amazon S3 Complaint) NB: The 4 might change in the future
32 (Any other S3 compatible provider) NB: The 32 might change in the future too
1 (Enter AWS credentials in the next step)
access_key_id = PASTE TELNYX API KEY
secret_access_key = NOT REQUIRED BUT ENTER A FEW RANDOM A to Z ONLY LETTERS
1 (Will use v4 signatures and an empty region)
endpoints > PASTE us-east-1.telnyxstorage.com IF USING us-east-1 or look up others
location_constraint > EMPTY HIT ENTER
1 Owner gets FULL_CONTROL. No one else has access rights (default).
No (Advanced)
y (if all correct say yes)
q (quit)
Now test:
rclone lsd S3Telnyx:
You should see a list of buckets if its working.
Now test the bucket: (replace mybucketname with your actual bucket name!)
rclone ls S3Telnyx:mybucketname
You should see a list of files or if the bucket is empty then nothing - but not an error.
Now create a .sh file: (Install nano if missing)
nano backup-vpbx.sh
Enter the following into the .sh text file editor: (note this script includes a limit of 1 file transfer at a time and bandwidth limit of 5MBps to avoid saturating available line capacity - adjust to suit your environment)
rclone copy -Pv --transfers=1 --bwlimit=5M --ignore-existing /var/lib/vitalpbx/backup/ S3Telnyx:mybucketname/backup/
rclone delete S3Telnyx:mybucketname --min-age 30d
Now: Save and Exit the nano editor (Alt x - Save - Exit)
Important *** the script includes the ability to delete files older than 30 days - DO NOT RUN inside the wrong bucket or you will loose other files.
Also don’t forget to change mybucketname to your actual bucket name.
Test run:
sh backup-vpbx.sh
It should run until the files are uploaded then exit.
Possible issues:
You may need to chmod if adding to cron. (Executable and/or Writable)
chmod +x backup-vpbx.sh
Now can somebody explain how to get this into the CRONJOBS of VitalPBX debian as I am stuck at getting this to execute nightly at 3am.
Did you try the vitalPbx Task Manager Addon yet?
Otherwise: crontab -e
I was a bit worried when I ran the crontrab -e as it spawned a new root crontab and wasn’t sure if there would be any conflicts with vpbx cron.
However I didn’t spot the Task Manager because I looked up “cron” in the web interface thinking that was all there was too it. It looks like the Task Manager should work.
Thanks!
UPDATE
For anyone else wanting to do this:
SSH in and copy/mv the backup-vpbx.sh to the folder /var/lib/vitalpbx/scripts/
Then make the .sh executable otherwise you will get a Permission Denied error when the cron runs.
chmod +x backup-vpbx.sh
Then in the web interface - use the search function to find these.
“Cron Profiles” - Make a Daily task for say 3am - Save and Refresh Page. (Also check you have the built in local backup function working too)
“Task Manager” - Select the Script from the drop down and choose the pre-created 3am cron profile. - Save.
Extra TIP: If you modify an existing Cron Profile time on VPBX and Save - you need to go into the Task manager and re-save the existing Cron task otherwise it doesn’t seem to execute at the right time.