Re: Backing up database...
Posted by: Scott Nemes
Date: January 11, 2013 10:55AM

Do you have shell access to the server? If so you can easily do this with a script that you call via cron.

Below is an example bash script which uses "find" with "mtime" to locate and remove older backups. This is less precise than saying "keep exactly X number of backups" since it is based on time, but it will be similar as long as the backups are run at the same time each day.


#!/bin/bash

# prune backups
find /var/backups -mtime +4 -exec rm {} \;

mysqldump --all-databases --single-transaction | gzip > /var/backups/mysql_backup.`date +%Y%m%d`.gz
done

--
Scott Nemes
MySQL DBA

http://www.linkedin.com/in/scottnemes
http://www.twitter.com/ScottNemes



Edited 2 time(s). Last edit at 01/11/2013 10:56AM by Scott Nemes.

Options: ReplyQuote


Subject
Written By
Posted
January 10, 2013 11:55PM
Re: Backing up database...
January 11, 2013 10:55AM
January 11, 2013 10:08PM


Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.