I’ve managed to get my backup to Backblaze B2 storage and I thought I would share it here…
Shamelessly edited the script found over at autoize > original one found here, which is intended for Nextcloud.
Made some adjustments and got it working for Mailinabox.
#!/bin/sh Path="/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin" # EDITED by Mellow for use with Mailinabox # Originally a NextCloud to BackBlaze B2 Backup Script # Original Author: Autoize (autoize.com) # This script creates an incremental backup of your Mailinabox instance at BackBlaze's off-site location. # BackBlaze B2 is an object storage service that is much less expensive than using Amazon S3 for the same purpose, with similar versioning and lifecycle management features. # Uploads are free, and storage costs only $0.005/GB/month compared to S3's $0.022/GB/month. # Requirements # - BackBlaze B2 account (10 GB Free) - Create one at https://www.backblaze.com/b2/sign-up.html # - BackBlaze B2 CLI installed from PyPI - sudo pip3 install b2 # Instructions # 1. Create a bucket and obtain your Account ID and Application Key from your B2 account. # 2. Authenticate your CLI using the b2 authorize_account command. # 4. Save this script to a safe directory such as /srv/backupToB2.sh and make it executable with the following command. # sudo chmod +x backupToB2.sh # 5. This script must be run as root. To run a backup now: # sudo ./backupToB2.sh # 6. Set up a cron job to run this backup on a predefined schedule (optional). # sudo crontab -u root -e # Add the following line to the crontab to conduct a weekly backup every Saturday at 2:00am. # 0 2 * * sat /srv/backupToB2.sh > /srv/backupToB2.log 2>&1 # Save, quit and check that the crontab has been installed using the following command. # sudo crontab -u root -l # Name of BackBlaze B2 Bucket b2_bucket='yourbucketname' # Path to box backupdata directory data_dir='/home/user-data/backup/encrypted' # Check if running as root if [ "$(id -u)" != "0" ]; then echo "This script must be run as root" 1>&2 exit 1 fi echo 'Started' date +'%a %b %e %H:%M:%S %Z %Y' # Sync data to B2 b2 sync $data_dir b2://$b2_bucket$data_dir date +'%a %b %e %H:%M:%S %Z %Y' echo 'Finished'