I have google spreadsheets having Google scripts (.gs files) bounded to it. When I download them from Google Drive, only csv or xlsx get downloaded. The associated scripts files (.gs files) are not downloaded. However the standalone scripts can be downloaded from Google Drive. How can the back up of Google scripts (.gs files) bounded to Google Spreadsheets can be taken? How can they be downloaded?
You can back up file-bound scripts locally on your machine using the command line tools for Google Apps Script (clasp).
The clasp
is an open-source tool, provided by Google, to interact with Google App script projects. It may be used, for instance, to develop websites or Google Docs plugins locally instead of using the web environment. You can use clasp
to download or to deploy projects to the Google App Scritps.
You may check a tutorial in a the Google codelab for Clasp.
Making a copy of a Google Apps Script project
To use clasp
, you must install first Node-js. You can download an installer for Windows or Linux from the official website
One installed Node.js, you must install clasp
. Using a command line terminal, you may execute npm
to perform the installation
npm install -g @google/clasp
After installing clasp
, you can download the project files using the script id. You can go to Google Script Editor and copy the Script Id under File -> Project properties.
On your computer, create a folder for the project and navigate into the newly created folder. You can use a File Explorer to create the folder. Using Windows, Linux or Mac, you can create the folder using the command line terminal and the following commands:
mkdir gas-project
cd gas-project
Finally, to make the copy, you must execute the following command, where 'scriptid' is the id you copied from Project properties.
clasp clone <scriptid>
Once you have a local copy of the files, you can run clasp pull
to update the code locally or clasp push
to send any locally-made changes to the server.