IRedMail/FAQ/Backup

From iRedMail

(Difference between revisions)
Jump to: navigation, search
(Created page with '= Backup MySQL Databases = There's a shell script available for backing up MySQL databases: http://iredmail.googlecode.com/hg/iRedMail/tools/backup_mysql.sh Please read header o…')
Line 4: Line 4:
Please read header of this file carefully before you execute it:
Please read header of this file carefully before you execute it:
<pre>
<pre>
-
 
# Filename: backup_mysql.sh
# Filename: backup_mysql.sh
# Author:  Zhang Huangbin (zhb@iredmail.org)
# Author:  Zhang Huangbin (zhb@iredmail.org)
Line 58: Line 57:
###########################
###########################
-
# DESCRIPTION
+
# DIRECTORY STRUCTURE
###########################
###########################
#
#
#  $BACKUP_ROOTDIR            # Default is /backup
#  $BACKUP_ROOTDIR            # Default is /backup
#      |- mysql/              # Used to store all backed up databases.
#      |- mysql/              # Used to store all backed up databases.
-
#          |- YYYY.MM.DD/     # YEAR.MONTH.DAY
+
#          |- YEAR.MONTH/
-
#               |- DB.YYYY.MONTH.DAY.sql # Backup copy, plain SQL file.
+
#               |- YEAR.MONTH.DAY/
-
#                                         # Note: it will be removed immediately
+
#                   |- DB.YEAR.MONTH.DAY.MIN.HOUR.SECOND.sql
-
#                                         # if you have DELETE_PLAIN_SQL_FILE='YES'.
+
#                              # Backup copy, plain SQL file.
-
#               |- DB.YYYY.MONTH.DAY.sql.bz2   # Backup copy, compressed SQL file.
+
#                               # Note: it will be removed immediately after
 +
#                               # it was compressed with success and
 +
#                              # DELETE_PLAIN_SQL_FILE='YES'
 +
#
 +
#                  |- DB.YEAR.MONTH.DAY.HOUR.MINUTE.SECOND.sql.bz2
 +
#                              # Backup copy, compressed SQL file.
#
#
#      |- logs/
#      |- logs/
-
#          |- YYYY.MM/        # YEAR.MONTH
+
#          |- YEAR.MONTH/
-
#              |- mysql-YYYY.MM.DD.log    # Log file.
+
#              |- mysql-YEAR.MONTH.DAY.MIN.HOUR.SECOND.log    # Log file
#
#
 +
</pre>
</pre>

Revision as of 04:31, 24 September 2010

Backup MySQL Databases

There's a shell script available for backing up MySQL databases: http://iredmail.googlecode.com/hg/iRedMail/tools/backup_mysql.sh

Please read header of this file carefully before you execute it:

# Filename: backup_mysql.sh
# Author:   Zhang Huangbin (zhb@iredmail.org)
# Date:     2007.09.16
# Purpose:  Backup specified mysql databases with command 'mysqldump'.
# License:  This shell script is part of iRedMail project, released under
#           GPL v2.

###########################
# REQUIREMENTS
###########################
#
#   * Required commands:
#       + mysqldump
#       + du
#       + bzip2 or gzip     # If bzip2 is not available, change 'CMD_COMPRESS'
#                           # to use 'gzip'.
#

###########################
# USAGE
###########################
#
#   * It stores all backup copies in directory '/backup' by default, you can
#     change it in variable $BACKUP_ROOTDIR below.
#
#   * Set correct values for below variables:
#
#       BACKUP_ROOTDIR
#       MYSQL_USER
#       MYSQL_PASSWD
#       DATABASES
#       DB_CHARACTER_SET
#       COMPRESS
#       DELETE_PLAIN_SQL_FILE
#
#   * Add crontab job for root user (or whatever user you want):
#
#       # crontab -e -u root
#       1   4   *   *   *   bash /path/to/backup_mysql.sh
#   
#   * Make sure 'crond' service is running, and will start automatically when
#     system startup:
#
#       # ---- On RHEL/CentOS ----
#       # chkconfig --level 345 crond on
#       # /etc/init.d/crond status
#
#       # ---- On Debian/Ubuntu ----
#       # update-rc.d cron defaults
#       # /etc/init.d/cron status
#

###########################
# DIRECTORY STRUCTURE
###########################
#
#   $BACKUP_ROOTDIR             # Default is /backup
#       |- mysql/               # Used to store all backed up databases.
#           |- YEAR.MONTH/
#               |- YEAR.MONTH.DAY/
#                   |- DB.YEAR.MONTH.DAY.MIN.HOUR.SECOND.sql
#                               # Backup copy, plain SQL file.
#                               # Note: it will be removed immediately after
#                               # it was compressed with success and 
#                               # DELETE_PLAIN_SQL_FILE='YES'
#
#                   |- DB.YEAR.MONTH.DAY.HOUR.MINUTE.SECOND.sql.bz2
#                               # Backup copy, compressed SQL file.
#
#       |- logs/
#           |- YEAR.MONTH/
#               |- mysql-YEAR.MONTH.DAY.MIN.HOUR.SECOND.log     # Log file
#

Personal tools