Error message on failed backup of file already deleted

68 Views Asked by At

I am using a google apps script that I found on stack overflow to do a daily back up of files time-based. Now I have deleted a few of those files and get an email from [email protected] that the script has failed to finish successfully.

Using this code:

// Abhijeet Chopra
// 26 February 2016
// Google Apps Script to make copies of Google Sheet in specified destination folder

function makeCopy() {
  // generates the timestamp and stores in variable formattedDate as year-month-date hour-minute-second
  var formattedDate = Utilities.formatDate(new Date(), "GMT", "yyyy-MM-dd' 'HH:mm:ss");  
  // gets the name of the original file and appends the word "copy" followed by the timestamp stored in formattedDate
  var name = SpreadsheetApp.getActiveSpreadsheet().getName() + " Copy " + formattedDate;  
  // gets the destination folder by their ID. REPLACE xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx with your folder's ID that you can get by opening the folder in Google Drive and checking the URL in the browser's address bar
  var destination = DriveApp.getFolderById("1ysgERhjmrnq5Uzb9Lu7CtqOWccVTHyVj");  
  // gets the current Google Sheet file
  var file = DriveApp.getFileById(SpreadsheetApp.getActiveSpreadsheet().getId())  
  // makes copy of "file" with "name" at the "destination"
  file.makeCopy(name, destination);
}

The error message is Authorization is required to perform that action.

As the file is not in my Trash folder on my Google Drive anymore, I don't how to turn off that attempts to backup a file that shouldn't exist any more. I also couldn't find any active triggers any more.

I really appreciate some input! Thanks.

0

There are 0 best solutions below