1
votes

I have a linux machine with some website (normally in /usr/local/apache/htdocs). I would like to create a incremental backup (minimum 7 days) for all data in a my bucket. I have created a bucket as Coldline and I have used rsync for syncing my local folder to the bucket. If I use a rsync tomorrow, the new files is automatically uploaded to the bucket...but how can I delete (after minimum 7 days) the old files?

I use this for rsync: gsutil -m rsync -r /usr/local/apache/htdocs gs://my_bucket

(without the remove tag, because i would keep the deleted files for some days...)

Thank you!

2

2 Answers

3
votes

Google Cloud Platform comes with Object Lifecycle Management functionality, which allows you to add lifecycle management configurations to Cloud Storage buckets.

This can allow you to add rules, including deletion policies.

Each lifecycle management configuration contains a set of rules. For each rule, you can specify various conditions (including object age) for many actions (including delete).

You could therefore use this to create a deletion rule for objects 7+ days old.

For detailed instructions on how to enable Object Lifecycle Management, and configure a deletion rule based on object(s) age take a look here.

0
votes

gsutil rsync doesn't provide a way to delete only after a number of days past when the source file was deleted. You might want to look at backup applications that work with Google Cloud Storage. Such apps let you configure various things about how backups work, for example to hold on to the last version of a deleted file for N days before deleting.