Backup/Restore Magento SQL database using SSH

This tutorial explains how to backup and restore a database using secure shell (SSH) as opposed to Cpanel or PHPMyadmin. SSH (Secure Shell) can be used in Windows via 3rd party apps like Putty or in OSX via native Terminal App.

ssh

To backup your database through SSH (create SQL dump):

mysqldump --opt -u user -p dbname > {path}/backup.sql

Replace user with the db username and dbname with the database name. Replace {path} with the path where you want your DB dump to sit. Example:

mysqldump –opt – u root – p magentodatabase > usr/var/backups/aprilbackup.sql

You’ll be prompted for the database password as soon as you run the command. Enter the password and hit enter.

To restore:

mysql -u user -p dbname < {path}/backup.sql

Michael Savin

My name is Michael Savin. I've been contributing to the Internet for over ten years and have been a London based Magento freelancer for the last six.

I build eCommerce websites for varied companies worldwide and enjoy a close relationship with many brands, freelancers and studios. Work aside I enjoy cycling, reading and long walks in sunny days.

Leave a Reply

Your email address will not be published. Required fields are marked *