Mysqldump rotate backup | Unix Linux Forums | Shell Programming and Scripting

  Go Back    


Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts and shell scripting languages here.

Mysqldump rotate backup

Shell Programming and Scripting


Tags
mysqldump rotate backup

Closed Thread    
 
Thread Tools Search this Thread Display Modes
    #1  
Old 06-25-2013
timgolding timgolding is offline
Registered User
 
Join Date: Dec 2008
Last Activity: 4 November 2013, 5:24 AM EST
Posts: 83
Thanks: 10
Thanked 2 Times in 2 Posts
Mysqldump rotate backup

I have a very simple script that uses a cron job to take a daily backup of our orders database.


Code:
echo "Dumping ORDERS database";
mysqldump -u root --password='mypassword' -h '1.1.1.1' --opt --compress ORDERS $tbl_names > /Volumes/Files_Backup_1/db_backups/orders.sql
echo "Copied database to external disk";

This will make a single backup on the external hard disk. My worry is if somehow the orders database was TRUNCATED, DROPPED then that evening the database backup would overwrite the empty version of the database to the backup and i would be in big trouble. What i need to know how to do it understand how i can use mysqldump to make a weeks worth of daily backup. Maybe a mon, tue, wed, thur, fri, sat, sun backup or something similar.

I could do


Code:
mysqldump ... > database_$(date +%Y_%m_%d).sql

Or something but then my backup disk would fill up. I need some way of deleting the older backups. Any ideas
Sponsored Links
    #2  
Old 06-25-2013
radoulov's Avatar
radoulov radoulov is offline Forum Staff  
Moderator
 
Join Date: Jan 2007
Last Activity: 21 November 2014, 5:01 AM EST
Location: Варна, България / Milano, Italia
Posts: 5,675
Thanks: 184
Thanked 620 Times in 578 Posts
You may use the day of the week:


Code:
mysqldump ... > database_$(date +%w).sql

The Following User Says Thank You to radoulov For This Useful Post:
timgolding (06-25-2013)
Sponsored Links
    #3  
Old 06-25-2013
timgolding timgolding is offline
Registered User
 
Join Date: Dec 2008
Last Activity: 4 November 2013, 5:24 AM EST
Posts: 83
Thanks: 10
Thanked 2 Times in 2 Posts
Thanks that seems to work
Sponsored Links
Closed Thread

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
Mysqldump certain tables timgolding UNIX for Dummies Questions & Answers 5 01-02-2013 10:42 AM
Help needed for mysqldump command proactiveaditya Shell Programming and Scripting 0 01-20-2010 09:32 PM
mysqldump slowing down the process? DILEEP410 UNIX for Advanced & Expert Users 7 04-19-2009 11:32 PM
mysqldump script without hardcode password bulkbiz Shell Programming and Scripting 5 12-21-2008 06:16 AM



All times are GMT -4. The time now is 12:31 PM.