1and1 Help Centre Categories

print article

Backup a MySQL Database Using SSH (Shell)

For 1&1 Linux packages with MySQL

Follow the steps below to backup your MySQL Database and store the backup in your webspace via SSH.

Do you want to make major changes to your website? By backing up your database, you can quickly store your data and import it again when needed.

Step 1
To log in to your server via SSH, etablish a connection from your PC or from your MAC.
Step 2
Once logged in, type the pwd command and press ENTER to display in which folder you are currently. This command will display the entire folder structure. In this example, the current working directory is a joomla subfolder of the webspace.
(uiserver) :u504577533:~/joomla > pwd
/kunden/homepages/11/d256250497/htdocs/joomla
Step 3
Type cd ~ command and press ENTER to change directory to the root of your webspace. The root of your webspace is the htdocs folder. To confirm you are in the htdocs folder, type the pwd command and press ENTER again.
(uiserver) :u504577533:~/joomla > pwd
/kunden/homepages/11/d256250497/htdocs/joomla
(uiserver) :u504577533:~/joomla > cd ~
(uiserver) :u504577533:~ > pwd
/kunden/homepages/11/d256250497/htdocs
Step 4
Now you can create a folder to store all of your MySQL backups in one place. Type mkdir exportedDatabases to make a subfolder in htdocs/ named exportedDatabases/. Enter cd exportedDatabases/ to change directories to the newly created folder.
(uiserver) :u504577533:~/joomla > pwd
/kunden/homepages/11/d256250497/htdocs/joomla
(uiserver) :u504577533:~/joomla > cd ~
(uiserver) :u504577533:~ > pwd
/kunden/homepages/11/d256250497/htdocs
(uiserver) :u504577533:~ > mkdir exportedDatabases/
(uiserver) :u504577533:~ > exportedDatabases/
(uiserver) :u504577533:~/exportedDatabases >
Step 5
Now that you are in the folder where you wish to save the exported database file, you can run the export command. The command will depend on the type of package you have.

For 1&1 WebHosting packages the command will be similar to:

mysqldump --no-create-db=true -h db1111.perfora.net -u dbo111111111 -p db111111111 > 1and1help.com-Joomla-Apr.05.2010.sql

After typing the this command, hit ENTER.You will be prompted for a password. As you enter the password, the characters typed will not display on the screen. Hit Enter when finished.

(uiserver) :u504577533:~/joomla > pwd
/kunden/homepages/11/d256250497/htdocs/joomla
(uiserver) :u504577533:~/joomla > cd ~
(uiserver) :u504577533:~ > pwd
/kunden/homepages/11/d256250497/htdocs
(uiserver) :u504577533:~ > mkdir exportedDatabases/
(uiserver) :u504577533:~ > exportedDatabases/
(uiserver) :u504577533:~/exportedDatabases > mysqldump --no-create-db=true -h db2050.perfora.net -u dbo298362073 -p db298362073 > 1and1help.co.uk-Joomla-Apr.05.2010.sql

For 1&1 Managed Serverpackages the command will be similar to:

mysqldump --no-create-db=true -u dbo111111111 -S /kunden/tmp/mysql5.sock -p db111111111 > 1and1help.co.uk-Joomla-Apr.05.2010.sql

After typing thia command, hit ENTER.You will be prompted for a password. As you enter the password, the characters typed will not display on the screen. Hit Enter when finished.

-S /kunden/tmp/mysql5.sock
This option specifies to use the supplied socket in place of the default one. This is necessary for connecting to MySQL5 databases on Website Server packages.
(uiserver) :u504577533:~/joomla > pwd
/kunden/homepages/11/d256250497/htdocs/joomla
(uiserver) :u504577533:~/joomla > cd ~
(uiserver) :u504577533:~ > pwd
/kunden/homepages/11/d256250497/htdocs
(uiserver) :u504577533:~ > mkdir exportedDatabases/
(uiserver) :u504577533:~ > exportedDatabases/
(uiserver) :u504577533:~/exportedDatabases > mysqldump --no-create-db=true -u dbo298362073 -S /kunden/tmp/mysq15.sock -p db298362073 > 1and1help.co.uk-Joomla-Apr.05.2010.sql
When the command prompt returns, the export is finished. Type
ls -lah
to view the contents of the current directory. You should see your exported file listed along with the filesize.

(uiserver) :u504577533:~/joomla > pwd
/kunden/homepages/11/d256250497/htdocs/joomla
(uiserver) :u504577533:~/joomla > cd ~
(uiserver) :u504577533:~ > pwd
/kunden/homepages/11/d256250497/htdocs
(uiserver) :u504577533:~ > mkdir exportedDatabases/
(uiserver) :u504577533:~ > exportedDatabases/
(uiserver) :u504577533:~/exportedDatabases > mysqldump --no-create-db=true -u dbo298362073 -S /kunden/tmp/mysq15.sock -p db298362073 > 1and1help.co.uk-Joomla-Apr.05.2010.sql
Enter password:
(uiserver) :u50477533:~/exportedDatabases > ls -lah
total 384k
drwxr-xr-x 2 u50477533 ftpusers 49 Apr 5 10:34 .
drwx---r-t 16 u50477533 ftpusers 4.OK Apr 5 10:34 ..
-rw-r--r-- 1 u50477533 ftpusers 377K Apr 5 10:34 1and1help.co.uk-Joomla-Apr.05.2010.sql
(uiserver) :u50477533:~/exportedDatabases >