[thelist] MySQL Backup Statement

Dan McCullough dan.mccullough at gmail.com
Fri Aug 5 09:28:36 CDT 2005


sorry for the unclear response.

you can create a file called backup.sh at the beginning of the file put this:

############################################################
#!/bin/sh
#backup.sh

date=`date -I`
rm -f /var/backup/<dbname>-bak-*.sql.gz
/opt/mysql/bin/mysqldump --opt --quote-names -u <user> -p<pass>
<dbname> | gzip > /var/backup/<dbname>-bak-$date.sql.gz


############################################################

the email might break up the line the mysqldump command should be all
on the same lines.  sorry about the gz, here is a non gz command

#############################################################

no compression
/opt/mysql/bin/mysqldump --opt --quote-names -u <user> -p<pass>
<dbname> > /var/backup/<dbname>-bak-$date.sql

bzip2
/opt/mysql/bin/mysqldump --opt --quote-names -u <user> -p<pass>
<dbname> | bzip2 -c > <dbname>-bak-$date.sql.bz2

tar (not tested)
/opt/mysql/bin/mysqldump --opt --quote-names -u <user> -p<pass>
<dbname> | tar -cvf > <dbname>-bak-$date.sql.tar
#############################################################

to do the cron job just vi /etc/crontab and enter below on a blank line.
############################################################
<minute> <hour 24 hour clock> * * * <path to file location>/backup.sh
>/dev/null 2>&1
############################################################

that will run daily at the time specified, to run it only on a certain
day at the last '*' put 0-6, 0= Sunday and 6=Saturday.  for more
specifics just google for cron settings.

On 8/5/05, A Maynes <andrew at milords.com> wrote:
> I'm not too fmailiar with shell which part would I put in the .sh file?
> 
> Could you point me to a shell tutorial for this setup please?
> 
> Would I need to have gz installed?
> 
> Andrew
> 
> 
> > -----Original Message-----
> > From: Dan McCullough [mailto:dan.mccullough at gmail.com]
> > Sent: 05 August 2005 15:02
> > To: thelist at lists.evolt.org
> > Subject: Re: [thelist] MySQL Backup Statement
> >
> >
> > you could so a simple shell script and cron it.
> >
> >
> > #!/bin/sh
> > #backup.sh
> >
> > date=`date -I`
> > rm -f /var/backup/dbname-bak-*.sql.gz
> > /opt/mysql/bin/mysqldump --opt --quote-names -u <user> -p<pass> dbname
> > | gzip > /var/backup/dbname-bak-$date.sql.gz
> >
> >
> >
> > On 8/5/05, A Maynes <andrew at milords.com> wrote:
> > > I need to run a simple MySQL Backup statement without
> > causing too much
> > > strain on the server what would be the best method?
> > >
> > > I am thinking about running a cron to run a PHP script which simply
> > > dumbs the backup file in a DIR on a daily basis?
> > >
> > > Anyone have a pointer to the PHP code please
> > >
> > > Andrew
> > >
> > > --
> > >
> > > * * Please support the community that supports you.  * *
> > > http://evolt.org/help_support_evolt/
> > >
> > > For unsubscribe and other options, including the Tip Harvester and
> > > archives of thelist go to: http://lists.evolt.org Workers
> > of the Web,
> > > evolt !
> > >
> > --
> >
> > * * Please support the community that supports you.  * *
> http://evolt.org/help_support_evolt/
> 
> For unsubscribe and other options, including the Tip Harvester
> and archives of thelist go to: http://lists.evolt.org
> Workers of the Web, evolt !
> 
> 
>


More information about the thelist mailing list