Simple Google Drive client for Linux.
This script uses rclone and inotify to monitor a local directory for changes and automatically copy them to your Google Drive. Directory structure/hierarchy is preserved in the copy and dotfiles are ignored. The script monitors for creations, moves/renames, and modifications in the configured local directory and propagates them to your Google Drive. Deleting files locally will not delete them on your Google Drive.
Moving files/directories within the monitored local directory will upload a new file/directory in the new location to Google Drive. Likewise, renaming files/directories within the monitored local directory will upload a new file/directory with the new name to Google Drive. The old file/directory will still be in your Google Drive, and you'll have to explicitly delete it if you no longer want it. This script will not delete anything from your Google Drive as-is.
- You'll need to have
rclone
installed, configured, and linked to your Google Drive. - You'll also need
inotify-wait
for monitoring local file changes andnotify-send
for notifications (although both might be installed already depending on your distro).
- Download
gdrive.sh
. - Open
gdrive.sh
in your favorite Text Editor. - Change
RCLONE_REMOTE_NAME
to whatever you named your Google Drive remote during rclone setup (if you forgot, you can runcat ~/.config/rclone/rclone.conf
, and it'll be in square brackets above the drive configuration). - Optionally change
GDRIVE_DIR
to point to the local directory where files will be monitored and copied from (defaults to~/Drive
and creates the directory if it doesn't already exist on script run).GDRIVE_DIR
is meant to be equivalent to your remote Google Drive's root directory. So, if you createsample.txt
inGDRIVE_DIR
, then you should seesample.txt
at the root of your Google Drive after upload. If you createBaseDir/NestedDir/sample.txt
inGDRIVE_DIR
, then you should see that same directory structure and file when you open up Google Drive. - Make script executable:
chmod +x gdrive.sh
. - Run script:
./gdrive.sh
. You'll get a notification each time a file is uploaded to Google Drive.
If there's any files/directories in your Google Drive that you want copied to GDRIVE_DIR
on your machine, you'll have to explicitly run an rclone copy
, since this script only copies changes one way (from your machine to Google Drive).
https://rclone.org/commands/rclone_copy/
I do this through a systemd user service.
mkdir -p ~/.config/systemd/user
cd ~/.config/systemd/user
touch gdrive.service
- Open
gdrive.service
in your favorite Text Editor. - Write the following (replacing the path to
gdrive.sh
)
[Unit]
Description=gdrive-linux systemd user service
[Service]
Type=simple
ExecStart=/bin/bash /path/to/gdrive.sh
[Install]
WantedBy=default.target
systemctl --user enable gdrive.service
reboot
Logs for the current boot can be viewed with journalctl -b --user -u gdrive.service
.