Skip to content

Instantly share code, notes, and snippets.

@Generator
Last active October 10, 2017 22:47
Show Gist options
  • Save Generator/051adaa3904a1843628e105ad0160a64 to your computer and use it in GitHub Desktop.
Save Generator/051adaa3904a1843628e105ad0160a64 to your computer and use it in GitHub Desktop.
Grive autosync with inotify
#!/bin/bash
# Google Drive Grive script that syncs your Google Drive folder on change
# This functionality is currently missing in Grive and there are still no
# official Google Drive app for Linux coming from Google.
#
# This script will only detect local changes and trigger a sync. Remote
# changes will go undetected and are probably still best sync on a periodic
# basis via cron.
#
# Kudos to Nestal Wan for writing the excellent Grive software
# Also thanks to Google for lending some free disk space to me
#
# Peter Österberg, 2012
GRIVE_COMMAND=grive # Path to your grive binary, change to match your system
GDRIVE_PATH=~/GDrive # Path to the folder that you want to be synced
GDRIVE_LOG_PATH=/tmp/grive.log # Path to log file
TIMEOUT=300 # Timeout time in seconds, for periodic syncs. Nicely pointed out by ivanmacx
while true
do
inotifywait -t $TIMEOUT -e modify -e move -e create -e delete -r $GDRIVE_PATH
$GRIVE_COMMAND -l $GDRIVE_LOG_PATH -p $GDRIVE_PATH $GRIVE_OPTIONS --ignore '^FOOBAR/STUFF/*'
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment