MySQL’de Otomatik Backup Nasıl Alınır?

Hepimiz bir şekilde mutlaka Mysql database kullanıyoruz. Mysql de databaselerin yedeği almak için belki fazlasıyla yazılım olabilir. Ben size bu işin için kullanabileceğiniz en basit ve stabil yazılımın nasıl kurulum ayarlanabileceğini anlatacağım.

Elimizde debian, ubuntu, redhat gibi kurulmuş kullandığımız işletim sistemimiz üzerinde şu komutu koşuyoruz.

aptitude install automysqlbackup

Komutu koşturduğumuzda gerekli olan bütün bileşenler ile birlikte yazılımı kuracaktır.

Daha Sonra yazılımın ayar dosyasına ulaşıp sistemimize göre ayarlamalar yapacağız. Ayar dosyasına ulaşmak için;

nano /etc/default/automysqlbackup

Komutu koşturduğunuzda karşınıza böyle bir ekran çıkacak;


GNU nano 2.2.2 File: /etc/default/automysqlbackup

 

# By default, the Debian version of automysqlbackup will use:

# mysqldump –defaults-file=/etc/mysql/debian.cnf

# but you might want to overwrite with a specific user & pass.

# To do this, simply edit bellow.

 

# Username to access the MySQL server e.g. dbuser

#USERNAME=`grep user /etc/mysql/debian.cnf | tail -n 1 | cut -d”=” -f2 | awk ‘{print $1}’`

 

# Username to access the MySQL server e.g. password

#PASSWORD=`grep password /etc/mysql/debian.cnf | tail -n 1 | cut -d”=” -f2 | awk ‘{print $1}’`

 

# Host name (or IP address) of MySQL server e.g localhost

DBHOST=localhost

 

# List of DBNAMES for Daily/Weekly Backup e.g. “DB1 DB2 DB3”

# Note that it’s absolutely normal that the db named “mysql” is not in this

# list, as it’s added later by the script. See the MDBNAMES directives below

# in this file (advanced options).

# This is ONLY a convenient default, if you don’t like it, don’t complain

# and write your own.

# The following is a quick hack that will find the names of the databases by

# reading the mysql folder content. Feel free to replace by something else.

# DBNAMES=`find /var/lib/mysql -mindepth 1 -maxdepth 1 -type d | cut -d’/’ -f5 | grep -v ^mysq$

# This one does a list of dbs using a MySQL statement.

DBNAMES=`mysql –defaults-file=/etc/mysql/debian.cnf –execute=”SHOW DATABASES” | awk ‘{print $

 

# Backup directory location e.g /backups

# Folders inside this one will be created (daily, weekly, etc.), and the

# subfolders will be database names. Note that backups will be owned by

# root, with Unix rights 0600.

BACKUPDIR=”/var/lib/automysqlbackup”

 

# Mail setup

# What would you like to be mailed to you?

# – log : send only log file

# – files : send log file and sql files as attachments (see docs)

# – stdout : will simply output the log to the screen if run manually.

# – quiet : Only send logs if an error occurs to the MAILADDR.

MAILCONTENT=”quiet”

 

# Set the maximum allowed email size in k. (4000 = approx 5MB email [see

# docs])

MAXATTSIZE=”4000″

 

# Email Address to send mail to? (user@domain.com)

MAILADDR=”root”

 

# ============================================================

# === ADVANCED OPTIONS ( Read the doc’s below for details )===

#=============================================================

Hiçbir konfigürasyon yapmadan sizin databaselerinizi BACKUPDIR (var/lib/automysqlbackup) altına yedekleyecektir.

Siz burdan diğer ayarları (mailile haber verme, başka bir yere backup,zamanlama gibi ) yapabilrisiniz.

Yazılımı çalıştırmak için “automysqlbackup” komutunu koşturmanız gerekiyor. Malesefki bu komut her seferinde elle çalıştırılmalı ama isterseniz crontab’a ekleyerek otomatik yapabilirsiniz J

ls -l /var/lib/automysqlbackup

Komutu ile oluşturulan backuplara bakabilir,

ls -l /var/lib/automysqlbackup/daily/db_ispconfig/

Bu komutla da dumpları inceleyebilirsiniz.

Bu konuyla ilgili sorularınızı Http://forum.mshowto.org alt kısımda bulunan yorumlar alanını kullanarak sorabilirsiniz.

Referanslar

www.mshowto.org

Yazı gezinmesi

Mobil sürümden çık