Automatic MySQL backupFollow @ggarron
Backups are one of the most important tasks a Linux System Administrator has to perform.
In information technology, a backup or the process of backing up refers to making copies of data so that these additional copies may be used to restore the original after a data loss event. These additional copies are typically called "backups." The verb is back up in two words, whereas the noun is backup (often used like an adjective in compound nouns).
Backups are useful primarily for two purposes. The first is to restore a state following a disaster (called disaster recovery). The second is to restore small numbers of files after they have been accidentally deleted or corrupted. Data loss is also very common. 66% of internet users have suffered from serious data loss.
Since a backup system contains at least one copy of all data worth saving, the data storage requirements are considerable. Organizing this storage space and managing the backup process is a complicated undertaking. A data repository model can be used to provide structure to the storage. In the modern era of computing there are many different types of data storage devices that are useful for making backups. There are also many different ways in which these devices can be arranged to provide geographic redundancy, data security, and portability.
So, backups of MySQL databases are also very important, and therefore the best way to do them, is automatically, and daily if possible, you write a cronjob, with a simple code using mysqldump backup but you can also use AutoMySQLBackUp, In the project moves or stops and you can not find in any more, I have a copy here of version 2.5, dowload from here.
Open the file, and you will find it self explicative, and is really easy to use, just do this, as minimum settings.
# 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="/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. # - quiet : Only send logs if an error occurs to the MAILADDR. MAILCONTENT="stdout" # Set the maximum allowed email size in k. (4000 = approx 5MB email [see docs]) MAXATTSIZE="4000" # Email Address to send mail to? (email@example.com) MAILADDR="firstname.lastname@example.org"
Be sure to change the username/password you normally use to access the databases you want to back, or create another user just for this task, (The user must have at least select privileges to the databases).
Be sure to have gzip installed, so the databases backups can be compressed, then change DBNAMES to the databases names you need to backup, with that data, is enough you can copy the scrip to
/etc/cron.daily directory, make it belong to root, and give it execution permissions.
It will create daily backups, which will rotate, and then create weekly and monthly versions of the backups.
I recommend you to download from time to time the backups to any local disk, so you are double protected.