X
X
Dump
Dump one table
mysqldump -u root <dbname> <table> > <table>.dump
Dump (2)
Dump complete database
mysqldump -u root <dbname> > all.dump
Dump with where clause
Example:
mysqldump -u root --where "lang_id=3" custhelp faqs>custhelp.dump
dump.sh
[ Download ]
#!/bin/bash
# Can run on any path :)
DBNAME=foo
thisPATH=/root/software/foo/mysqldump
echo `/bin/date`
# YYYYMMDD:
mydate=`/bin/date +%Y%m%d`
/bin/mkdir $thisPATH/$mydate-all
echo -n "DB Dump all ... "
/usr/bin/mysqldump -u root $DBNAME >$thisPATH/$mydate-all/$DBNAME.dump
echo -n "done at "
echo `/bin/date`
cd $thisPATH
/bin/tar -czf $thisPATH/$mydate-all.tar.gz $mydate-all
/bin/rm -Rf $thisPATH/$mydate-all
ls -lt $thisPATH/*.tar.gz
See also: /know how/linux/shell