So I figured out a working solution and I thought I would share it. This is my first sort of "guide" so if I did something wrong or if it is not helpful to anyone I apologize! Still trying to figure out all the nuances...
- The first step is to create a cron-job backup of the config file for freenas. This is fairly easy to do and I followed cyberjock's post here: https://forums.freenas.org/index.php?threads/backup-config-file-every-night-automatically.8237
You will want to create a script. I called my backupconf.sh and I placed it in /usr/bin but you can put it wherever you like. Don't forget to chmod +x it!
My config backup is in my "Storage" pool, but you can also put this where ever you like. Mine was placed in /mnt/Storage/Data/ConfigBackup/
Code:cp /data/freenas-v1.db /mnt/Storage/Data/ConfigBackup/`date +%Y%m%d`_`cat /etc/version | cut -d'-' -f2`_`cat /etc/ve$
Set the cronjob to run as root and use
manually run it and make sure your backup appears in the correct path.Code:sh /usr/bin/backupconf.sh
- You will need to download the gdrive binaries. These can be found here: https://github.com/prasmussen/gdrive
Download the corresponding file. I used the x64 FreeBSD one.
- After you download the file, move it to /usr/local/bin
Code:sudo mv drive /usr/local/bin
I downloaded it onto a windows machine and put it on one of my CIFS shares. I think moved it via terminal. Also remember to chmod +x /usr/local/bin/drive afterwards!
- once this is done. You should be able to type "drive" into your terminal, and you should get some text in the terminal with a web URL link. Do not open this link yet (Although if you do it's okay). We just wanted to make sure that "drive" was working.
- Now that we confirmed the binary was installed, and your cron job is working. We need to add in the google drive uploading portion. For this we are going to edit /usr/bin/backupconf.sh again. Simply open it up and add:
Code:FILENAME="/mnt/Storage/Data/ConfigBackup/`date +%Y%m%d`_`cat /etc/version | cut -d'-' -f2`_`cat /etc/version | cut -$ drive upload --file $FILENAME
So your new file should look something like:
Code:cp /data/freenas-v1.db /mnt/Storage/Data/ConfigBackup/`date +%Y%m%d`_`cat /etc/version | cut -d'-' -f2`_`cat /etc/ve$ FILENAME="/mnt/Storage/Data/ConfigBackup/`date +%Y%m%d`_`cat /etc/version | cut -d'-' -f2`_`cat /etc/version | cut -$ drive upload --file $FILENAME
This just stores the filename that will be created when you move the config file into a variable, and then that variable is passed to the drive command.
- The first time you run this script, you should get a link in the terminal output. Now we are going to take this link and put it into a web browser. It will take you to a google page where you need to allow access. Simply click the "Allow" button.
- After this you will received an authentication code. Copy this code, and paste it back into the terminal. It should be asking for it.
- That should be it! If you check your google drive, you should have the file on the top level. I haven't quite figured out how to specifically choose a directory to upload to yet. Still working on that. I hope this wasn't too hard to follow. I will try to add pictures and better explanations with time permitting.