Uğur AKÇIL
UBUNTU/LINUX GOOGLE DRIVE SYNCHRONIZATION SCRIPT
This script uses rclone
and inotifywait
to synchronize specified folders between a local Ubuntu 22.04 system and Google Drive. It performs an initial sync and then monitors the folders for changes, synchronizing any changes with Google Drive in real-time.
- Ubuntu 22.04
rclone
installed and configuredinotify-tools
installed
Follow the official rclone installation guide to install rclone.
Run the following command to configure rclone for Google Drive:
rclone config
Follow the prompts to set up a new remote named gdrive (or any name you prefer).
If you are worried about making a mistake, you can search in detail on the internet for how to configure Google Drive with rclone.
Clone this repository to your local machine:
git clone https://github.com/ugurakcil/ubuntu-gdrive-sync.git
cd ubuntu-gdrive-sync
Edit the script gdrive_sync.sh with your preferred text editor and update the following variables:
USER: Your Ubuntu username GROUP: Your Ubuntu group REMOTE: Your rclone remote name (default is gdrive) LOCAL_DIR: The local directory where you want the Google Drive folders to be synchronized FOLDERS: The names of the folders you want to synchronize
Make the script executable with the following command:
chmod +x gdrive.sh
and try it
./gdrive.sh
To ensure the script runs continuously, even after rebooting your system, you can set it up as a systemd service.
sudo nano /etc/systemd/system/gdrive_sync.service
Add the following content to the file:
[Unit]
Description=Google Drive Synchronization Service
After=network.target
[Service]
User=your_username
Group=your_group
ExecStart=/path/to/your/script/gdrive_sync.sh
Restart=always
[Install]
WantedBy=multi-user.target
Enable the service to start on boot and start the service immediately:
sudo systemctl daemon-reload
sudo systemctl enable gdrive_sync.service
sudo systemctl start gdrive_sync.service
sudo systemctl status gdrive_sync.service