Update: I now use a slightly different version of this script, which creates a single zip file instead of one per document, and puts a timestamp in the filename rather than overwriting the previous backup file. That version can be found at https://github.com/brokensandals/export-google-docs.
Google Apps Script that exports all your Google Docs/Sheets/Slides into docx/xlsx/pptx files and PDFs into a folder in your Google Drive. For more info and step-by-step setup instructions, see here: http://brokensandals.net/google-docs-backup
Replace INSERT_FOLDER_ID_HERE with the ID of the folder you want backups to be placed in.
Create a trigger to run the backupAll
function if you want to do this on a schedule (e.g. nightly).
Notes:
- By default, only files that you own (as opposed to files others have shared with you) will be backed up.
Remove the
file.getOwner()
check from thebackupAll
method if you want to change that. - For each file, both an Office file (docx/xlsx/pptx) and a PDF are generated, and combined into a zip file that's placed in the backup folder. Zipping the backup files ensures that they don't clutter up the recent activity list for Docs/Sheets/Slides.
- The script depends on the lastUpdated dates being correct on both the input files and the files in the backup directory.
If that seems problematic, you could change the
createOrUpdateFileForBlob
method to delete existing backup files rather than updating them.
As always, this code may have defects that prevent it from working properly. Use at your own risk and remember to periodically verify that your backups are actually working as expected.
@dmorgans0803 Based on the error, I'm guessing maybe you didn't replace the text INSERT_FOLDER_ID_HERE in the script. You need to replace it with the ID of some folder that you've created (this is where the backup files will go), as mentioned in the "Instructions" section here: https://brokensandals.net/technical/backup-tooling/google-docs/
To get the ID, you open the folder in Google Drive in your web browser, then look at the address bar - you should see something similar to "https://drive.google.com/drive/folders/asdflkjjlk23409cdsklmklmnnl290". Notice the long sequence of random-looking letters and numbers after "folders/" - that's what you need to copy. Don't include the slash or anything before it; and if you see a question mark, don't include the question mark or anything after it.
Hope this helps - if the issue is something else, I'm afraid I don't have any immediate ideas.