I need to backup a file on a daily basis, I have resolved this issue using the following script:
function myFunction() {
DocsList.getFileById(SpreadsheetApp.getActiveSpreadsheet().getId()).makeCopy(SpreadsheetApp.getActiveSpreadsheet().getName() + "_Backup");
}
And I'm using the Time-driven trigger to set the hour I want the script creates the backup file. However, I would like these daily backups going to a specific Subfolder, lets call it "Daily Backup Folder".
Can someone help me with a script for that?
Thanks in advance!
makeCopy(name) is what you are using.
makeCopy(name, destination) is what you need to use.
Solution:
You will need to get your folder's ID. Open your the folder where you want to save your backup files in google drive and check it's URL in the browser's address bar.
It will look like:"https ://drive.google.com/drive/folders/zzzzz". Copy this zzzzz and replace the xxxxxx in the code below.
using DocsList service: try:
However, since DocsList service is depreciated, you may want to consider Drive service. Try:
Fill in the actual id of the folder 'Daily Backup folder' in the last line of the script and see if that works ?