MySQL backup

Andreyka
На сайте с 19.02.2005
Offline
822
#51

А чего про них говорить? Плати и юзай.

Не стоит плодить сущности без необходимости
Pandabeer
На сайте с 13.07.2007
Offline
138
#52

Raistlin, почитайте, как работает LVM, механизм Copy on Write, и не позорьтесь.

По сабжу: я пользуюсь софтом ZRM for MySQL, из бесплатных решений - лучшее, что видел.

sappi
На сайте с 11.11.2009
Offline
28
#53

Скриптик для backup`а mysql баз на email или ftp. Может чем поможет/спасет.

Понятия:

db_name - название сохраняемой базы данных.

backupdir - папка на сервере для сохранения локальной копии файла.
user_name - mysql логин (обычно root).
pass_here - mysql пароль.

В cron вбиваете и по скрипту backup или кладется на ftp или на email отсылается.

Я лично использую данный скрипт как запасной вариант.


# This script will backup one or more mySQL databases
# and then optionally email them and/or FTP them
# This script will create a different backup file for each database by day of the week
# i.e. 1-dbname1.sql.gz for database=dbname1 on Monday (day=1)
# This is a trick so that you never have more than 7 days worth of backups on your FTP server.
# as the weeks rotate, the files from the same day of the prev week are overwritten.
############################################################
#===> site-specific variables - customize for your site
# List all of the MySQL databases that you want to backup in here,
# each seperated by a space
#
databases="db_name"
#
# Directory where you want the backup files to be placed
#
backupdir=/home/username/backup
#
# MySQL dump command, use the full path name here
#
mysqldumpcmd=/usr/bin/mysqldump
#
# MySQL Username and password
#
userpassword=" --user=user_name --password=pass_here"
#
# MySQL dump options
#
dumpoptions=" --quick --add-drop-table --add-locks --extended-insert --lock-tables"
#
# Unix Commands
#
gzip=/bin/gzip
uuencode=/usr/bin/uuencode
mail=/bin/mail
#
# Send Backup? Would you like the backup emailed to you?
# Set to "y" if you do
#
sendbackup="n"
subject="Backup is done"
mailto="email@domain.tld"
#
#===> site-specific variables for FTP Use FQDN or IP
#
ftpbackup="y"
ftpserver="ftp.domain.tld"
ftpuser="ftp_username"
ftppasswd="ftp_pass"
#
# If you are keeping the backups in a subdir to your FTP root
#
ftpdir="/"
#===> END site-specific variables - customize for your site
############################################################
# Get the Day of the Week (0-6)
# This allows to save one backup for each day of the week
# Just alter the date command if you want to use a timestamp
DOW=`date +%w`
#
# Create our backup directory if not already there
#
mkdir -p ${backupdir}
if [ ! -d ${backupdir} ]
then
echo "Not a directory: ${backupdir}"
exit 1
fi
#
# Dump all of our databases
#
echo "Dumping MySQL Databases"
for database in $databases
do
$mysqldumpcmd $userpassword $dumpoptions $database > ${backupdir}/${DOW}-${database}.sql
done
#
# Compress all of our backup files
#
echo "Compressing Dump Files"
for database in $databases
do
rm -f ${backupdir}/${DOW}-${database}.sql.gz
$gzip ${backupdir}/${DOW}-${database}.sql
done
#
# Send the backups via email
#
if [ $sendbackup = "y" ]
then
for database in $databases
do
$uuencode ${backupdir}/${DOW}-${database}.sql.gz > ${backupdir}/${DOW}-${database}.sql.gz.uu
$mail -s "$subject : $database" $mailto < ${backupdir}/${DOW}-${database}.sql.gz.uu
done
fi
#
# FTP it to the off-site server
#
echo "FTP file to $ftpserver FTP server"
if [ $ftpbackup = "y" ]
then
for database in $databases
do
echo "==> ${backupdir}/${DOW}-${database}.sql.gz"
ftp -n $ftpserver <<EOF
user $ftpuser $ftppasswd
bin
prompt
cd $ftpdir
lcd ${backupdir}
put ${DOW}-${database}.sql.gz
quit
EOF
done
fi
#
# And we're done
#
ls -l ${backupdir}
echo "Dump Complete!"
exit

Оригинал: Автоматическое_сохранение_баз_данных

sappi добавил 10.02.2010 в 02:02

+ еще один вариант.

http://dev.mysql.com/doc/refman/5.0/en/mysqlhotcopy.html

К этому всему тоже есть скриптик. Ссылка на статью: MySQL_backups_с_помощью_mysqlhotcopy

Авторизуйтесь или зарегистрируйтесь, чтобы оставить комментарий