Taking backup and restore database via SSH :
You can easily take backup of your databases through SSH by firing few commands. You need to login to your accout via SSH client once you get into your account use following command /usr/bin/mysqldump $databasename -u $user -p$password > /path/to/file.sql
Please make sure you put all required info for all $varilables for above command. You can consider an example with username ‘jack’ and you want to backup a databases named ‘jack-phpbb’ which is accessed by user jack_forums and a password of supp0rt. so above command will look like following comand with all required parameters.
/usr/bin/mysqldump jack-phpbb -u jack_forums -psupp0rt > /home/jack/file.dump
In case if you are forget or don’t know the database username or password you can take help you of your MySQL screen of your cPanel to get required information. Make sure you don’t keep any space between passward and -p operator.
Thus you have backup of your database at /home/jack/file.dump which can be restored anytime you want. For some reason you need to restore your backup databases you will have to use following command so that you can restore them
mysql $databasename -u $user -p$password < /path/to/$dump_file
You will have to use all required substitue for $variables for above commands.
Let’s say you have a batabases backup file called backup.sql which is already uploaded under public_html directory and now you need to restore it. so you have account username as ‘jaack’ and you are looking for restoring databases called ‘jack-phpbb’ you will have to modify above command as per this parameters as
mysql jack_phpbb -u $jack_forums -p$supp0rt < /home/jack/public_html/backup.sql
Thus you can easily take and restore backup of databases through SSH using above commands.
Posted under Fantastico Hosting, Reseller Hosting, WHM cpanel Hosting, cPanel account Hosting
This post was written by on April 9, 2008






















