Re: backup mysql
| From: | steve | Date: | Fri, 03 Jan 2003 18:44:26 +0000 |
| Subject: | Re: backup mysql | ||
| References: | 1 | Groups: | php.general.es |
| Request: | Send a blank email to general-es+get-30866@lists.php.net to get a copy of this message | ||
hey nicolás,
aquí tienes un script de unix que me ha servido muy bien.
lo utilizo de un cronjob:
0 0,4,8,12,16,20 * * * /path/to/script/mysql_dump.sh username password > /dev/null 2>&1
fins ara,
steve
#!/bin/sh
########################################################################################################
#
# mysql_dump.sh
# author: steven kirk (steve at gruntle.com)
#
# Dumps specific tables in a database (defaults to foo_db)
#
# http://www.mysql.com/documentation/mysql/bychapter/manual_MySQL_Database_Administration.html#mysqldump
# regarding more options for the mysqldump command.
#
# see below for a description of all the flags we currently use.
#
########################################################################################################
if [ $# != 2 ]
then
echo Usage: $0 [username] [password]
exit 2
else
DATE=date '+%Y%m%d%H%M%S'
export DATE
DUMPFILE=/path/to/backup/directory/$DATE.sql
export DUMPFILE
DATABASE=foo_db
export DATABASE
# main application tables
MAIN_TABLES="person place thing animal mineral"
echo working . . . .
/path/to/mysql/bin/mysqldump -u$1 -p$2 --add-locks --no-create-info --complete-insert --extended-insert --lock-tables $DATABASE $MAIN_TABLES > $DUMPFILE
/bin/gzip $DUMPFILE
echo Archived database $DATABASE
echo Main tables: $MAIN_TABLES
echo dump file $DUMPFILE created at date
echo Done.
fi
# --add-locks
# Add LOCK TABLES before and UNLOCK TABLE after each table dump. (To get faster inserts into MySQL.)
#
# -c, --complete-insert
# Use complete insert statements (with column names).
#
# -e, --extended-insert
# Use the new multiline INSERT syntax. (Gives more compact and faster inserts statements.)
#
# -l, --lock-tables.
# Lock all tables before starting the dump. The tables are locked with READ LOCAL to allow concurrent
# inserts in the case of MyISAM tables. Please note that when dumping multiple databases, --lock-tables
# will lock tables for each database separately. So using this option will not guarantee your tables will
# be logically consistent between databases. Tables in different databases may be dumped in completely
# different states.
#
# -t, --no-create-info
# Dont write table creation information (the CREATE TABLE statement).
#
# : # -u user_name, --user=user_name
# The MySQL user name to use when connecting to the server. The default value is your Unix login name.
At 14:43 03.01.2003 -0300, Nicolás Farante wrote:
Hola a todos, soy nuevo en la lista y estoy empezando a disfrutarla. Lo que me gustaría saber es si alguien conoce alguna herramienta para hacer backup de las bases de mysql. Eso es todo. Un abrazo. Nicolás Farante