prasmussen / gdrive

Google Drive CLI Client
MIT License
8.99k stars 1.19k forks source link

Gdrive Backup Feature #315

Open ModdyLP opened 7 years ago

ModdyLP commented 7 years ago

Hello,

is it possible to implement the backup function from gdrive in the client? I would like to create a backup with the client and want to delete all backups older than 3 days. I dont know if it is possible with the current version, but i dont get it to work.

Best Regards ModdyLP

menasheh commented 6 years ago

Certainly possible with gdrive and bash scripting together

menasheh commented 6 years ago

To delete all but 5 most recent backups in a particular google drive folder:

#!/bin/bash
FOLDER={{REPLACE WITH BACKUP FOLDER ID}}
KEEP=5
gdrive list --no-header -q "'$FOLDER' in parents" | cut -d " " -f1 | tail -n +$(expr $KEEP + 1) | xargs -n1 -I id gdrive delete id
victorhjk commented 5 years ago

Surely, I did exactly that you questioned, I have only the backups of the three most recent days, I implemented a bash and put it in crontab!