Shell script that copies to OneDrive

I'm trying to create a shell script on mac os that does copy a certain folder from the Filemaker backup-directory to a directory in OneDrive and run it on certain moments from within Filemaker Server
The script does work from within Filemaker Server when the destination is NOT OneDrive but a directory somewhere on the same Mac
The script does work when I run it form the Terminal, even to the OneDrive directory.
But it does not work from Filemaker Server to the OneDrive directory.

The OneDrive directory has permissions 770.

The Script is the simplicity itself: just 1 line, a cp-command but as it works from with the Terminal the cause is not the script.

What do I forget? Or is it impossible to save a backup file to a remote location?

Perhaps the utility "ExpanDrive" could help you? ExpanDrive maps drives or volumes (mac/pc) so you can access them like any other drive making file operations much simpler in many cases.

Sounds like permission settings. Can you run it with sudo?

1 Like

Not an answer to your exact question, but we’ve been using the AWS CLI to copy local files to AWS S3 Storage for a few years from Windows and Macs using a system script run by FileMaker Server. It’s run flawlessly and there are great tools like Transmit (Macs) and S3 Browser (Windows) to access the files.

The key thing about these type of scripts is first, do they run successfully when executed directly in Terminal on the Mac, or when double clicked in Windows, which you’ve confirmed you script does.

Therefore, look at the ‘Run as’ options in the FileMaker Server script, which has always been the problem (and solution) when we’ve had the same issue as it appears you have.


It’s late here, but just checked my setup notes before heading to bed, these may be of help:

If the shell script works:
To check it is executable via the default fmserver account, run:
sudo -u fmserver ./ and enter the Mac admin password when prompted

If all runs OK, then this can be run from a FileMaker Server schedule

Create a FileMaker Schedule for a System script
Point to the new script
Leave the default account to run
Run the script and check the Macintosh HD/Library/FileMaker Server/Logs/Event.Log in Console - check the script runs successfully before continuing

If there is a problem running the script, add the following to the /etc/sudoers file:
In Terminal run:
copy and paste the result for use below
sudo visudo and enter the Mac admin password when prompted
Use the arrow keys to navigate down until the line after:
# User privilege specification
root ALL=(ALL) ALL
%admin ALL=(ALL) ALL
In the line below the above:
press the 'A' key to insert text
Host_Alias FMSHOST = hostname
replace 'hostname' with the result from entering 'hostname' at the beginning above
Create a new line (in the normal way) and enter:
Defaults:fmserver targetpw, timestamp_timeout=0, passwd_tries=1
Create another new line and enter:
fmserver FMSHOST = (ALL) /Library/FileMaker\ Server/Data/Scripts/*, /bin/kill
Press the 'ESC' escape key to finish editing the file
Press the colon key and type wq (:wq) then the Enter/Return key to save the changes and to exit visudo (vi)
vi is used rather than other Terminal based text editors as it confirms proper syntax prior to saving the file.

Maybe an issue similar to the one happening with cron?

"In your case you have to add cron as "parent" app to the user's Security & Privacy > Privacy > Full Disk Access apps/execs."

1 Like

Inside the FileMaker server folder, you can find console.log and error.log files that will show you standard error and standard out for any shell scripts run from within FMS.

You should be able to see errors there, or you can add logging to your script file with echo commands etc.

Edit: correction, the files are located in /Library/FileMaker Server/Logs and are named stdout and stderr and although they don't have filename extensions, they are text files and you can manually open them in the


Thanks for all your comments but nothing works. What worked with Dropbox seems impossible with OneDrive. I guess the people at Microsoft make it impossible.
I've spend enough time with this, I will find another solution.

Three options below.

1. If you try the idea I suggested, namely, ExpanDrive, you can create a local drive "mapping" of your OneDrive folder (personal or business type). At that point, you can do a regular copy using whatever shell method or other you want.

Here are the connections supported by ExpanDrive.


2. You could also use the MS API:

Copy a file or folder - OneDrive API - OneDrive dev center | Microsoft Docs


3. You could also use Zapier which has built-in connectors to OneDrive and the free FileMaker connector for FMS. Zapier is incredible!

OneDrive Integrations | Connect Your Apps with Zapier

I'm sure one of (it not all of) these options will work.

Hi, For option 2, you could also check the demo file from Soliant Consulting.

1 Like