If you care about the data being stored on your Apple computer, then you probably already use Time Machine as a backup solution. But if you're a developer or somebody else using MySQL, then you will soon or later reach the maximum capacity of your backup HDD. Why, just because the transaction logs (usually a file called ibdata) grows day after day and Time Machine seems not to be able to only backup the difference between 2 versions of this file.
I've faced this issue by the past and managed to solve it, but here it is, once again and because I've reinstalled my LAMP stack, my backup HDD is crying again and I decided to make a simple note on the topic.
Well, there are 2 solutions to deal with this problem :
If like me you don't want to ignore it from your automated backup, then just go for the second solution, which is detailed below :
$ mysqldump -uroot -p --all-databases > all_databases.sql
Or if you want to zip it at the same time
$ mysqldump -uroot -p --all-databases | gzip > all_databases.sql.gz
Note : if like me you've created a lot of database on your system, this might be the time to delete some of them...
Check that you backup file has been correctly written on your system
$ ls -lh $ total 1426728 $ -rw-r--r-- 1 alafon staff 697M 12 jui 14:59 all_databases.sql.gz
Note : Also, you should copy the whole MySQL data folder as an other backup
$ sudo cp -R /usr/local/mysql/data /usr/local/mysql/data_old
Many solution to drop your database, so feel free to use your favorite one. From the MySQL CLI tool :
In my case, I'm using a homebrew installation, so that's pretty simple :
$ mysql.server stop
By default, there might not be any MySQL configuration file on your system, so just create it in the default location (/etc/my.cnf), and add the following :
Remember : to know where your data are located, have a look at the datadir variable (mysql -uroot -p -e "show variables;" | grep datadir should help)
$ ls -l /usr/local/var/mysql/ $ ....
$ rm /usr/local/var/mysql/ib*
$ mysql.server start
$ mysql -uroot -p < all_databases.sql
or if you did zip the dump
$ gunzip < all_databases.sql.gz | mysql -uroot -p
Unless you want to keep them during your entire life, you can frequently remove (I'm not talking about ignoring it) the /usr/local/mysql/data folder from the Time Machine viewer (obviously, after a manual MySQL dump...). As far as I'm concerned the purpose of using Time Machine in this case, is not to restore a 6 months old version of your MySQL data, it's just there to deal with a recent crash...blog comments powered by Disqus
Système (1) Réseau (1) VMware vSphere Hypervisor (ESXi) (1) Virtualisation (1) Bootstrap (1) Monitoring (1) multi-lingual (1) ezlupdate (1) phpmyadmin (1) Dedibox (1) Perso (1) Debian (2) Développement (1) PHP (2) Github (1) Blog (1) Pro (1) eZ Publish (4) homebrew (2) Note2self (2) MySQL (1) Time Machine (1) Backup (1) Mac OS X (2)
7 years, roaming in the IT world, working on different project sizes, different project types and using a lot of technologies and solutions that are usually used on LAMP projects.
My last job at eZ Systems (the company behind eZ Publish) as Technical Accounter Manager and Senior Consultant, was very formative since it gave me the opportunity to work for prestigious and high-end customers
I can now operate as a freelance for both customers and IT companies, always keeping in mind everybody's needs.
Get in touch with me using this form .