google drive and backup

New Contributor

is there any script and setting in Jamf pro that I can configure all endpoints and users for getting automatic backup on their google drive space for specific folders like Documents etc...



Contributor III

Would love to see this as an MDM-level setting like "enable cloud backup" then you could set your cloud drive service / info so that once the binary is installed and the user authenticated it would back up the desired folders automagically...

Contributor III

There's a script in the end HERE. Is that what you're looking for? You might need to do some tweaking.

New Contributor

The only way i've seen to deploy the fully synced folders was to move the documents to the root Google Drive folder, then create symlinks to replace the Desktop folder. It's error prone, and confuses the hell out of users so I wouldn't recommend.

I've tweaked the script that YanW linked to, to work with the latest paths that Google Drive uses. It doesn't configure google drive to sync the desktop and documents folder, but instead copies the folders to the Google Drive path so that they upload to the cloud.

Have Jamf run this policy on a periodic basic to create new backups, and make a script to clean out the older backups once they exceed your retention period.


# User backup script.
# Originally by: Joseph Jenkins
# Version 1.0 - 20170629, Joseph Jenkins
# Version 2.0 - 20191222, Joseph Jenkins
# Version 3.0 - 20221222, Forseti

# Variables for use
HNAME=$(hostname -s)
USER=$(/bin/echo "show State:/Users/ConsoleUser" | /usr/sbin/scutil | /usr/bin/awk '/Name :/&&!/loginwindow/{print $3}')
FOLDER=$(ls /Users/$USER/Library/CloudStorage | grep GoogleDrive)
VOLBKUPFLDR="/Users/$USER/Library/CloudStorage/$FOLDER/My Drive/Backups"
DATE=$(date "+%Y%m%d")

# Check to see if the backup folder exists. If not, create a backup folder with the device name and today's date
if [[ -d "$VOLBKUPFLDR/$HNAME-Backup-$DATE" ]]
    echo "$HNAME-Backup-$DATE exists. Beginning backup operation..."
    mkdir -p "$VOLBKUPFLDR/$HNAME-Backup-$DATE/"

# Now backup folders to Google Drive. By default, only Desktopa and Documents are backed up, but other paths may be added.
# Including the jamf script variables for script execution that are commented out, but can be used withi paths filled out in the script webform.
#"$RSYNC" -a -v "$4" "$VOLBKUPFLDR/$HNAME-Backup-$DATE"
#"$RSYNC" -a -v "$5" "$VOLBKUPFLDR/$HNAME-Backup-$DATE"
#"$RSYNC" -a -v "$6" "$VOLBKUPFLDR/$HNAME-Backup-$DATE"
#"$RSYNC" -a -v "$7" "$VOLBKUPFLDR/$HNAME-Backup-$DATE"
#"$RSYNC" -a -v "$8" "$VOLBKUPFLDR/$HNAME-Backup-$DATE"
#"$RSYNC" -a -v "$9" "$VOLBKUPFLDR/$HNAME-Backup-$DATE"