-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Script to Empty Google Drive Trash #436
Comments
You can list the files in trash and remove them all with
What this does is basically list all files that are in trash, extract their file IDs then pipe it to I strongly recommend you consider checking out #422 (comment) which has some tips to safe ways of implementing such queries too especially if you're planning to use cron jobs. Starting from this line
Cheers |
Thanks. The query seems to work but I very quickly run into problems with 'Error 403: Rate Limit Exceeded'. The solution linking to the other issue was also one of mine, so I'm familiar with the code you provided a couple of weeks ago. The situation I'm having is that I have a cron which runs at 3am every day. This creates a backup of my websites and databases, which is then sent over to Google Drive. The file is approximately 450MB. Then, every Sunday, I have another cron which lists the backups that are older than one week and deletes them. It is this that seems to create the 403 error and I'm unsure as to a way around it. |
Another solution I've thought of is using Google Drive's versioning feature. So, rather than having multiple backup files that are just deleted once a week, the latest backup is always available - with older versions available for 30 days or 100 versions through the web interface. I'm unsure how to go about overwriting an exiting file, however, as the GDrive README seems to suggest downloading a file rather than uploading. |
Ah my bad sorry, didn't realize it was you :)
This behavior most likely will change in a future release and you won't need to recompile but just add the API keys |
You can overwrite an existing file using
|
I've just done a trial run of the 'update' script and seem to have avoided a 403 error for now. Hopefully it will remain that way and, if so, it will be what I use going forward. At 450MB a backup, using the versioning feature makes much more sense as I don't have to worry about deleting files to free up space. Essentially, it will save me ~3GB a week which is very useful when restricted to a 30GB plan of GSuite. If I run into any problems, I'll report back. |
As the subject title suggests, is there a way to empty the trash folder via command line?
I'm thinking this could potentially run as a cron once or twice a week, rather than being done manually through the web interface.
The text was updated successfully, but these errors were encountered: