Mysqlautobackup

Aus Cryptronic
Wechseln zu: Navigation, Suche

Autobackupscript

Auf dieser Seite: Automatisches Backup von MySQL-Datenbanken

Oder der direkt Download: sourceforge


Download via wget nach /root

Nach dem Download konfigurieren:

nano /root/automysqlbackup.sh.2.3
# Username to access the MySQL server e.g. dbuser
USERNAME=root

# Username to access the MySQL server e.g. password
PASSWORD=rootpass

# 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"
DBNAMES="all"

# Backup directory location e.g /backups
BACKUPDIR="/root/backups"

# 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.
MAILCONTENT="log"

# 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="mail@cryptronic.de"

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

# List of DBBNAMES for Monthly Backups.
MDBNAMES="mysql $DBNAMES"

# List of DBNAMES to EXLUCDE if DBNAMES are set to all (must be in " quotes)
DBEXCLUDE=""

# Include CREATE DATABASE in backup?
CREATE_DATABASE=yes

# Separate backup directory and file for each DB? (yes or no)
SEPDIR=yes

# Which day do you want weekly backups? (1 to 7 where 1 is Monday)
DOWEEKLY=6

# Choose Compression type. (gzip or bzip2)
COMP=gzip

# Compress communications between backup server and MySQL server?
COMMCOMP=no

# Command to run before backups (uncomment to use)
#PREBACKUP="/etc/mysql-backup-pre"

Die Rechte für das Skript müssen noch mit chmod auf 777 gesetzt werden, so dass das Skript ausführbar ist:

chmod 700 /root/automysqlbackup.sh.2.3

Dann noch als cronjob einrichten:

bearbeiten der /etc/crontab

#mysqlbackupscript
0  2    * * *   root    /root/automysqlbackup.sh.2.3

anschließend cron neu starten

/etc/init.d/cron restart
Meine Werkzeuge
Namensräume
Varianten
Aktionen
Navigation
Tipps
Werkzeuge