Sync any Linux folder to Google drive using Rclone + systemd.
Source: Dev.to
Install rclone
sudo apt install rclone
Check version:
rclone version
Configure Google Drive
Run the configuration wizard:
rclone config
- Choose n) New remote and set the name to
gdrive. - Select the remote type
drive. - Accept the defaults for the following prompts:
- Client ID: press Enter
- Client Secret: press Enter
- Scope:
1) Full access - Use auto config: Yes (rclone will open a browser for you to log in and grant access)
- Configure as a Shared Drive?: No
- Keep this remote?: Yes
Verify the remote:
rclone lsd gdrive:
You should see your Drive folders.
Choose folders to auto‑sync
Example local folder:
/home/arunkrish/workspace
It will be uploaded to the remote path:
gdrive:workspace
Why NOT use sync?
rclone sync mirrors the source, so files deleted locally are also deleted from Google Drive—unsuitable for backups.
Instead, use rclone copy, which only uploads new or changed files and never deletes anything on the remote.
Create systemd auto‑upload services
Service unit
mkdir -p ~/.config/systemd/user
nano ~/.config/systemd/user/gdrive-workspace.service
Add the following content:
[Unit]
Description=Upload workspace to Google Drive
[Service]
Type=oneshot
ExecStart=/usr/bin/rclone copy /home/arunkrish/workspace gdrive:workspace --verbose --create-empty-src-dirs
Timer unit
nano ~/.config/systemd/user/gdrive-workspace.timer
Add the following content:
[Unit]
Description=Run workspace uploader every 5 minutes
[Timer]
OnBootSec=2min
OnUnitActiveSec=5min
[Install]
WantedBy=timers.target
Enable and start the timer
systemctl --user enable --now gdrive-workspace.timer
Confirm all timers
systemctl --user list-timers
You should see gdrive-workspace.timer in the list.
How Smart Auto‑Sync Works
- Internet OFF → rclone waits.
- Internet ON → rclone uploads new files.
- Files already uploaded are not uploaded again.
- Files deleted locally are not deleted on Drive.
This provides true cloud backup behavior.
Pause Syncing Anytime (Low Data Mode)
To pause the auto‑upload:
systemctl --user stop gdrive-workspace.timer
To resume:
systemctl --user start gdrive-workspace.timer
To disable permanently:
systemctl --user disable gdrive-*.timer
Manual Upload (Optional)
Force an immediate upload with:
rclone copy /home/arunkrish/workspace gdrive:workspace
Summary
Using rclone together with systemd gives you:
- Automatic folder uploads
- Low data usage
- No deletions on Drive (safe backups)
- Offline resilience
- Full control to pause/resume at any time
This setup is cleaner and more powerful than official sync clients.