A Script to automatically backup Google Share Drives onto an external drive?

138 views
Skip to first unread message

Dustin Tripp

unread,
Jun 14, 2021, 1:16:18 PM6/14/21
to Google Apps Script Community
Can it be done? It seems the Google API keeps one from making a script to export files from Google Drive. If the former can't be done, does anyone know of a script to automate the downloading of all the files from a drive/folder? Thanks.  

Clark Lind

unread,
Jun 15, 2021, 8:30:38 AM6/15/21
to Google Apps Script Community
Because Drive does not have access to your computer's file system, you have to make the call from your computer using the Drive API. Here is a javascript example using Node:

Download a single file:

var fileId = '0BwwA4oUTeiV1UVNwOHItT0xfa2M';
var dest = fs.createWriteStream('/tmp/photo.jpg');
drive.files.get({
  fileId: fileId,
  alt: 'media'
})
    .on('end', function () {
      console.log('Done');
    })
    .on('error', function (err) {
      console.log('Error during download', err);
    })
    .pipe(dest);


That should point you in the right direction and hopefully explain the limitations.
Reply all
Reply to author
Forward
0 new messages