Backing up and Restoring MySQL with mysqldump

| devops | databases |

I backup and restore databases across servers every few months, but each time I have to resort to reading this very verbose documentation. The steps below are a no fuss way to do this each time.

Backup Server

SSH into the server with the database that you wish to backup run the following command.
mysqldump -u root -p $DB_NAME > $DB_NAME.sql

Copy the File to Destination Server

Using scp, we can securely transfer the backup
scp $DB_NAME.sql $USER@$SERVER:

Restore on Destination Server

SSH into the server with the database that you wish to restore. From the the previous step the backup file should now be located in the root directory.
  1. Create new database
    mysql -u root -p -e 'CREATE DATABASE $DB_NAME'
    
  2. Restore your backup
    mysql -u root -p $DB_NAME < $DB_NAME.sql

Thank you for reading! Share your thoughts with me on bluesky, mastodon, or via email.

Check out some more stuff to read down below.

Most popular posts this month

Recent Favorite Blog Posts

This is a collection of the last 8 posts that I bookmarked.

Articles from blogs I follow around the net

If we do not stop to help each other, what do we become?

Yesterday, I received this email as a response to You Can't Vibe Code Love. It's such a remarkable and powerful statement that I asked permission to share it here, in its entirety, with personal information redacted:Hey Jeff,Hope you and your family are do...

via Coding Horror September 25, 2026

Using an LLM to Automate the Process of Archiving New macOS App Icons

Whenever a new version of macOS drops, I find myself archiving the new app icons for my macOS icon gallery. In the past, the work to do this was a bit tedious. First, I’d find the app in the “Applications” folder (or elsewhere on the Mac), right click and...

via Jim Nielsen’s Blog September 25, 2026

Pluralistic: Itch scratching (25 Sep 2026)

Today's links Itch scratching: Love, care and self-actualization. Hey look at this: Delights to delectate. Object permanence: 9/11 x Viridians; Announcing Wikipedia; Infinite Copyright Mickey; Floppy shoulder bag; Wells Fargo's long sleaze; Corbyn wins Lab...

via Pluralistic: Daily links from Cory Doctorow September 25, 2026

Generated by openring