This post will not go into how to backup your FreeNAS configs, I will make another post for that shortly.

My setup is like so, I backup my FN config hourly to /mnt/config-backups/backups/phxlp-stg01.devita.co and want to push that hourly to DigitalOcean's spaces.

I have a general bucket in spaces called "homelab" with backups folder, and inside of that folder I have a folder for each hostname which is putting data to the space.

/mnt/config-backups - backups/ - phxlp-stg01.devita.co/

on the bucket I mock a similar structure:

s3://homelab/ - backups/ - phxlp-stg01.devita.co/

Setup DigitalOcean Spaces Bucket

I wont go into much detail on this part as its fairly straight forward. At the time of writing this you need to be enrolled in the beta for spaces and have it provisioned on your account.!

Create the "space" or "bucket"

I named space/bucket "homelab"



Then create a space access key





Create the bucket's folder structure

Create a folder structure like above, inside of the bucket create a folder called backups and then inside of that create one for your hostname.

Install & Confgure s3cmd plugin in FreeNAS

First off, in the FreeNAS GUI Navigate to plugins and install the s3cmd plugin.

Once thats done, on the left side expand the jails tree menu and mount your backup pool storage to the s3cmd jail. I have a seperate pool entirely for my config backups at /mnt/config-backups . I am mounting that to /backups in the jail so my config looks like this:

Once thats done, open the s3cmd plugin's settings in the FreeNAS GUI and add in your relevant settings placing the access key and access secret in and click save.

Modify s3cmd config to use DigitalOcean's Spaces URLs

Now ssh into your FreeNAS server and run jxec s3cmd_1 to login to the s3cmd jail.

Note: your number might be different in FN, you can use jls to find the jail name and change accordingly.

In that s3cmd_1 jail, we need to install nano to edit the cfg file and then make some key changes to the .s3cfg to make it work with DigitalOcean's spaces.

By default s3cmd installs to /usr/pbi/s3cmd-amd64 .

pkg install nano; cd /usr/pbi/s3cmd-amd64; nano .s3cfg;

edit the follow three properties in /usr/pbi/s3cmd-amd64/.s3cfg to point to your relevant DO Spaces URL, in my case at the time of writing NYC3 was the only data center that had spaces enabled.

host_base = nyc3.digitaloceanspaces.com host_bucket = %(bucket)s.nyc3.digitaloceanspaces.com website_endpoint = http://%(bucket)s.nyc3.digitaloceanspaces.com/

save the file and exit.

Test It Out

Now you can run the s3cmd put <directory>/* s3://<bucket>/<folder>/ command to put the files to the bucket.

The exact full command to put the entire contents of /backups (/mnt/config-backups/backups on the FN box directly) to my homelab bucket is s3cmd put --progress --recursive /backups s3://homelab/

Set a cron task to run s3cmd automatically

in the FreeNAS s3cmd_1 jail edit the /var/run/s3run_script.sh and modify it as such:

I had to install the bash shell first to get this to work

pkg install bash

My /var/run/s3run_script.sh looks like this

#!/usr/local/bin/bash /usr/local/bin/s3cmd put --progress --recursive /backups s3://homelab/

root's crontab entry in s3cmd_1 jail looks like this

*/10 * * * * /usr/local/bin/bash /var/run/s3run_script.sh