Home > Enterprise >  Automatic Syncing between two Google Drive Shared Drives
Automatic Syncing between two Google Drive Shared Drives

Time:12-20

Question: I have two Google Shared Drives (Team Drives), let's say Movies and MoviesBackup. I need to backup whatever I upload to Movies into MoviesBackup. For this, I need an unidirectional sync from Movies to MoviesBackup, once daily.

What I have tried: I know of of Rclone, and have used its Command Line Interface to sync between two Shared Drives. Maybe if Rclone can be used from Google AppScript, I would set a daily trigger. But I seem to find no way to do so.

Any other solutions that work will be appreciated.

CodePudding user response:

Although I'm not sure whether this is the direct solution of your issue, in your situation, how about the following sample script? This sample scripts uses a Google Apps Script library. Ref

When this library is used, a source folder can be copied to the specific destination folder. And, when the files in the source folder are updated, the updated files are copied to the destination folder as the overwrite.

Usage:

1. Install library.

Please install the library to your Google Apps Script project. The method of installing it can be seen at here.

2. Sample script.

Please copy and paste the following script to the script editor of your Google Apps Script project. And save it. And, in this library, Drive API is used. So please enable Drive API at Advanced Google services.

And, please set the source and destination folder IDs to the following object.

function myFunction() {
  const object = {
    sourceFolderId: "###", // Please set the source folder ID.
    destinationFolderId: "###", // Please set the destination folder ID.
    overwrite: true,
  };
  const res = CopyFolder.copyAllFilesFolders(object);
  console.log(res);
}

Note:

  • When this script is run for the 1st time, all files are copied. And, after the script is run as 2 times, only the updated files are copied.

Reference:

  • Related