text 使用rclone为Linux自动执行Google Drive同步

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了text 使用rclone为Linux自动执行Google Drive同步相关的知识,希望对你有一定的参考价值。

Script that will trigger a local to remote sync when any changes below your local Google Drive folder occur - but at max. every 10 minutes - and a remote to local sync every x (e.g. 30 minutes) via a cron job.

0. Install rclone and configure it for Google Drive
1. Create files listed below
2. Configure rclone_watch_local.sh to be run on startup (e.g. using a systemd service unit)
3. Add a cron job that runs rclone_remote2local.sh every x (e.g. 30) minutes

----------------------
rclone_local2remote.sh
----------------------
!/bin/bash

GDRIVE_DIR=/media/myuser/HDD/Google\ Drive

echo '[rclone] Syncing local -> remote.'

if [ -d "$GDRIVE_DIR" ]; then
	if ! ps ax | grep -v grep | grep "rclone sync" > /dev/null; then
		rclone sync "$GDRIVE_DIR" drive:/ && echo 'Finished local -> remote sync.'
	else
		echo '[rclone] A sync is already running.'
	fi
fi

----------------------
rclone_remote2local.sh
----------------------
!/bin/bash

GDRIVE_DIR=/media/myuser/HDD/Google\ Drive

echo '[rclone] Syncing remote -> local.'

if [ -d "$GDRIVE_DIR" ]; then
	if ! ps ax | grep -v grep | grep "rclone sync" > /dev/null; then
		rclone sync drive:/ "$GDRIVE_DIR" && echo '[rclone] Finished remote -> local sync.'
	else
		echo '[rclone] A sync is already running.'
	fi
fi

---------------------
rclone_watch_local.sh
---------------------
!/bin/bash

GDRIVE_DIR=/media/myuser/HDD/Google\ Drive

echo '[rclone] Watching locally.'

if [ -d "$GDRIVE_DIR" ]; then
	while true; do
		# sync at max every 10 minutes
		inotifywait -r "$GDRIVE_DIR" && bash /home/myuser/scripts/rclone_local2remote.sh && sleep 10m 
	done
fi

以上是关于text 使用rclone为Linux自动执行Google Drive同步的主要内容,如果未能解决你的问题,请参考以下文章

技术方案:Go 实现的存储服务器,文件系统,Key-Value 存储(特别是Rclone)

Python rclone检查两个文件夹的差异

php Opencart - 爬过数据库查找使用的图像/ pdf,并将它们输出为简单的文本列表。 CP / Rclone / PHP可以使用此列表进行中继

如何使用rclone从AWS S3迁移到IBM COS - part 2 - 同步腾讯云对象存储

使用电报机器人在 Heroku 上的 docker 中安装 Rclone [帮助]

使用go命令可以定位到文件头和文件末