LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software
User Name
Password
Linux - Software This forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.

Notices


Reply
  Search this Thread
Old 03-31-2004, 04:54 AM   #1
markehb
LQ Newbie
 
Registered: Mar 2004
Distribution: mandrake 9.0
Posts: 29

Rep: Reputation: 15
dumping mysql db script with dates


Morning,

Doing mysql db dump on a cron job from a file that has something like:
mysqldump --databases db1 db2 db3 > /var/www/Backup/dbs.txt --opt -p

Which is run once a week.

What i'd like is rather than it overwrite the file everyweek, to do it by date so I get a list of:
31_3_04_dbs.txt
24_3_04_dbs.txt

etc

any ideas?
 
Old 05-04-2004, 03:12 PM   #2
Nnyan
LQ Newbie
 
Registered: Jun 2003
Posts: 6

Rep: Reputation: 0
Here is what I'm using. Format the mydate command to however you like by changing the %X variables.

If you don't want to FTP take that part out or install LFTP or whatever you like. LFTP needs the /usr/local/bin in your path or in the script like I have and exported (otherwise take that out).

--opt adds a bunch of options (--lock-tables, --add-drop-table, --add-locks, etc...)

PLEASE notice the spacing in the -p and -u options in mysqldump and the options inside the bracket in the IF



#! /bin/bash
mydate=$(date +%m%d%Y%l%M%p)
PATH=$PATH:/usr/local/bin
export PATH

/usr/local/mysql/bin/mysqldump --flush-logs --opt -u SQLUSER -pSQLPWD dbname > /dir1/dir2/dir3/backup.sql
cd /dir1/dir2/dir3/
if [ -e backup.sql ]
then
tar -czvf backup-$mydate.tar.gz backup.sql
fi
if [ -e backup-$mydate.tar.gz ]
then
lftp <<EOF
open FTPSERVER
user FTPUSER FTPPWD
pwd
put backup-$mydate.tar.gz
bye
EOF
fi
if [ -e backup-$mydate.tar.gz ]
then rm /dir1/dir2/dir3/backup.sql
fi
 
Old 04-23-2006, 10:11 PM   #3
zamri
Member
 
Registered: May 2004
Location: Malaysia
Distribution: Mandrake,Slackware,RedHat
Posts: 157

Rep: Reputation: 30
how about using ssh (scp?) instead of ftp? anyone know how to do with scp?

Last edited by zamri; 04-24-2006 at 07:12 AM.
 
  


Reply



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

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Backing up MySQL without the dumping jme Linux - Software 8 05-27-2006 12:01 AM
Novell is dumping KDE, so I'll be dumping SuSE KimVette SUSE / openSUSE 10 11-12-2005 08:09 PM
dumping sound gazza Linux - Newbie 0 02-28-2004 12:40 PM
php and mySQL dates before a sudden year go wrong??? Satriani Linux - Software 2 04-29-2003 03:13 AM
Dates and Times in MySQL oulevon General 2 09-13-2001 03:27 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Software

All times are GMT -5. The time now is 01:05 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration