Re:Incremental Backup Script

2010-10-13 Thread kranthi
Hi 

Please be send sample incremental backup script (bash Shell script
Easy to understand)

 

Thanks  Regards,

Kranthikiran



Re: Incremental Backup Script

2010-10-13 Thread Shawn Green (MySQL)

On 10/13/2010 9:18 AM, kranthi wrote:

Hi

 Please be send sample incremental backup script (bash Shell script
Easy to understand)



Thanks  Regards,

Kranthikiran




I think you missed the points of the previous replies.

MySQL does not do incremental backups the the same way that other RDBMS 
products you may be familiar with. You can take full backups (all of the 
tables and all of the data) and partial backups (some of the tables or 
some of the data). With those, you can combine the contents of the 
Binary Log Files to provide yourself with the ability to perform a 
point-in-time-recovery (PITR). Which  combination of backup techniques 
(and there are multiple techniques) you use depends on your hardware, 
software, and operational requirements.


Please read the fine manual for more details:
http://dev.mysql.com/doc/refman/5.1/en/backup-and-recovery.html


--
Shawn Green
MySQL Principal Technical Support Engineer
Oracle USA, Inc.
Office: Blountville, TN

--
MySQL General Mailing List
For list archives: http://lists.mysql.com/mysql
To unsubscribe:http://lists.mysql.com/mysql?unsub=arch...@jab.org



Re: dbnightly maintenance backup script

2007-05-16 Thread Ofer Inbar
On Thu, May 10, 2007 at 03:23:31PM -0400,
Ofer Inbar [EMAIL PROTECTED] wrote:
   http://thwip.sysadmin.org/dbnightly

The version I put up there had a minor bug:

176c176
   my ($sec,$min,$hour,$mday,$mon,$year) = localtime(time); $year+=1900;
---
   my ($sec,$min,$hour,$mday,$mon,$year) = localtime(time); $year+=1900; 
 $mon++;

I forgot to increment month in the code that names the full dump file,
so it got named with 0-based month numbers (that is, 200704 for May).

It's fixed.  If you got the script, get it from there or add the increment.
  -- Cos

-- 
MySQL General Mailing List
For list archives: http://lists.mysql.com/mysql
To unsubscribe:http://lists.mysql.com/[EMAIL PROTECTED]



dbnightly maintenance backup script

2007-05-10 Thread Ofer Inbar
I wrote a perl script to handle all of our regular mysql maintenance
tasks, which I thought might be useful to others.  It's meant for an
enviroment with binary logging turned on, but is fairly flexible.
Although if you're backing up multiple databases you'll have to modify
it a bit, since in our case we only care about backing up one database
(if you do modify it for multidatabase, please send me your diffs).

  http://thwip.sysadmin.org/dbnightly

The syntax is: dbnightly [action [action ...]]

It will perform the actions in the order you give them on its commandline.
Actions it knows how to do are:

1. maint - Run a bunch of SQL queries for nightly maintenace
  (put the queries you want in the DBMAINT section of the script)

2. full - a full mysqldump, into the backup directory, gzip'ed and
   with the database name and datetimestamp in the filename

3. partial - a partial mysqldump of a list of tables you choose,
   into the backup directory, gzip'd

4. flush - flush binary logs

5. logs - copy new or modified binary logs to the backup directory and
   gzip them, delete any that have been deleted from the mysql directory,
   and don't copy  gzip ones that haven't changed since last backed up

The resulting backup directory is all gzip'ed and suitable for rsync'ing.

We run it from crontab, and it produces output like this:

2007-05-10 06:00 dbnightly: Database maintenace
Table   Op  Msg_typeMsg_text
databasename.tablename   optimizestatus  OK
2007-05-10 06:00 dbnightly: Database maintenance done
2007-05-10 06:00 dbnightly: Partial dump of databasename to 
/home/maintusr/backups
2007-05-10 06:01 dbnightly: Partial dump complete: databasename-partial.sql
2007-05-10 06:02 dbnightly: Flushing binary logs
2007-05-10 06:02 dbnightly: Copying /var/lib/mysql/binlogfile.90 to 
/home/maintusr/backups
2007-05-10 06:02 dbnightly: Copying /var/lib/mysql/binlogfile.91 to 
/home/maintusr/backups
2007-05-10 06:02 dbnightly: Done

It also syslogs, like this:

May 10 05:00:01 hostname dbnightly: Database maintenace 
May 10 05:00:04 hostname dbnightly: Database maintenance done 
May 10 05:00:04 hostname dbnightly: Partial dump of databasename to 
/home/maintusr/backups 
May 10 05:01:18 hostname dbnightly: Partial dump complete: 
databasename-partial.sql 
May 10 05:02:14 hostname dbnightly: Flushing binary logs 
May 10 05:02:15 hostname dbnightly: Copying /var/lib/mysql/binlogfile.90 to 
/home/maintusr/backups 
May 10 05:02:38 hostname dbnightly: Copying /var/lib/mysql/binlogfile.91 to 
/home/maintusr/backups 
May 10 05:02:39 hostname dbnightly: Done 

Both of these are from dbnightly maint partial flush logs, which we
run 6 nights a week.  On the other night, we run dbnightly maint full logs
(no need to flush because --flush-logs is in the $fulldump options).

Note: the dirsyncgz script I posted recently was a modified version
of the binlogs subroutine from this script (dbnightly was not complete yet)

  --  Cos (Ofer Inbar)  --  [EMAIL PROTECTED]  http://thwip.sysadmin.org/
  cos, is perl God? 'No, Larry Wall is God.  Perl is the Language of God.
  But I thought you don't believe in God?  That's OK, I don't believe
   in Larry Wall either.  -- a conversation with Mike Sackton over lunch

-- 
MySQL General Mailing List
For list archives: http://lists.mysql.com/mysql
To unsubscribe:http://lists.mysql.com/[EMAIL PROTECTED]



RE: dbnightly maintenance backup script

2007-05-10 Thread Daevid Vincent
Thanks for sharring Ofer.

I'll throw the one I wrote and use into the mix too.
http://daevid.com/examples/daily_backup_tgz.sh

Simply put it in your /etc/cron.daily/ 

And then every so often monitor /backups/ and delete stuff that's getting old. 
(it does some cleanup)

d

 -Original Message-
 From: Ofer Inbar [mailto:[EMAIL PROTECTED] 
 Sent: Thursday, May 10, 2007 12:24 PM
 To: mysql@lists.mysql.com
 Subject: dbnightly maintenance  backup script
 
 I wrote a perl script to handle all of our regular mysql maintenance
 tasks, which I thought might be useful to others.  It's meant for an
 enviroment with binary logging turned on, but is fairly flexible.
 Although if you're backing up multiple databases you'll have to modify
 it a bit, since in our case we only care about backing up one database
 (if you do modify it for multidatabase, please send me your diffs).
 
   http://thwip.sysadmin.org/dbnightly
 
 The syntax is: dbnightly [action [action ...]]
 
 It will perform the actions in the order you give them on its 
 commandline.
 Actions it knows how to do are:
 
 1. maint - Run a bunch of SQL queries for nightly maintenace
   (put the queries you want in the DBMAINT section of the script)
 
 2. full - a full mysqldump, into the backup directory, gzip'ed and
with the database name and datetimestamp in the filename
 
 3. partial - a partial mysqldump of a list of tables you choose,
into the backup directory, gzip'd
 
 4. flush - flush binary logs
 
 5. logs - copy new or modified binary logs to the backup directory and
gzip them, delete any that have been deleted from the 
 mysql directory,
and don't copy  gzip ones that haven't changed since last 
 backed up
 
 The resulting backup directory is all gzip'ed and suitable 
 for rsync'ing.
 
 We run it from crontab, and it produces output like this:
 
 2007-05-10 06:00 dbnightly: Database maintenace
 Table   Op  Msg_typeMsg_text
 databasename.tablename   optimizestatus  OK
 2007-05-10 06:00 dbnightly: Database maintenance done
 2007-05-10 06:00 dbnightly: Partial dump of databasename to 
 /home/maintusr/backups
 2007-05-10 06:01 dbnightly: Partial dump complete: 
 databasename-partial.sql
 2007-05-10 06:02 dbnightly: Flushing binary logs
 2007-05-10 06:02 dbnightly: Copying 
 /var/lib/mysql/binlogfile.90 to /home/maintusr/backups
 2007-05-10 06:02 dbnightly: Copying 
 /var/lib/mysql/binlogfile.91 to /home/maintusr/backups
 2007-05-10 06:02 dbnightly: Done
 
 It also syslogs, like this:
 
 May 10 05:00:01 hostname dbnightly: Database maintenace 
 May 10 05:00:04 hostname dbnightly: Database maintenance done 
 May 10 05:00:04 hostname dbnightly: Partial dump of 
 databasename to /home/maintusr/backups 
 May 10 05:01:18 hostname dbnightly: Partial dump complete: 
 databasename-partial.sql 
 May 10 05:02:14 hostname dbnightly: Flushing binary logs 
 May 10 05:02:15 hostname dbnightly: Copying 
 /var/lib/mysql/binlogfile.90 to /home/maintusr/backups 
 May 10 05:02:38 hostname dbnightly: Copying 
 /var/lib/mysql/binlogfile.91 to /home/maintusr/backups 
 May 10 05:02:39 hostname dbnightly: Done 
 
 Both of these are from dbnightly maint partial flush logs, which we
 run 6 nights a week.  On the other night, we run dbnightly 
 maint full logs
 (no need to flush because --flush-logs is in the $fulldump options).
 
 Note: the dirsyncgz script I posted recently was a modified version
 of the binlogs subroutine from this script (dbnightly was not 
 complete yet)
 
   --  Cos (Ofer Inbar)  --  [EMAIL PROTECTED]  http://thwip.sysadmin.org/
   cos, is perl God? 'No, Larry Wall is God.  Perl is the 
 Language of God.
   But I thought you don't believe in God?  That's OK, I 
 don't believe
in Larry Wall either.  -- a conversation with Mike 
 Sackton over lunch
 
 -- 
 MySQL General Mailing List
 For list archives: http://lists.mysql.com/mysql
 To unsubscribe:
 http://lists.mysql.com/[EMAIL PROTECTED]
 
 


-- 
MySQL General Mailing List
For list archives: http://lists.mysql.com/mysql
To unsubscribe:http://lists.mysql.com/[EMAIL PROTECTED]



Re: mysql backup script

2004-06-16 Thread Steve Buehler
Thanks to all that responded.  The answer was a little different from the 
one below.  So what it came out to was this:
while [ -f $mysqlpid ]
do
sleep 1
/etc/rc.d/init.d/mysqld stop
done

For those that recommended webmin.  Although I have webmin installed, 
because of the type of backups that I needed and how they were to be done, 
webmin was not an option.  Thanks though.
Steve

At 11:29 AM 6/15/2004, Brian Reichert wrote:
On Tue, Jun 15, 2004 at 08:04:00AM -0500, Steve Buehler wrote:
 I am having a problem with a backup script that is written in a shell
 (/bin/sh) script to backup my mysql databases.  For some reason on any day
 with an even number I get the following error:
 MySQL could not be stopped, exiting...
 It is really weird because it will run on odd number days without a
 problem.  Should I put some kind of a wait in the script after it stops 
the
 mysqld and before it checks to make sure the pid file is still there?  If
 so, does anybody know how?  I am not sure that that will solve the problem
 though because it exits afterward and the mysql daemon is still running
 without having to restart it.  Below is the relevant part of the script.
 The script is run from cron with this line
 0 1 * * * /root/backup/backup.sh /dev/null 21
 But since the logs do show it running, That shouldn't be the problem.
 Thanks
 Steve

 #  Perform myisamchk
 #mysqladmin -p$MYSQLPWD shutdown
 /etc/rc.d/init.d/mysqld stop
 if [ -f $mysqlpid ]; then

Does /etc/rc.d/init.d/mysqld (however indirectly) remove the $mysqlpid file
when it exits?
Is $mysqlpid the same as '/etc/rc.d/init.d/mysqld start' would create?
Couldn't you check for an exit status of '/etc/rc.d/init.d/mysqld stop'
instead?
I've played stupid games like this, to work around weak management
scripts (pseudo-code):
  while( -f $mysqlpid )
sleep 1
  end
There are risks with that, as well, of course, but you see what it's trying
to do...
--
Brian Reichert  [EMAIL PROTECTED]
37 Crystal Ave. #303Daytime number: (603) 434-6842
Derry NH 03038-1713 USA BSD admin/developer at large

--
MySQL General Mailing List
For list archives: http://lists.mysql.com/mysql
To unsubscribe:http://lists.mysql.com/[EMAIL PROTECTED]


mysql backup script

2004-06-15 Thread Steve Buehler
I am having a problem with a backup script that is written in a shell 
(/bin/sh) script to backup my mysql databases.  For some reason on any day 
with an even number I get the following error:
MySQL could not be stopped, exiting...
It is really weird because it will run on odd number days without a 
problem.  Should I put some kind of a wait in the script after it stops the 
mysqld and before it checks to make sure the pid file is still there?  If 
so, does anybody know how?  I am not sure that that will solve the problem 
though because it exits afterward and the mysql daemon is still running 
without having to restart it.  Below is the relevant part of the script.
The script is run from cron with this line
0 1 * * * /root/backup/backup.sh /dev/null 21
But since the logs do show it running, That shouldn't be the problem.
Thanks
Steve

#  Perform myisamchk
#mysqladmin -p$MYSQLPWD shutdown
/etc/rc.d/init.d/mysqld stop
if [ -f $mysqlpid ]; then
echo -e MySQL could not be stopped, exiting...   
/tmp/backuplog$date
exit 1
else
echo -e Checking MYI tables for all databases   
/tmp/backuplog$date
myisamchk --silent --force --fast --update-state -O key_buffer=64M \
-O sort_buffer=64M -O read_buffer=1M -O write_buffer=1M \
/var/lib/mysql/*/*.MYI
fi
echo -e Checks complete, starting MySQL   /tmp/backuplog$date
/etc/rc.d/init.d/mysqld restart
sleep 20
if [ ! -f $mysqlpid ]; then
echo -e MySQL failed to start, exiting...   /tmp/backuplog$date
exit 1
fi
##

--
MySQL General Mailing List
For list archives: http://lists.mysql.com/mysql
To unsubscribe:http://lists.mysql.com/[EMAIL PROTECTED]


Re: mysql backup script

2004-06-15 Thread Brian Reichert
On Tue, Jun 15, 2004 at 08:04:00AM -0500, Steve Buehler wrote:
 I am having a problem with a backup script that is written in a shell 
 (/bin/sh) script to backup my mysql databases.  For some reason on any day 
 with an even number I get the following error:
 MySQL could not be stopped, exiting...
 It is really weird because it will run on odd number days without a 
 problem.  Should I put some kind of a wait in the script after it stops the 
 mysqld and before it checks to make sure the pid file is still there?  If 
 so, does anybody know how?  I am not sure that that will solve the problem 
 though because it exits afterward and the mysql daemon is still running 
 without having to restart it.  Below is the relevant part of the script.
 The script is run from cron with this line
 0 1 * * * /root/backup/backup.sh /dev/null 21
 But since the logs do show it running, That shouldn't be the problem.
 Thanks
 Steve
 
 #  Perform myisamchk
 #mysqladmin -p$MYSQLPWD shutdown
 /etc/rc.d/init.d/mysqld stop
 if [ -f $mysqlpid ]; then

Does /etc/rc.d/init.d/mysqld (however indirectly) remove the $mysqlpid file
when it exits?

Is $mysqlpid the same as '/etc/rc.d/init.d/mysqld start' would create?

Couldn't you check for an exit status of '/etc/rc.d/init.d/mysqld stop'
instead?

I've played stupid games like this, to work around weak management
scripts (pseudo-code):

  while( -f $mysqlpid )
sleep 1
  end

There are risks with that, as well, of course, but you see what it's trying
to do...


-- 
Brian Reichert  [EMAIL PROTECTED]
37 Crystal Ave. #303Daytime number: (603) 434-6842
Derry NH 03038-1713 USA BSD admin/developer at large

-- 
MySQL General Mailing List
For list archives: http://lists.mysql.com/mysql
To unsubscribe:http://lists.mysql.com/[EMAIL PROTECTED]



Re: my backup script

2003-05-30 Thread Jeremy Zawodny
On Thu, May 29, 2003 at 12:37:46AM -0700, Jeremy Zawodny wrote:
 On Thu, May 29, 2003 at 12:10:09AM -0700, Daevid Vincent wrote:
  
  Ps. And yes, I sent that as a link in my resume because I'm unemployed
  and would love any offers for coding work with PHP, Linux, SQL, etc...
  ;-)
 
 Well, if you're gonna pimp your resume here, I'll respond
 similarly. :-)
 
 We use lots of PHP and MySQL at Yahoo!  Visit join.yahoo.com to search
 for current engineering openings.  If you apply, make sure to note
 that I referred you.

On second thought, you seem to be spamming mailing lists.  Please do
not apply.

Jeremy
-- 
Jeremy D. Zawodny |  Perl, Web, MySQL, Linux Magazine, Yahoo!
[EMAIL PROTECTED]  |  http://jeremy.zawodny.com/

MySQL 4.0.8: up 115 days, processed 3,589,713,440 queries (360/sec. avg)

-- 
MySQL General Mailing List
For list archives: http://lists.mysql.com/mysql
To unsubscribe:http://lists.mysql.com/[EMAIL PROTECTED]



RE: my backup script

2003-05-30 Thread Daevid Vincent
Whoa. Easy there killer. First, it's kinda uncool to accuse me of
spamming when I sent it one time to three separate lists all relevant:
SVLUG, RedHat and mySQL. Just because YOU are on multiple lists, doesn't
mean that others are. This is hardly 'spamming'. Then on top of that,
you sent your *opinion* to a public list as well, instead of directly to
me. Talk about poor netiquette. This forces me to reply public ally to
defend myself.

Second, my script is hardly spam. It is highly useful for both daily
Linux system backups as well as mySQL database backups -- extremely
relevant to all lists. The reason to send it to the mySQL list is
obvious as 1/2 the script is for backing up mySQL db's intelligently. I
sent it to SVLUG, as there are many of my friends on there and I still
consider that my main Linux list. Then I sent it to the redhat list
because someone had just posted that they were looking for a good backup
script, and I was replying to that. Not to mention an excellent example
of bash shell scripting that contains multiple examples of code that I
had to scour the web for -- now someone else could cut/paste out the
parts they need to do a different task.

So, you can escalate this into a flame war Jeremy, or you can retract
your rude statement by apologizing and let it be bygones...


 -Original Message-
 From: Jeremy Zawodny [mailto:[EMAIL PROTECTED] 
 Sent: Thursday, May 29, 2003 7:58 AM
 To: [EMAIL PROTECTED]
 Cc: Daevid Vincent
 Subject: Re: my backup script
 
 
 On Thu, May 29, 2003 at 12:37:46AM -0700, Jeremy Zawodny wrote:
  On Thu, May 29, 2003 at 12:10:09AM -0700, Daevid Vincent wrote:
   
   Ps. And yes, I sent that as a link in my resume because 
 I'm unemployed
   and would love any offers for coding work with PHP, 
 Linux, SQL, etc...
   ;-)
  
  Well, if you're gonna pimp your resume here, I'll respond
  similarly. :-)
  
  We use lots of PHP and MySQL at Yahoo!  Visit 
 join.yahoo.com to search
  for current engineering openings.  If you apply, make sure to note
  that I referred you.
 
 On second thought, you seem to be spamming mailing lists.  Please do
 not apply.
 
 Jeremy
 -- 
 Jeremy D. Zawodny |  Perl, Web, MySQL, Linux Magazine, Yahoo!
 [EMAIL PROTECTED]  |  http://jeremy.zawodny.com/
 
 MySQL 4.0.8: up 115 days, processed 3,589,713,440 queries 
 (360/sec. avg)
 


-- 
MySQL General Mailing List
For list archives: http://lists.mysql.com/mysql
To unsubscribe:http://lists.mysql.com/[EMAIL PROTECTED]



Re: my backup script

2003-05-30 Thread Jeremy Zawodny
On Thu, May 29, 2003 at 02:19:11PM -0700, Daevid Vincent wrote:
 Whoa. Easy there killer. First, it's kinda uncool to accuse me of
 spamming when I sent it one time to three separate lists all relevant:
 SVLUG, RedHat and mySQL. Just because YOU are on multiple lists, doesn't
 mean that others are. This is hardly 'spamming'. Then on top of that,
 you sent your *opinion* to a public list as well, instead of directly to
 me. Talk about poor netiquette. This forces me to reply public ally to
 defend myself.

For the sake of anyone who is wondering, I'll keep this short and keep
all of my *opinion* out of it.  We're now discussing this off-list.

Jeremy
-- 
Jeremy D. Zawodny |  Perl, Web, MySQL, Linux Magazine, Yahoo!
[EMAIL PROTECTED]  |  http://jeremy.zawodny.com/

MySQL 4.0.8: up 115 days, processed 3,595,603,240 queries (360/sec. avg)

-- 
MySQL General Mailing List
For list archives: http://lists.mysql.com/mysql
To unsubscribe:http://lists.mysql.com/[EMAIL PROTECTED]



my backup script

2003-05-29 Thread Daevid Vincent
I've just spent the past few days writing this backup script...

http://resume.daevid.com follow the link for it.

It will do weekly full backups on Sunday and daily diff backups. It also
does daily dumps of all databases in the mysql db directory then
combines them into a single .tgz file for storage (I find this more sexy
than the mysqldump -A option which combines them all into a huge dump
file! Yipes). It is best if you have /backups as a separate device
because I mount it rw and then ro when finished storing the backups.
Simply list what you want at the top and use the exclude file to omit
what you don't.

Ideally I'd like to make it so it only backs up the mysql databases that
have changed (diff), but I'm not sure how to determine that, as the
directory doesn't seem to change it's date as I would expect, if the
contents within are updated. Hmmm. Ideas?

Also, I use ctime in my find for the differentials, is mtime a better
choice or does it really matter? Will ctime find all the mtime files
too?

Daevid Vincent
http://daevid.com

Ps. And yes, I sent that as a link in my resume because I'm unemployed
and would love any offers for coding work with PHP, Linux, SQL, etc...
;-)


-- 
MySQL General Mailing List
For list archives: http://lists.mysql.com/mysql
To unsubscribe:http://lists.mysql.com/[EMAIL PROTECTED]



Re: my backup script

2003-05-29 Thread Jeremy Zawodny
On Thu, May 29, 2003 at 12:10:09AM -0700, Daevid Vincent wrote:
 
 Ps. And yes, I sent that as a link in my resume because I'm unemployed
 and would love any offers for coding work with PHP, Linux, SQL, etc...
 ;-)

Well, if you're gonna pimp your resume here, I'll respond
similarly. :-)

We use lots of PHP and MySQL at Yahoo!  Visit join.yahoo.com to search
for current engineering openings.  If you apply, make sure to note
that I referred you.

Contact me for more details.

Jeremy
-- 
Jeremy D. Zawodny |  Perl, Web, MySQL, Linux Magazine, Yahoo!
[EMAIL PROTECTED]  |  http://jeremy.zawodny.com/

MySQL 4.0.8: up 114 days, processed 3,575,609,920 queries (360/sec. avg)

-- 
MySQL General Mailing List
For list archives: http://lists.mysql.com/mysql
To unsubscribe:http://lists.mysql.com/[EMAIL PROTECTED]



RE: backup script

2003-02-22 Thread Don Read

On 19-Feb-2003 Jeff Mao wrote:
 Greetings all,
 
 Not sure if this is the right place to ask this,...I use the 
 following script on an OS X server to backup my mysql databases:
 
   #!/bin/sh
 DATE=`/bin/date +%Y%m%d_%H%M%S`;
 cd /Users/usernmae/Documents;
 /usr/bin/mysqldump -hhost -uusername -ppassword --all-databases  
 full_dump_$DATE.sql;
 exit
 
 The script runs on from the crontab each morning at 3:30 am.  Simple 
 question, I got the script from someone else, so I'm not too savvy 
 with scripting.  What can I add to the script so that it 
 automatically erases backups that are x weeks or days old?  If I 
 forget about it, the backup folder soon blossoms as it collects a new 
 backup each day, and I'd like to automate the process more so I'm not 
 holding on to tons of old backups.
 

find /Users/usernmae/Documents -mtime +7 -name full_dump*.sql -exec rm{} \;

will delete backups older than a week (7 days)

Regards,
-- 
Don Read   [EMAIL PROTECTED]
-- It's always darkest before the dawn. So if you are going to 
   steal the neighbor's newspaper, that's the time to do it.
(53kr33t w0rdz: sql table query)

-
Before posting, please check:
   http://www.mysql.com/manual.php   (the manual)
   http://lists.mysql.com/   (the list archive)

To request this thread, e-mail [EMAIL PROTECTED]
To unsubscribe, e-mail [EMAIL PROTECTED]
Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php



backup script

2003-02-19 Thread Jeff Mao
Greetings all,

Not sure if this is the right place to ask this,...I use the 
following script on an OS X server to backup my mysql databases:

 #!/bin/sh
DATE=`/bin/date +%Y%m%d_%H%M%S`;
cd /Users/usernmae/Documents;
/usr/bin/mysqldump -hhost -uusername -ppassword --all-databases  
full_dump_$DATE.sql;
exit

The script runs on from the crontab each morning at 3:30 am.  Simple 
question, I got the script from someone else, so I'm not too savvy 
with scripting.  What can I add to the script so that it 
automatically erases backups that are x weeks or days old?  If I 
forget about it, the backup folder soon blossoms as it collects a new 
backup each day, and I'd like to automate the process more so I'm not 
holding on to tons of old backups.

Thanks
Jeff

--

Jeff Mao
[EMAIL PROTECTED]

-
Before posting, please check:
  http://www.mysql.com/manual.php   (the manual)
  http://lists.mysql.com/   (the list archive)

To request this thread, e-mail [EMAIL PROTECTED]
To unsubscribe, e-mail [EMAIL PROTECTED]
Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php



Re: backup script

2003-02-19 Thread Sigurd Urdahl
Jeff Mao [EMAIL PROTECTED] writes:

 Greetings all,
 
 Not sure if this is the right place to ask this,...I use the following
 script on an OS X server to backup my mysql databases:
 
   #!/bin/sh
 DATE=`/bin/date +%Y%m%d_%H%M%S`;
 cd /Users/usernmae/Documents;
 /usr/bin/mysqldump -hhost -uusername -ppassword --all-databases 
 full_dump_$DATE.sql;
 exit
 
 The script runs on from the crontab each morning at 3:30 am.  Simple
 question, I got the script from someone else, so I'm not too savvy
 with scripting.  What can I add to the script so that it automatically
 erases backups that are x weeks or days old?

Probalbly lots of ways:) You could use find to løoace files older than
some date, and erase them. Or if one week is god for you you could
change your script to do something like this:

/usr/bin/mysqldump -hhost -uusername -ppassword --all-databases 
`date +%V`/full_dump.sql;

That will give you 7 directories, one for each weekday, with a dump
each.

-sig

-- 
Sigurd Urdahl   [EMAIL PROTECTED]
Systemkonsulent | Systems consultant www.linpro.no
LIN PRO can improve the health of people who consume the eggs,
meat and milk [..] (http://www.werneragra.com/linpro.html)

-
Before posting, please check:
   http://www.mysql.com/manual.php   (the manual)
   http://lists.mysql.com/   (the list archive)

To request this thread, e-mail [EMAIL PROTECTED]
To unsubscribe, e-mail [EMAIL PROTECTED]
Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php




Re: backup script

2002-08-27 Thread Terence

You need a combo of cron jobs (man crontab) and use either mysqldump or
mysqlhotcopy.

cron:
* 3 * * * path_to_your_script

script

./mysqldump --opt -A  path_to_output_sql_file -u username

this is just one of the many ways.

- Original Message -
From: Ilyas Keser [EMAIL PROTECTED]
To: [EMAIL PROTECTED]
Sent: Tuesday, August 27, 2002 6:26 AM
Subject: backup script


Has anyone a shell script example to backup all mysql databases at 3
o'clock at the night?

Thanks...
ilyas

-
Before posting, please check:
   http://www.mysql.com/manual.php   (the manual)
   http://lists.mysql.com/   (the list archive)

To request this thread, e-mail [EMAIL PROTECTED]
To unsubscribe, e-mail
[EMAIL PROTECTED]
Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php


-
Before posting, please check:
   http://www.mysql.com/manual.php   (the manual)
   http://lists.mysql.com/   (the list archive)

To request this thread, e-mail [EMAIL PROTECTED]
To unsubscribe, e-mail [EMAIL PROTECTED]
Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php




backup script

2002-08-26 Thread Ilyas Keser

Has anyone a shell script example to backup all mysql databases at 3 
o'clock at the night?

Thanks...
ilyas

-
Before posting, please check:
   http://www.mysql.com/manual.php   (the manual)
   http://lists.mysql.com/   (the list archive)

To request this thread, e-mail [EMAIL PROTECTED]
To unsubscribe, e-mail [EMAIL PROTECTED]
Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php




Re: backup script

2002-08-26 Thread Gerald R. Jensen

I use a shell script and set up a cron job. Here's the shell script (I call
it mydbbak.sh)

#
#!/bin/sh
#
# Create /dbbakup directory
# $1 = Unix/MySQL Username
# $2 = Unix/MySQL Password

if [ ! -e /dbbakup ]
 then
  mkdir /dbbakup
  chmod 777 /dbbakup -R
fi

mysqldump -u$1 -p$2 -c --add-drop-table --add-locks --flush-logs --databases
database1/dbbakup/database1.sql
mysqldump -u$1 -p$2 -c --add-drop-table --add-locks --flush-logs --databases
database2/dbbakup/database2.sql
mysqldump -u$1 -p$2 -c --add-drop-table --add-locks --flush-logs --databases
database3/dbbakup/database3.sql

#


And here's the line from the crontab ...

# Make backups of databases at 3am daily
0 3 * * * /usr/local/bin/mydbbak.sh

Gerald Jensen
- Original Message -
From: Ilyas Keser [EMAIL PROTECTED]
To: [EMAIL PROTECTED]
Sent: Monday, August 26, 2002 5:26 PM
Subject: backup script


Has anyone a shell script example to backup all mysql databases at 3
o'clock at the night?

Thanks...
ilyas

-
Before posting, please check:
   http://www.mysql.com/manual.php   (the manual)
   http://lists.mysql.com/   (the list archive)

To request this thread, e-mail [EMAIL PROTECTED]
To unsubscribe, e-mail
[EMAIL PROTECTED]
Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php






-
Before posting, please check:
   http://www.mysql.com/manual.php   (the manual)
   http://lists.mysql.com/   (the list archive)

To request this thread, e-mail [EMAIL PROTECTED]
To unsubscribe, e-mail mysql-unsubscribe-##L=##[EMAIL PROTECTED]
Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php




Re: backup script

2002-08-26 Thread Mark Stringham

Anyone done it on widows?

Thanks

Mark
- Original Message -
From: Ilyas Keser [EMAIL PROTECTED]
To: [EMAIL PROTECTED]
Sent: Monday, August 26, 2002 4:26 PM
Subject: backup script


 Has anyone a shell script example to backup all mysql databases at 3
 o'clock at the night?

 Thanks...
 ilyas

 -
 Before posting, please check:
http://www.mysql.com/manual.php   (the manual)
http://lists.mysql.com/   (the list archive)

 To request this thread, e-mail [EMAIL PROTECTED]
 To unsubscribe, e-mail
[EMAIL PROTECTED]
 Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php



-
Before posting, please check:
   http://www.mysql.com/manual.php   (the manual)
   http://lists.mysql.com/   (the list archive)

To request this thread, e-mail [EMAIL PROTECTED]
To unsubscribe, e-mail [EMAIL PROTECTED]
Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php




Re: backup script

2002-08-26 Thread Dicky Wahyu Purnomo

Pada Mon, 26 Aug 2002 20:37:46 -0600
Mark Stringham [EMAIL PROTECTED] menulis :

 Anyone done it on widows?
 
 Thanks
 
 Mark


for dumping, the syntax is same  ... mysqldump bla bla bla  ;-)

but for the time, you have to use scheduler application to run the mysqldump :D

-- 
Write clearly - don't be too clever.
- The Elements of Programming Style (Kernighan  Plaugher)
 
MySQL 3.23.51 : up 66 days, Queries : 356.856 per second (avg).

--
Dicky Wahyu Purnomo - System Administrator
PT FIRSTWAP : Jl Kapt. Tendean No. 34 - Jakarta Selatan 12790
Phone : +62 21 79199577 - HP : +62 8551044244 - Web : http://www.1rstwap.com


-
Before posting, please check:
   http://www.mysql.com/manual.php   (the manual)
   http://lists.mysql.com/   (the list archive)

To request this thread, e-mail [EMAIL PROTECTED]
To unsubscribe, e-mail [EMAIL PROTECTED]
Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php




Re: Re: backup script

2002-08-26 Thread conquer

Mark Stringham :
   
 i think that you can use task plan on windows.such as,
 backup.bat:
mysqldump -uroot -pmysql databasename tablename  tablename.sql 
move tablename.sql d:\where you want store it\
and add a  tast plan in control panel, set the time to 3 o'lock,
set the execute application to backup.bat.
english not my mother tongue,so i am sorry for my english.


Anyone done it on widows?

Thanks

Mark
- Original Message -
From: Ilyas Keser [EMAIL PROTECTED]
To: [EMAIL PROTECTED]
Sent: Monday, August 26, 2002 4:26 PM
Subject: backup script


 Has anyone a shell script example to backup all mysql databases at 3
 o'clock at the night?

 Thanks...
 ilyas

Regards
   
conquer
[EMAIL PROTECTED]



-
Before posting, please check:
   http://www.mysql.com/manual.php   (the manual)
   http://lists.mysql.com/   (the list archive)

To request this thread, e-mail [EMAIL PROTECTED]
To unsubscribe, e-mail [EMAIL PROTECTED]
Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php