I have a strange problem when making a backup of my mysql databases. In order to do so I have a 2TB external hard disk mounted when needed under /backup.
Before making the backup I stop mysql (with /etc/rc.d/mysqld stop) and use rsync to copy all the data to the external hard disk.
As soon as the copy is done I start mysql again (/etc/rc.d/mysld start). The whole copy process takes about 20 minutes (all databases are ~60GB).
But... when I try to umount the backup unit I get
root@slackserver:/# umount /backup0 umount: /backup0: device is busy umount: /backup0: device is busy
And when looking who is keeping the device busy (backup0 = /dev/sdf1):
root@slackserver:/# fuser -m /dev/sdf1 /dev/sdf1: 22420c root@slackserver:/# ps auxw | grep 22420 root 5630 0.0 0.0 2056 644 pts/1 R+ 17:03 0:00 grep 22420 root 22420 0.0 0.0 2760 1376 pts/0 S 11:13 0:00 /bin/sh /usr/bin/mysqld_safe --datadir=/var/lib/mysql --sql-mode=ansi --pid-file=/var/run/mysql/mysql.pid
The only way to umount the backup unit is to so before restarting mysqld.
But why is mysql keeping the device busy. All other hard disks are not "locked" by mysql. Does mysql see the data on the backup drive and recognize it as mysql databases?
As you can see, the datadir is set to /var/lib//mysql and that is (on my system):
/dev/mapper/vg2-sql on /var/lib/mysql type xfs (rw) That is part of a software raid 5 with lvm 2 (device /sd[bcde]1).
What is going on here?