Question

Removing a volume: steps to move files back to droplet, remove symbolic link and delete volume

Hello -

Short story is my admin is no longer with us and I’m not that familiar with this setup, so appreciate any help.

We have an Ubuntu droplet for our MySql database: db-droplet We have a volume attached to that droplet and our db tables and data live there: /mnt/db-volume-01

I see in our droplet it has a symbolic link to what I assume is the original location where the db was storing the db table data.

/mysql/db_tables -> /var/lib/mysql/db_tables

We no longer need the volume so we’d like to copy back our data from the volume to the droplet, remove the symbolic link and then detach & delete the volume.

Can anyone please provide the necessary steps and commands to do the above? Much appreciated!

Subscribe
Share

Submit an answer
You can type!ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!

These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.

Greetings!

I can kind of get you there a bit, but some pieces are relative and you’ll need to consider how they impact you because they might be just a little wrong. Where I’m failing the most, which may cause me to be wrong, is drawing correlation between /mnt/db-volume-01 and /mysql. If the additional volume is mounted at /mnt/db-volume-01 and the databases are symlinked from /mysql, then I assume the databases are not on the additional volume. So for my purposes here, I’m going to just make an assumption that the databases are at /mnt/db-volume-01/mysql and work accordingly.

Under my assumption, this is what I’d do:

  1. Take a snapshot of the droplet. This is your restore point should anything go wrong.
  2. Run these commands:
service mysql stop && systemctl stop mysql #Covers init and systemd, if one fails no issue.
unlink /var/lib/mysql
cp -R /mnt/db-volume-01/mysql /var/lib
service mysql start && systemctl start mysql
umount /mnt/db-volume-01
  1. Look in /etc/fstab to make sure the volume isn’t listed, remove if it is.

This is mildly dangerous and may fail, restoring droplet backup should undo the failure.

Jarland