{"id":842,"date":"2025-09-09T16:19:49","date_gmt":"2025-09-09T08:19:49","guid":{"rendered":"https:\/\/www.zhzxs.site\/?p=842"},"modified":"2026-05-21T18:58:46","modified_gmt":"2026-05-21T10:58:46","slug":"1757405977","status":"publish","type":"post","link":"https:\/\/www.zhzxs.site\/index.php\/2025\/09\/09\/1757405977\/","title":{"rendered":"\u4f7f\u7528 rclone \u548c Crontab \u6bcf\u5929\u5907\u4efd\u670d\u52a1\u5668\u6587\u4ef6\u5939\u5230 Google Drive"},"content":{"rendered":"\n<p>\u672c\u6587\u6f14\u793a\u5982\u4f55\u4f7f\u7528 <strong>rclone<\/strong> \u5c06\u670d\u52a1\u5668\u4e0a\u7684\u67d0\u4e2a\u6587\u4ef6\u5939\u6bcf\u5929\u5907\u4efd\u5230 Google Drive\uff0c\u5e76\u901a\u8fc7 <strong>crontab<\/strong> \u81ea\u52a8\u5316\u6267\u884c\u3002<\/p>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<h2 class=\"wp-block-heading\">\u6b65\u9aa4 1\ufe0f\u20e3\uff1a\u5728 Windows \u4e0a\u914d\u7f6e rclone<\/h2>\n\n\n\n<ol class=\"wp-block-list\">\n<li>\u4e0b\u8f7d\u5e76\u89e3\u538b <a href=\"https:\/\/rclone.org\/downloads\/\">rclone<\/a> \u5230 Windows \u7535\u8111\u3002<\/li>\n\n\n\n<li>\u6253\u5f00 CMD \u6216 PowerShell\uff0c\u8fd0\u884c\uff1a<\/li>\n<\/ol>\n\n\n\n<pre class=\"wp-block-code\"><code>rclone config\n<\/code><\/pre>\n\n\n\n<ol start=\"3\" class=\"wp-block-list\">\n<li>\u65b0\u5efa remote\uff0c\u914d\u7f6e Google Drive\uff0c\u4f8b\u5982\u547d\u540d\u4e3a <code>gdriver<\/code>\uff1a\n<ul class=\"wp-block-list\">\n<li>\u9009\u62e9\u81ea\u52a8\u8ba4\u8bc1\uff08Yes\uff09\uff0c\u6d4f\u89c8\u5668\u767b\u5f55 Google<\/li>\n\n\n\n<li>\u5b8c\u6210\u540e rclone \u4f1a\u751f\u6210\u914d\u7f6e\u6587\u4ef6 <code>rclone.conf<\/code><\/li>\n<\/ul>\n<\/li>\n\n\n\n<li>\u914d\u7f6e\u6587\u4ef6\u9ed8\u8ba4\u4f4d\u7f6e\uff1a<\/li>\n<\/ol>\n\n\n\n<pre class=\"wp-block-code\"><code>C:\\Users\\&lt;\u7528\u6237\u540d&gt;\\.config\\rclone\\rclone.conf\n<\/code><\/pre>\n\n\n\n<p>\u5982\u679c\u627e\u4e0d\u5230\uff0c\u53ef\u4ee5\u4f7f\u7528\u547d\u4ee4\u67e5\u770b\uff1a<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>rclone config file\n<\/code><\/pre>\n\n\n\n<blockquote class=\"wp-block-quote is-layout-flow wp-block-quote-is-layout-flow\">\n<p>\u26a0\ufe0f \u6ce8\u610f\uff1a\u4e00\u5b9a\u8981\u5728 Windows \u4e0a\u5b8c\u6210 Google Drive \u6388\u6743\u3002<\/p>\n<\/blockquote>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<h2 class=\"wp-block-heading\">\u6b65\u9aa4 2\ufe0f\u20e3\uff1a\u5c06\u914d\u7f6e\u6587\u4ef6\u62f7\u8d1d\u5230\u670d\u52a1\u5668<\/h2>\n\n\n\n<ol class=\"wp-block-list\">\n<li>\u5728\u670d\u52a1\u5668\u4e0a\u521b\u5efa rclone \u914d\u7f6e\u76ee\u5f55\uff08\u5982\u679c\u4e0d\u5b58\u5728\uff09\uff1a<\/li>\n<\/ol>\n\n\n\n<pre class=\"wp-block-code\"><code>mkdir -p ~\/.config\/rclone\n<\/code><\/pre>\n\n\n\n<ol start=\"2\" class=\"wp-block-list\">\n<li>\u4e0a\u4f20 Windows \u4e0a\u7684 <code>rclone.conf<\/code> \u6587\u4ef6\u5230\u670d\u52a1\u5668\uff1a<\/li>\n<\/ol>\n\n\n\n<pre class=\"wp-block-code\"><code>scp C:\\Users\\&lt;\u7528\u6237\u540d&gt;\\.config\\rclone\\rclone.conf ubuntu@\u670d\u52a1\u5668IP:~\/.config\/rclone\/rclone.conf\n<\/code><\/pre>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<h2 class=\"wp-block-heading\">\u6b65\u9aa4 3\ufe0f\u20e3\uff1a\u5728\u670d\u52a1\u5668\u4e0a\u6d4b\u8bd5 rclone \u914d\u7f6e<\/h2>\n\n\n\n<p>\u8fd0\u884c\uff1a<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>rclone ls gdriver:\n<\/code><\/pre>\n\n\n\n<ul class=\"wp-block-list\">\n<li>\u5982\u679c\u80fd\u5217\u51fa Google Drive \u6587\u4ef6\uff0c\u8bf4\u660e\u914d\u7f6e\u6210\u529f \u2705<\/li>\n<\/ul>\n\n\n\n<p>\u4e4b\u540e\u5c31\u53ef\u4ee5\u4f7f\u7528 rclone \u8fdb\u884c\u6587\u4ef6\u5907\u4efd\u3002<\/p>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<h2 class=\"wp-block-heading\">\u6b65\u9aa4 4\ufe0f\u20e3\uff1a\u521b\u5efa\u5907\u4efd\u811a\u672c<\/h2>\n\n\n\n<p>\u5728\u670d\u52a1\u5668\u4e0a\u65b0\u5efa\u811a\u672c\uff0c\u4f8b\u5982\uff1a<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>vim ~\/sh_scripts\/rclone_Bitwardon.sh\n<\/code><\/pre>\n\n\n\n<p>\u5c06\u4e0b\u9762\u5185\u5bb9\u7c98\u8d34\u8fdb\u53bb\uff1a<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>#!\/bin\/bash\n\n# \u5b9a\u4e49\u53d8\u91cf\nSRC_DIR=\"\/home\/ubuntu\/dockers\/bitwarden\/vw-data\"  # \u9700\u8981\u5907\u4efd\u7684\u76ee\u5f55\nDEST_DIR=\"gdriver:\/Bitwardon\"                     # Google \u4e91\u76d8\u4e0a\u7684\u5907\u4efd\u76ee\u5f55\nBACKUP_NAME=\"Bitwardon_backup_$(date +'%Y%m%d%H%M').tar.gz\" # \u5907\u4efd\u6587\u4ef6\u540d\nBACKUP_PATH=\"\/tmp\/$BACKUP_NAME\"                  # \u672c\u5730\u4e34\u65f6\u5b58\u50a8\u8def\u5f84\n\n# 1. \u538b\u7f29\u6587\u4ef6\nsudo tar -czf \"$BACKUP_PATH\" \"$SRC_DIR\"\n\n# 2. \u4e0a\u4f20\u5230 Google \u4e91\u76d8\nrclone copy \"$BACKUP_PATH\" \"$DEST_DIR\"\n\n# 3. \u5220\u9664\u672c\u5730\u5907\u4efd\nsudo rm -f \"$BACKUP_PATH\"\n\n# 4. \u53ea\u4fdd\u7559 Google \u4e91\u76d8\u4e0a\u6700\u65b0\u7684 10 \u4e2a\u5907\u4efd\nrclone ls \"$DEST_DIR\" --max-depth 1 | sort -k2 | head -n -10 | awk '{print $2}' | while read -r file; do\n    rclone delete \"$DEST_DIR\/$file\"\ndone\n\necho \"Backup completed: $BACKUP_NAME\"\n<\/code><\/pre>\n\n\n\n<p>\u4fdd\u5b58\u5e76\u8d4b\u4e88\u6267\u884c\u6743\u9650\uff1a<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>chmod +x ~\/sh_scripts\/rclone_Bitwardon.sh\n<\/code><\/pre>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<h2 class=\"wp-block-heading\">\u6b65\u9aa4 5\ufe0f\u20e3\uff1a\u4f7f\u7528 crontab \u81ea\u52a8\u6bcf\u5929\u6267\u884c<\/h2>\n\n\n\n<ol class=\"wp-block-list\">\n<li>\u7f16\u8f91 crontab\uff1a<\/li>\n<\/ol>\n\n\n\n<pre class=\"wp-block-code\"><code>EDITOR=vim crontab -e\n<\/code><\/pre>\n\n\n\n<ol start=\"2\" class=\"wp-block-list\">\n<li>\u6dfb\u52a0\u4ee5\u4e0b\u4efb\u52a1\uff0c\u6bcf\u5929 12:00 \u81ea\u52a8\u6267\u884c\u5907\u4efd\u811a\u672c\uff1a<\/li>\n<\/ol>\n\n\n\n<pre class=\"wp-block-code\"><code>0 12 * * * \/home\/ubuntu\/sh_scripts\/rclone_Bitwardon.sh\n<\/code><\/pre>\n\n\n\n<ol start=\"3\" class=\"wp-block-list\">\n<li>\u4fdd\u5b58\u9000\u51fa\uff0cCrontab \u4f1a\u81ea\u52a8\u751f\u6548\u3002<\/li>\n<\/ol>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<h2 class=\"wp-block-heading\">\u6ce8\u610f\u4e8b\u9879<\/h2>\n\n\n\n<ul class=\"wp-block-list\">\n<li>\u786e\u8ba4 <code>SRC_DIR<\/code> \u8def\u5f84\u6b63\u786e\uff0c\u5426\u5219 tar \u4f1a\u62a5\u9519 <code>Cannot stat: No such file or directory<\/code><\/li>\n\n\n\n<li>\u5982\u679c\u4f7f\u7528\u9ed8\u8ba4 rclone <code>client_id<\/code>\uff0cGoogle Drive \u6bcf\u5206\u949f\u8bf7\u6c42\u6709\u914d\u989d\u9650\u5236\uff0c\u5bb9\u6613\u62a5\u9519 <code>RATE_LIMIT_EXCEEDED<\/code>\n<ul class=\"wp-block-list\">\n<li>\u5efa\u8bae\u6ce8\u518c\u81ea\u5df1\u7684 Google Cloud \u9879\u76ee\uff0c\u751f\u6210 <code>client_id<\/code> \u548c <code>client_secret<\/code><\/li>\n<\/ul>\n<\/li>\n\n\n\n<li>\u672c\u811a\u672c\u4f1a\u5728 Google Drive \u76ee\u5f55\u53ea\u4fdd\u7559\u6700\u65b0\u7684 10 \u4e2a\u5907\u4efd\uff0c\u907f\u514d\u5360\u7528\u8fc7\u591a\u7a7a\u95f4<\/li>\n<\/ul>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<p>\u2705 \u5b8c\u6210\u4ee5\u4e0a\u6b65\u9aa4\u540e\uff0c\u4f60\u7684\u670d\u52a1\u5668\u5c31\u53ef\u4ee5\u6bcf\u5929\u81ea\u52a8\u5907\u4efd\u6307\u5b9a\u6587\u4ef6\u5939\u5230 Google Drive\u3002<\/p>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n","protected":false},"excerpt":{"rendered":"<p>\u672c\u6587\u6f14\u793a\u5982\u4f55\u4f7f\u7528 rclone \u5c06\u670d\u52a1\u5668\u4e0a\u7684\u67d0\u4e2a\u6587\u4ef6\u5939\u6bcf\u5929\u5907\u4efd\u5230 Google Drive\uff0c\u5e76\u901a\u8fc7 cront [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":101,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[2],"tags":[160,162,161],"class_list":["post-842","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-2","tag-rcxlone","tag-162","tag-161"],"_links":{"self":[{"href":"https:\/\/www.zhzxs.site\/index.php\/wp-json\/wp\/v2\/posts\/842","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.zhzxs.site\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.zhzxs.site\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.zhzxs.site\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.zhzxs.site\/index.php\/wp-json\/wp\/v2\/comments?post=842"}],"version-history":[{"count":4,"href":"https:\/\/www.zhzxs.site\/index.php\/wp-json\/wp\/v2\/posts\/842\/revisions"}],"predecessor-version":[{"id":871,"href":"https:\/\/www.zhzxs.site\/index.php\/wp-json\/wp\/v2\/posts\/842\/revisions\/871"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.zhzxs.site\/index.php\/wp-json\/wp\/v2\/media\/101"}],"wp:attachment":[{"href":"https:\/\/www.zhzxs.site\/index.php\/wp-json\/wp\/v2\/media?parent=842"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.zhzxs.site\/index.php\/wp-json\/wp\/v2\/categories?post=842"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.zhzxs.site\/index.php\/wp-json\/wp\/v2\/tags?post=842"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}