Alex Rivera | Logout

How to take MySQL Database backup and put it in Amazon s3 every Night by using Cron tab?

Asked 2011-05-30T10:52:29.477
10

I have got one server in Rackspace and i'm already running a cron job evry day night to process something...(some account related operation- that will send me email every mid night). my application is in groovy on grails. now i want to take mysql database (called myfleet) backup on every mid night and put that file in Amezon S3 . how can i do that? do i need to write any java or groovy file to process that? or is it can be done from Linux box itself? i have already got account in Amezon S3 (bucket name is fleetBucket)

Edit
Report

1 Answer

7

Should be pretty straightforward:
- backup your database using mysqldump

mysqldump -u [uname] -p[pass] myfleet | gzip -9 > myfleet.sql.gz  

- upload your dump file to S3 using a command line client (e.g. http://s3tools.org/s3cmd:
s3cmd put myfleet.sql.gz s3://<bucketname>/myfleet.sql.gz

Just add this to your cron job (you might want to use some kind of numbering scheme for the dump files, in case you want to keep several versions).

answered 2011-05-30T10:57:18.180

Your Answer