How to backup and restore your database with SSH
Description: How to backup and restore your database with SSH
In Categories: Miscellanea
- Link to this article: Select All
[url=https://www.phpbb.com/support/docs/en/3.3/kb/article/how-to-backup-and-restore-your-database-with-ssh/]Knowledge Base - How to backup and restore your database with SSH[/url]
How to backup and restore your database with SSH
- Ok, so a lot of people are having trouble backing up and restoring...reasons varying from the query taking longer than the server upload time, corrupted files, improperly split files, etc. Anyway, here is how to do it through SSH.
- First, you need an ssh client. PuTTY is an easy one to use and works well. Search for it on google and download it.
- Under session, put your website name into the host name box. Use port 22, and make sure SSH is selected. Under SSH in the left menu, you may have to select a different protocol. I use 2. Click open.
- Input your site administration username into the shell prompt. It will prompt you for a password. Enter this too. Use the cd command to change directories to where you want your backup to be stored.
To confirm the directory, type "pwd" without the quotes.
Input "mysqldump -u [username] -p --opt [databasename] > [backupfilename.sql]" substituting the correct username for your database, database name, and filename for the backup. It will prompt you for a password. Enter your SQL password. If it returns with a prompt and no errors, you successfully made a backup. - To restore the database, login as usual. Use the cd command to change directories to where your sql backup is stored. Use the ls command to verifty that the file is there and you have the correct name. Type "mysql -u[username] -p[password] [databasename] < [backupfilename.sql]" and press enter. do not put a space between u and your username, or p and your password. If it returns with a prompt, you successfully restored your database.