UNIX Help
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me

The Shed is going Social! Join us on FaceBook and Twitter and chime in on the conversation.

Go Back   Dev Shed ForumsOperating SystemsUNIX Help

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
  #1  
Old August 6th, 2003, 05:37 PM
lowspeed lowspeed is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Aug 2003
Posts: 141 lowspeed User rank is Corporal (100 - 500 Reputation Level)lowspeed User rank is Corporal (100 - 500 Reputation Level)lowspeed User rank is Corporal (100 - 500 Reputation Level)lowspeed User rank is Corporal (100 - 500 Reputation Level) 
Time spent in forums: 18 h 56 m 13 sec
Reputation Power: 11
How to Crontab

Hi,

I want to use crontab to make daily backups of my mysql database.

But, I don’t want it to overwrite the old file.

How do I auto number the files I’m creating ?

Backup - mysqldump database_name -u user_name -ppassword > SQL_Back_XX

Where xx will increment one after another.


Thanks !

Low.

Reply With Quote
  #2  
Old August 7th, 2003, 12:10 AM
rycamor rycamor is offline
Gödelian monster
Dev Shed Regular (2000 - 2499 posts)
 
Join Date: Jul 1999
Location: Central Florida, USA
Posts: 2,306 rycamor User rank is Sergeant Major (2000 - 5000 Reputation Level)rycamor User rank is Sergeant Major (2000 - 5000 Reputation Level)rycamor User rank is Sergeant Major (2000 - 5000 Reputation Level)rycamor User rank is Sergeant Major (2000 - 5000 Reputation Level)rycamor User rank is Sergeant Major (2000 - 5000 Reputation Level)rycamor User rank is Sergeant Major (2000 - 5000 Reputation Level) 
Time spent in forums: 3 Days 6 h 42 m 51 sec
Reputation Power: 60
This is really a Unix shell-scripting issue, not a database one, but one quick way to handle this would be to use dates:

mysqldump database_name -u user_name -ppassword > SQL_Back_`date +%Y_%m_%d`

Note: the single quotes in this are backquotes (the top left key over the Tab). This means that the command inside the quotes is executed, and the result is returned as a string. So, your backup files would look like

SQL_Back_2003_08_05
SQL_Back_2003_08_06
SQL_Back_2003_08_07

etc...

You could also add minutes to this if you want several backups a day:

mysqldump database_name -u user_name -ppassword > SQL_Back_`date +%Y_%m_%d_%M`

There are many combinations you can do if you play with the date formatting options. Do a 'man date' for more info.
__________________
The real n-tier system:

FreeBSD -> PostgreSQL -> [any_language] -> Apache -> Mozilla/XUL

Amazon wishlist -- rycamor (at) gmail.com

Reply With Quote
  #3  
Old August 7th, 2003, 03:17 PM
lowspeed lowspeed is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Aug 2003
Posts: 141 lowspeed User rank is Corporal (100 - 500 Reputation Level)lowspeed User rank is Corporal (100 - 500 Reputation Level)lowspeed User rank is Corporal (100 - 500 Reputation Level)lowspeed User rank is Corporal (100 - 500 Reputation Level) 
Time spent in forums: 18 h 56 m 13 sec
Reputation Power: 11
Thanks, Helped a bunch.

Quote:
Originally posted by rycamor
This is really a Unix shell-scripting issue, not a database one, but one quick way to handle this would be to use dates:

mysqldump database_name -u user_name -ppassword > SQL_Back_`date +%Y_%m_%d`

Note: the single quotes in this are backquotes (the top left key over the Tab). This means that the command inside the quotes is executed, and the result is returned as a string. So, your backup files would look like

SQL_Back_2003_08_05
SQL_Back_2003_08_06
SQL_Back_2003_08_07

etc...

You could also add minutes to this if you want several backups a day:

mysqldump database_name -u user_name -ppassword > SQL_Back_`date +%Y_%m_%d_%M`

There are many combinations you can do if you play with the date formatting options. Do a 'man date' for more info.

Reply With Quote
Reply

Viewing: Dev Shed ForumsOperating SystemsUNIX Help > How to Crontab

Developer Shed Advertisers and Affiliates



Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump

Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 


Powered by: vBulletin Version 3.0.5
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.

© 2003-2013 by Developer Shed. All rights reserved. DS Cluster - Follow our Sitemap