• Increase font size
  • Default font size
  • Decrease font size
Tag:mysql

 All MySQL versions from 3.23.32 till 5.0 (except for 4.1.0 and 4.1.1) are fully supported. Please note that the older your MySQL version is, the more limitations you will have to face.
phpMyAdmin may connect to your MySQL server using php's classic MySQL extension as well as the improved MySQL extension (MySQLi) that is available in php 5.0.
Either way, the developers of both extensions recommend to use the classic extension for MySQL 4.0 and below and MySQLi for MySQL 4.1 and newer.
When compiling php, we strongly recommend that you manually link the MySQL extension of your choice to a MySQL client library of at least the same minor version since the one that is bundled with some php distributions is rather old and might cause problems (see FAQ 1.17a). If your webserver is running on a windows system, you might want to try MySQL's Connector/PHP instead of the MySQL / MySQLi extensions that are bundled with the official php Win32 builds. 
MySQL 5.1 is not yet supported.

 

Mysql automatic backup script


#! / bin / bash
# This is a ShellScript For Auto DB Backup
# Powered by aspbiz


# Setting
# Set the database name, database login names, passwords, backup path, log path, data file location, as well as backup
# By default, the backup is tar, can also be mysqldump, mysqldotcopy
# By default, with the root (empty) log mysql database backup to / root / dbxxxxx.tgz
DBName = mysql
DBUser = root
DBPasswd =
BackupPath = / root /
LogFile = / root / db.log
DBPath = / var / lib / mysql /
# BackupMethod = mysqldump
# BackupMethod = mysqlhotcopy
# BackupMethod = tar
# Setting End


NewFile = "$ BackupPath" db $ (date +% y% m% d). Tgz
DumpFile = "$ BackupPath" db $ (date +% y% m% d)
OldFile = "$ BackupPath" db $ (date +% y% m% d - date = '5 days ago '). Tgz

echo "-------------------------------------------">;>; $ LogFile
echo $ (date + "% y-% m-% d% H:% M:% S")>;>; $ LogFile
echo "--------------------------">;>; $ LogFile
# Delete Old File
if [-f $ OldFile]
then
rm-f $ OldFile>;>; $ LogFile 2>; & 1
echo "[$ OldFile] Delete Old File Success!">;>; $ LogFile
else
echo "[$ OldFile] No Old Backup File!">;>; $ LogFile
fi

if [-f $ NewFile]
then
echo "[$ NewFile] The Backup File is exists, Can't Backup!">;>; $ LogFile
else
case $ BackupMethod in
mysqldump)
if [-z $ DBPasswd]
then
mysqldump-u $ DBUser - opt $ DBName>; $ DumpFile
else
mysqldump-u $ DBUser-p $ DBPasswd - opt $ DBName>; $ DumpFile
fi
tar czvf $ NewFile $ DumpFile>;>; $ LogFile 2>; & 1
echo "[$ NewFile] Backup Success!">;>; $ LogFile
rm-rf $ DumpFile
;;
mysqlhotcopy)
rm-rf $ DumpFile
mkdir $ DumpFile
if [-z $ DBPasswd]
then
mysqlhotcopy-u $ DBUser $ DBName $ DumpFile>;>; $ LogFile 2>; & 1
else
mysqlhotcopy-u $ DBUser-p $ DBPasswd $ DBName $ DumpFile >;>;$ LogFile 2>; & 1
fi
tar czvf $ NewFile $ DumpFile>;>; $ LogFile 2>; & 1
echo "[$ NewFile] Backup Success!">;>; $ LogFile
rm-rf $ DumpFile
;;
*)
/ etc / init.d / mysqld stop>; / dev / null 2>; & 1
tar czvf $ NewFile $ DBPath $ DBName>;>; $ LogFile 2>; & 1
/ etc / init.d / mysqld start>; / dev / null 2>; & 1
echo "[$ NewFile] Backup Success!">;>; $ LogFile
;;
esac
fi

echo "-------------------------------------------">;>; $ LogFile
 

 

With mysqldump anyone can write a small shell script and running it from cron, it will achieve an automatic backup solution

AutoMySQLBackup can backup a single database, multiple databases, or all the databases on the server; each database is saved in a separate file that can be compressed (with gzip or bzip2); it will rotate the backups and not keep them filling your hard drive (as normal in the daily backup you will have only the last 7 days of backups, the weekly if enabled will have one for each week, etc.).

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

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

# 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="DB1 DB2 DB3"

# Backup directory location e.g /backups
BACKUPDIR="/var/backup/mysql"


You can also run the script manually:

./automysqlbackup.sh.2.5

You can just dump it in the /etc/cron.daily/ folder and you should be done.  .
Myself I like to place it in /opt and create a symlink to the file (to help with future updates of the script):

ln -s automysqlbackup.sh.2.5 automysqlbackup.shand run it from cron by placing in /etc/crontab something like:

#MySQL Daily backup
45 5   * * *   root    /opt/automysqlbackup.sh >/dev/null 2>&1

Download AutoMySQLBackup

 

A script to take daily, weekly and monthly backups of your MySQL databases using mysqldump. Features - Backup mutiple databases - Single backup file or to a seperate file for each DB - Compress backup files - Backup remote servers - E-mail logs – More


AutoMySQLBackup Script Features

 Backup mutiple MySQL databases with one script. (Now able to backup ALL databases on a server easily. no longer need to specify each database seperately)


 Backup all databases to a single backup file or to a seperate directory and file for each database.


 Automatically compress the backup files to save disk space using either gzip or bzip2 compression.


 Can backup remote MySQL servers to a central server.


 Runs automatically using cron or can be run manually.
 Can e-mail the backup log to any specified e-mail address instead of "root". (Great for hosted websites and databases).

 Can email the compressed database backup files to the specified email address.
 Can specify maximun size backup to email.
 Can be set to run PRE and POST backup commands.
 Choose which day of the week to run weekly backups.

AutoMySQLBackup Download

The AutoMySQLBackup project has now been moved to Sourceforge.net for better maintainence.

http://sourceforge.net/projects/automysqlbackup/

AutoMySQLBackup Requirements

The AutoMySQLBackup script only requires mysqldump (A standard utility provided with the mysql client) and gzip or bzip2 for compression of the backup files.

If you would like to have the log emailed to you then you will need to have permission to execute the "mail" program. If you want the compressed backup files mailed to you then Mutt must be available on the server.
Finally you will need a bash shell and the standard system tools and utilities (all these requirements should be the default on most linux system.)

What AutoMySQLBackup does

Every day AutoMySQLBackup will run (if setup on /etc/cron.daily) and using mysqldump and gzip will dump your specified databases to the /backups/daily directory, it will rotate daily backups weekly so you should never have more than 7 backups in there..

Every Saturday AutoMySQLBackup will again backup the databases you have chosen but they will be placed into /backups/weekly, these will be rotated every 5 weeks so there should never be more than 5 backups in there..

Every 1st of the month AutoMySQLBackup will create a backup of all databases and place them into /backups/monthly. These will never be rotated so it will be up to you to do your own house keeping. I would suggest taking a copy of this offline every month or two so that if you have a hard drive failure you will be able to restore your database..

AutoMySQLBackup Installation

The install is as simple as editing a few variables in the AutoMySQLBackup file. The full setup is documented in the AutoMySQLBackup script file below the variables section..

Here is a quick minimum setup step by step..

1. Download automysqlbackup.sh and place it into your /etc/cron.daily directory or your home directory.

2. Edit (at least) the following lines :-
# Username to access the MySQL server e.g. dbuser
USERNAME=dbuser

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

# List of DBNAMES for Daily/Weekly Backup e.g. "DB1 DB2 DB3"
DBNAMES="DB1 DB2 DB3"

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


3. Make the file executable :- chmod u+rwx

4. Create the following directory./backups


5. That's it.. Now you can run it using the command line "./automysqlbackup.sh" or if it is in /etc/cron.daily it will run each day when cron runs.