Scripts
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Try It Free
Go Back   Dev Shed ForumsWeb Site ManagementScripts

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:
Get inside! Sample the range of functionality easily built with JMSL Library for Time Series Data Analysis, Heat Maps, Portfolio Optimization, Monte Carlo Simulation, Stock Price Charting and more. Download Now!
  #1  
Old February 11th, 2004, 07:55 AM
csross csross is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Dec 2003
Posts: 105 csross User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 4 h 56 m 28 sec
Reputation Power: 5
script to backup mysqldatabase

Hi,

I need a script for Solaris to perform a mysqldump of a database and have the name represent the day of the week. I have this script but it was written for linux.

$day = getDate();
$system_call = "mysqldump --all-databases > /dir/filename".$day.".sql"

I am not a scriptor and want to know if there is a script for this.

Thanks
Christine

Reply With Quote
  #2  
Old February 29th, 2004, 07:10 AM
christo's Avatar
christo christo is offline
Introspective
Dev Shed Loyal (3000 - 3499 posts)
 
Join Date: Nov 2001
Location: London, UK
Posts: 3,296 christo User rank is Second Lieutenant (5000 - 10000 Reputation Level)christo User rank is Second Lieutenant (5000 - 10000 Reputation Level)christo User rank is Second Lieutenant (5000 - 10000 Reputation Level)christo User rank is Second Lieutenant (5000 - 10000 Reputation Level)christo User rank is Second Lieutenant (5000 - 10000 Reputation Level)christo User rank is Second Lieutenant (5000 - 10000 Reputation Level)christo User rank is Second Lieutenant (5000 - 10000 Reputation Level) 
Time spent in forums: 3 Days 1 h 5 m 42 sec
Reputation Power: 101
Send a message via ICQ to christo Send a message via Yahoo to christo
the script you're looking at there is probably written in perl, and is only partially complete...

I would use the following statement in a cron job to back up a database with the name 'dbname' on host 'nikita'. Note the use of --add-drop-table, which means that table drop statements are added to the dump, so that you don't have to drop a database before restoring it.:

Code:
# back up database at 6am
00 6 * * * /usr/local/mysql/bin/mysqldump --add-drop-table -hnikita -uchristo -p**** dbname> /export/backups/spiration/spiration-`date "+%"`.sql


hth,

christo

Reply With Quote
  #3  
Old March 2nd, 2004, 11:37 AM
frymaster frymaster is offline
hubris, loathing, technology
Dev Shed Newbie (0 - 499 posts)
 
Join Date: May 2001
Location: http://frymaster.ca
Posts: 76 frymaster User rank is Private First Class (20 - 50 Reputation Level)frymaster User rank is Private First Class (20 - 50 Reputation Level) 
Time spent in forums: 1 h 27 m 57 sec
Reputation Power: 8
or use hotcopy

if you are running your backups on a live database, you really want to consider hotcopy (which comes with mysql)

http://www.mysql.com/doc/en/mysqlhotcopy.html

better still, though, is to run two mysqls on two different machines and replicate your data over the network so you always have a live backup. requires mysql 4.0 or higher (well, not really, but doing it on 3.x is a pain)

http://www.mysql.com/doc/en/Replication.html
__________________
[frymaster]

Reply With Quote
  #4  
Old March 2nd, 2004, 12:24 PM
csross csross is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Dec 2003
Posts: 105 csross User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 4 h 56 m 28 sec
Reputation Power: 5
thanks, I will look into it.

Reply With Quote
  #5  
Old April 16th, 2004, 10:13 AM
csross csross is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Dec 2003
Posts: 105 csross User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 4 h 56 m 28 sec
Reputation Power: 5
I have 2 servers running mysql and a cronjob that does a mysqldump to a file and then backs up the file. On one server where there is no root password on the database, the dump works. On the server with the root password for the mysql database, the cron job runs but generates an empty dump file. If I run the same backup script manually, it dumps correctly. When it runs as a cron job, it dumps to a zero length file. I do not see any errors. Any ideas

Reply With Quote
  #6  
Old July 28th, 2004, 06:47 PM
Sonic98 Sonic98 is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Dec 2002
Location: Memphis, TN
Posts: 195 Sonic98 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 2 h 16 m 44 sec
Reputation Power: 6
Send a message via AIM to Sonic98 Send a message via Yahoo to Sonic98
Quote:
Originally Posted by csross
I have 2 servers running mysql and a cronjob that does a mysqldump to a file and then backs up the file. On one server where there is no root password on the database, the dump works. On the server with the root password for the mysql database, the cron job runs but generates an empty dump file. If I run the same backup script manually, it dumps correctly. When it runs as a cron job, it dumps to a zero length file. I do not see any errors. Any ideas



I'd like more info about how to use mysqlhotcopy. Can I run it the same way I would mysql dumb just switch them around?

Is there no way to do a actual copy of a database onto or over another database?

Reply With Quote
Reply

Viewing: Dev Shed ForumsWeb Site ManagementScripts > script to backup mysqldatabase


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 | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 4 hosted by Hostway