Sunday, December 26, 2021

How to Schedule Automatic Backups of your Google Sheets


Code:

function archiveCopy() {
var file= DriveApp.getFileById("");
var destination= DriveApp.getFolderById("");

var timeZone=Session.getScriptTimeZone();
var formattedDate= Utilities.formatDate(new Date(),timeZone,"yyyy-MM-dd' 'HH:mm:ss");
var name= SpreadsheetApp.getActiveSpreadsheet().getName()+"Copy"+formattedDate;


  file.makeCopy(name,destination);
  
}

4 comments:

  1. Brand new to scripting...I've been trying to do this for a few hours without actual success due to older information, etc. Your tutorial helped me immediately and was the most succinct and easy to follow I have found. THANK YOU!

    ReplyDelete
  2. Hello it doens't work...could you help me ? Panicaiulian.ditu@gmail.com is my email... or 0040740852956 - i'm willing to pay

    ReplyDelete
  3. file.makeCopy(name,destination) isn't a function. How to fix that?

    ReplyDelete
  4. How to delete more than a week old files from backup folder? while backup files piling up with new.

    ReplyDelete