I'm setting up a bucket to store daily backups from my company's website. The archiving policy I had in mind was to keep a monthly backup for one year, and daily backups for one month. At present, the web server is configured simply to produce a backup each night and then save it to an S3 directory (prefix).S3's lifecycle configuration will let me set a rule to delete (expire) files (objects) after, say, 30 days automatically. The backup file names include the date, so what I'd like to do is have this rule run on anything that doesn't have day 01 in its date (the first of the month). I could then have a second rule to expire all these files.The filter rule options are very limited, however. You can filter on prefix (directory name/path), tag(s), or a combination of the two. Since my current setup just puts a backup into the same directory (prefix) each day, I can't readily use prefix alone as the filter. So, one solution would be to tag the monthly (day 01) backups with one tag, and the other backups with a different tag. Is there a good way of creating a rule that will automatically tag S3 objects based on their filename (using a regular expression)?This is not the only option, of course. I could also configure the backup software to perform a second backup into a different prefix (directory) on the first of the month. Or I could set up a cron job that runs the AWS CLI tool and moves the backup from the daily directory (prefix) into a monthly directory. I just thought it would be nice to try and use tags, if there is an easy way to do so.
Can I automatically add tags to S3 objects based on their filename?
amazon s3