Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Can I safely remove .BAK files from mysql database?

When I look inside my Drupal 6 database on a Linux machine, I see that it is clutters with a bunch of very big *.BAK files, with names like cache_form-110416043841.BAK. I am wondering if I can safely delete them? And if deleting them is not recommended, what's their use?

like image 393
qliq Avatar asked Apr 30 '11 02:04

qliq


1 Answers

Have a look at your /etc/my.cnf file and you’ll probably see this line:

myisam-recover = BACKUP

Or, if you're using a more recent version of MySQL:

myisam-recover-options = BACKUP

This is an option for the MyISAM storage engine. With recovery enabled, when MySQL starts up if it detects that a MyISAM table crashed or otherwise was not closed properly, it attempts to automatically recover the table. With the BACKUP option, it also creates this .BAK file of a copy of the table before it attempted recovery.

If everything seems to be running fine after a safe margin of time (30 days? YMMV), personally, I’d feel comfortable deleting the older .BAK files*, but if there are a lot of these over a span of time that continues to the present, I would probably try to identify the underlying problem that results in the failure of the tables being properly closed.

  • Related MySQL Documentation

*The age of the BAK file can be determined by a simple stat command or by the timestamp encoded in the file’s name: table-YYMMDDHHMMSS.BAK

like image 126
danorton Avatar answered Nov 11 '22 18:11

danorton