I have a shell script that runs every night to backup my EC2 sites database and html to S3, and when it backs the folders up, it appends the date to it for easier viewing. But I want it to also be able to delete the relevant backup folders from 3 days before. How can I do the calculations to get the date 3 days ago?
#!/bin/bash
DATE=`date +%m%d%Y`
s3cmd put -r /var/lib/mysql/mydb/ s3://mybucket/mydb-$DATE/
s3cmd put -r /home/ec2-user/public_html/ s3://mybucket/public_html-$DATE/
s3cmd del -r s3://mybucket/mydb-(date 3 days ago)