-1

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.

Tanaike
  • 181,128
  • 11
  • 97
  • 165
  • Hello everyone! Tell me if this question is not fit for stackoverflow. If it isn't, please tell where to post it. – Asmit Karmakar Dec 15 '21 at 04:31
  • I think that Google Apps Script can copy the files from the shared Drive "A" to the shared Drive "B". But in your situation, can I ask you about the maximum file size and the number of files you want to backup? Because GAS has the execution time. When the file size is large and the number of files is large, the process might not be able to be done by one script run. I'm worried about this. And, in your backup process, all files are copied? For example, do you copy the files by checking the modified time, md5Checksum, and so on? Can I ask you about the detailed process of the backup you want? – Tanaike Dec 15 '21 at 04:59
  • @Tanaike, unfortunately, they are large. :( – Asmit Karmakar Dec 16 '21 at 05:41
  • Yes, all the files are copied. I think of two ways: 1) During each sync, all files in *MoviesBackup* will get deleted, and all files from *Movies* will be copied into *MoviesBackup* from the beginning. 2) Only new files would be copied. 2a) Now, suppose, maybe I have a file in *Movies*, which I have updated (say I have changed Interstellar.mp4 from 720p to 1080p, and now they have different file sizes and md5hash. So, I want Interstellar.mp4 to be changed in *MoviesBackup* as well. – Asmit Karmakar Dec 16 '21 at 05:47
  • I prefer 2, since 1 will take a lot of time, and also google takes time to convert .mp4 to their own video format. – Asmit Karmakar Dec 16 '21 at 05:48
  • Hey, you deleted your question about Google Image, and I wanted to give you the solution. You can't use local `file://` URL on the internet. Those are your local files that server can't access. – jcubic Dec 16 '21 at 08:07
  • @jcubic so kind of you, thanks. But, I don't understand your comment. I am undeleting that question now. Please add a solution if you can. – Asmit Karmakar Dec 16 '21 at 08:09
  • Thank you for replying. Now I noticed your replying. I apologize for this. From your replying, I proposed an answer. Could you please confirm it? I'm not sure about your actual file size. So when my proposed method couldn't be used for your situation, I apologize. – Tanaike Dec 18 '21 at 05:13

1 Answers1

0

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:

Tanaike
  • 181,128
  • 11
  • 97
  • 165