Question

How to use Backup database (mysqldump) in recovery environment?

I booted from Recovery ISO, opened recovery console and ran command

mysqldump -u username -p database_name > data-dump.sql

Output

bash: mysqldump: command not found

I tried to find out but mysql was not installed, then I proceeded to install it.

sudo apt update
sudo apt install mysql-server

But the results returned

No space left on device

so i can’t install mysql on recovery environment, so i can’t create database backup via mysqldump command. What should I do, when droplet is down


Submit an answer


This textbox defaults to using Markdown to format your answer.

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

Sign In or Sign Up to Answer

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.

alexdo
Site Moderator
Site Moderator badge
February 17, 2025

Heya, @3a956ebeda09409f879334ecda13c0

What you can try is to copy the /var/lib/mysql data to your local machine instead of trying to install ‘mysql’ during recovery.

  1. Identify the disk that contains your data:
lsblk

You should see something like:

vda     250G ├─vda1  250G  /
  • If your data is on vda1, mount it:
mkdir /mnt/recovery mount /dev/vda1 /mnt/recovery
  1. Navigate to the MySQL data directory:
ls /mnt/recovery/var/lib/mysql

You should see folders corresponding to your databases.

  1. Create a backup folder in your recovery disk:
mkdir -p /mnt/recovery/root/mysql-backup
  1. Copy the raw MySQL database files:
cp -r /mnt/recovery/var/lib/mysql /mnt/recovery/root/mysql-backup/

Now, you need to download the database backup before reinstalling the Droplet.

  1. Enable SSH in Recovery Mode
  • Set a password for root:
passwd root
  • Start the SSH service:
service ssh start
  • Get your Recovery Mode IP Address:
ip a
  1. Download the Backup via SCP from your local machine:
scp -r root@<RECOVERY_IP>:/mnt/recovery/root/mysql-backup/ .

Once you have backed up your MySQL data, rebuild your Droplet and restore the database.

Hope that this helps!

Try DigitalOcean for free

Click below to sign up and get $200 of credit to try our products over 60 days!

Sign up

Become a contributor for community

Get paid to write technical tutorials and select a tech-focused charity to receive a matching donation.

DigitalOcean Documentation

Full documentation for every DigitalOcean product.

Resources for startups and SMBs

The Wave has everything you need to know about building a business, from raising funding to marketing your product.

Get our newsletter

Stay up to date by signing up for DigitalOcean’s Infrastructure as a Newsletter.

New accounts only. By submitting your email you agree to our Privacy Policy

The developer cloud

Scale up as you grow — whether you're running one virtual machine or ten thousand.

Get started for free

Sign up and get $200 in credit for your first 60 days with DigitalOcean.*

*This promotional offer applies to new accounts only.