I am trying to learn how to do a Ubuntu LVM backup of a MySQL database.
For this test I installed a fresh copy of Ubuntu 12.04.2 LTS on a new box, along with MySQL 5.5. The box has one hard drive. During the Ubuntu installation, I chose the partitioning option "Use entire disk and setup LVM".
Here is the space I have:
root@server2:~# df
Filesystem 1K-blocks Used Available Use% Mounted on
/dev/mapper/server2-root 238088848 1206832 224787760 1% /
udev 996264 4 996260 1% /dev
tmpfs 402324 384 401940 1% /run
none 5120 0 5120 0% /run/lock
none 1005800 0 1005800 0% /run/shm
/dev/sda1 233191 26733 194017 13% /boot
Ubuntu gave me a LVM setup of two logical volumes on one volume group:
root@server2:~# pvs
PV VG Fmt Attr PSize PFree
/dev/sda5 server2 lvm2 a- 232.64g 4.00m
root@server2:~# vgs
VG #PV #LV #SN Attr VSize VFree
server2 1 2 0 wz--n- 232.64g 4.00m
root@server2:~# lvs
LV VG Attr LSize Origin Snap% Move Log Copy% Convert
root server2 -wi-ao 230.68g
swap_1 server2 -wi-ao 1.96g
The database data file is at /var/lib/mysql/:
root@server2:~# mysqladmin variables | grep datadir
| datadir | /var/lib/mysql/
Which is on the logical volume:
root@server2:~# df /var/lib/mysql
Filesystem 1K-blocks Used Available Use% Mounted on
/dev/mapper/server2-root 238088848 1206836 224787756 1% /
There is not much free space left:
root@server2:~# vgdisplay server2 | grep Free
Free PE / Size 1 / 4.00 MiB
And finally I get to my question, in order to make a LVM backup of this MySQL database, will I first have to reduce the size of the logical volume so that there is more space?