I've enjoyed Homestead for years and today noticed a very appealing feature that I've never used before.
https://laravel.com/docs/7.x/homestead#database-snapshots says:
Homestead supports freezing the state of MySQL and MariaDB databases and branching between them using Logical MySQL Manager. For example, imagine working on a site with a multi-gigabyte database. You can import the database and take a snapshot. After doing some work and creating some test content locally, you may quickly restore back to the original state.
...
A common workflow looks like the following:
- Import a database into the default
master
lmm branch.- Save a snapshot of the unchanged database using
sudo lmm branch prod-YYYY-MM-DD
.- Modify the database.
- Run
sudo lmm merge prod-YYYY-MM-DD
to undo all changes.- Run
sudo lmm delete <branch>
to delete unneeded branches.
This tool sounds really useful, but I'm having trouble following those instructions. Here is what I've tried and the results:
sudo lmm status
Active snapshot:
Database snapshots:
master
2.70% used by MySQL databases.
sudo lmm branch beforeImports
df: '': No such file or directory
Logical volume name "" is invalid.
Run `lvcreate --help' for more information.
mount: /homestead-vg/beforeImports: special device /dev/homestead-vg/mysql-beforeImports does not exist.
mount: /homestead-vg/beforeImports: special device /dev/homestead-vg/mysql-beforeImports does not exist.
mount: /homestead-vg/prod-YYYY-MM-DD: special device /dev/homestead-vg/mysql-prod-YYYY-MM-DD does not exist.
mount: /homestead-vg/beforeImports: special device /dev/homestead-vg/mysql-beforeImports does not exist.
sudo lmm checkout master
is the currently active database.
Setting /homestead-vg/master as the active database.
rm: cannot remove '/var/lib/mysql': Is a directory
ln: failed to create symbolic link '/var/lib/mysql/master': File exists
I'm using: Windows 10, Vagrant 2.2.7, Virtualbox 6.1.2, Homestead v10.2.0.
What am I doing wrong?
P.S. I looked at https://github.com/Lullabot/lmm/blob/ubuntu-18.04/functions.sh#L5 (which I think is what Homestead is using), and then I ran sudo echo `readlink
/var/lib/mysql`
, and it printed a blank line. But sudo ls -lah /var/lib/mysql
shows lots of files. I clearly don't know what I'm doing and would appreciate any help.
P.P.S. I also see https://github.com/laravel/homestead/issues/1112 but do not understand.
There was a bug that prevented LMM from working with MySQL 8: https://github.com/laravel/homestead/issues/1383