0
votes

I am new to google app scripts and I have been looking for a way to back up a sheet. I am currently using.

DriveApp.getFileById("146qFnrQoNPBcDhV6QB0bscHFp8TquXJoAC1qg‌​_esy4E").makeCopy("D‌​ailyArchive" + Date() + " backup");

The problem is its making a daily backup and those backups are updating just like the original and I just want to make a backup of the values so I have a archive. In my sheet I am importing data from a jail roster. http://www.kitsapgov.com/sheriff/incustody/jailwebname.xml

1
im actually using - user5249
DriveApp.getFileById("146qFnrQoNPBcDhV6QB0bscHFp8TquXJoAC1qg_esy4E").makeCopy("DailyArchive" + Date() + " backup"); this is what I am using I ment to put. - user5249

1 Answers

0
votes

Here something quite simple for one sheet (you can adapt it for several sheets)

  var source = SpreadsheetApp.getActiveSpreadsheet();
  var data = source.getActiveSheet().getDataRange();
  var cible = SpreadsheetApp.create(source.getName()+" backup");
  cible.getActiveSheet().getRange(data.getA1Notation()).setValues(data.getValues());
  Logger.log(cible.getId());
  Logger.log(cible.getUrl());