I needed to create a backup for my google sheets and then send the backup to my work mail. so I created this script to help me do this automatically.
This script downloads a sheet from Google Sheets send it via gmail and then deletes it from the location downloaded
thanks to The-Intrigued-Engineer for the encoding solution
- Create a Google Cloud Platform project and get the
.jasonfile. This is the authentication for the google drive. !!SAVE THE FILE SOMEWHARE SAFE!! Here's a tutorial for that- Get the Key of the Spasific Google Sheet you want to download. for example, in this sheet
https://docs.google.com/spreadsheets/d/1zmW8vR7Nwm8Uedfr9zI7WmNsfuTwzk8WCtj4wbN6LUA/edit#gid=0the Key is1zmW8vR7Nwm8Uedfr9zI7WmNsfuTwzk8WCtj4wbN6LUA- Make sure your Google Account have eneabled
Two-Factor Authenticationthen in the Account Managment go to Security>>App Password>>Create new password forother. you will get astringkey !!SAVE THE FILE SOMEWHARE SAFE!! once you see it google will never show it again!- Change the script according to the outcome of the other steps above
- Enjoy :)
I used 'cron' to automate the task on the VM linux mechine. Please feel free to use any other method.