O365, SharePoint and OneDrive for Business - Backup to TrueNAS Scale?

Scott Anderson

Dabbler
Joined
Jun 2, 2021
Messages
18
Considering the strengths of TrueNAS, is there no formally supported mechanism to use TrueNAS as a target for backing up Microsoft O365 and SharePoint?

I'm not talking about hacking a solution together to backup my personal OneDrive, I mean using it to back up a Not-for-Profits O365 environment. Veema seems great but at £3600pa for a 200 user license...it's a bit much.
 

ragametal

Contributor
Joined
May 4, 2021
Messages
188
In the past, you were able to use "Cloud Sync" to backup to/from Microsoft O365.

In order to use "Cloud Sync" you will need to create a "Cloud Credential". When you are creating this credential, select the following:
  • Provider : "OneDrive"
  • Drive Account Type: "Business"
  • Drive ID : "EMPTY"
In my experience, if the "Drive ID" is left empty, then trueNAS will default to the Sharepoint associated with the user's account. If you are interested in backing up the user's assigned onedrive, then that is a bit more complicated as it requires you to find out the "Microsoft tenant id" for that user and put that number into the "Drive ID" field.

However, starting on TrueNAS Cobia, OneDrive has been removed as a provider of "Cloud Credentials". It seems the decision was made due to an incompatibility between the onedrive driver and the version of python included in Cobia.

The following is the thread discussing this issue if you are interested https://www.truenas.com/community/threads/onedrive-personal-cloudsync.112559/

Based on this, i believe this you cannot backup Microsoft O365 to the latest version of TrueNAS without "hacking" something up.
 
Last edited:

Cellobita

Contributor
Joined
Jul 15, 2011
Messages
107
Create a dataset (e.g., /mnt/Tank/Rclone) for
  • rclone (a standalone executable - download it from https://downloads.rclone.org/rclone-current-linux-amd64.zip and unzip),
  • its config file (generate one with /mnt/Tank/Rclone/rclone config --config=/mnt/Tank/Rclone/rclone.conf),
  • and a script (invoked with /mnt/Tank/Rclone/rclone --config=/mnt/Tank/Rclone/rclone.conf)
It'll work and be upgrade-safe (run it from a cron task). I am using this exact same method to do a daily backup of a customer's SharePoint site to TrueNAS, and it's working perfectly.

P.S.: my script wraps around this command
Code:
/mnt/Tank/Rclone/rclone sync SPOArq: /mnt/Tank/SPOArqBak \
 --config=/mnt/Tank/Rclone/rclone.conf \
 --create-empty-src-dirs \
 --ignore-checksum \
 --ignore-size \
 --metadata \
 --stats 0 \
 --human-readable
 --log-level NOTICE \
 --log-file $reportfile

SPOArq being the endpoint generated with the config command above; --ignore-checksum and --ignore-size are needed because SharePoint silently modifies Office files while copying to or from it (this is a known issue) - the script will fail with errors otherwise
 
Last edited:

ragametal

Contributor
Joined
May 4, 2021
Messages
188
@Cellobita . Thanks for the advisement.
I have so many questions about your solution now.
  1. What is the purpose of downloading Rclone yourself? I ask because TrueNAS already has Rclone installed in the system, which is accessible via the CLI and that version has OneDrive as a cloud provider.
  2. In your experience, is it better to download Rclone directly than to deploy it via their official docker container? The general consensus in this forum seems to be to avoid modifying the OS if possible. A docker container sounds to be more aligned with this mantra. (I'm not criticizing your solution, I'm honestly curious).
  3. could you share your script :tongue:?
 

Cellobita

Contributor
Joined
Jul 15, 2011
Messages
107
@Cellobita . Thanks for the advisement.
I have so many questions about your solution now.
  1. What is the purpose of downloading Rclone yourself? I ask because TrueNAS already has Rclone installed in the system, which is accessible via the CLI and that version has OneDrive as a cloud provider.
  2. In your experience, is it better to download Rclone directly than to deploy it via their official docker container? The general consensus in this forum seems to be to avoid modifying the OS if possible. A docker container sounds to be more aligned with this mantra. (I'm not criticizing your solution, I'm honestly curious).
  3. could you share your script :tongue:?

1. I prefer always running the last rclone version available; if you use the built-in one, you can't guarantee that.

2. I have never tried using docker. As the rclone executable is self-contained, I don't see the need for doing it this way, as opposed to having a dedicate dataset, but YMMV

3. Sure, this will get you started:

Code:
#!/bin/sh
# This script assumes a /mnt/Tank/Rclone dataset for both the script and the rclone exec
# The rclone.conf file can be generated with the following command
# /mnt/Tank/Rclone/rclone config --config=/mnt/Tank/Rclone/rclone.conf

reportfile=/mnt/Tank/Rclone/back_report.log

# The following line is optional, but allows rclone to update itself prior to executing the script; this could be risky
/mnt/Tank/Rclone/rclone selfupdate

/mnt/Tank/Rclone/rclone sync /mnt/Tank/[datasettobackup] [cloudendpoint]: \
 --config=/mnt/Tank/Rclone/rclone.conf \
 --create-empty-src-dirs \
 --ignore-checksum \
 --ignore-size \
 --metadata \
 --stats 0 \
 --log-level NOTICE \
 --log-file $reportfile

cat $reportfile | /usr/bin/mail -s "Daily SharePoint backup" "[your email address]"


Replace [datasettobackup] and [cloudendpoint] with the correct ones for your case, then save this file to the Rclone dataset, chmod +x the file to make it executable, and schedule a cron task for the script. The script will send you the sync result by mail, when run. That's it!
 
Last edited:
Top