Search  
   
Browse by Category
 
Netfirms 24/7 Support .: DATABASE MANAGEMENT .: How do I make a backup copy of a mySQL database?

How do I make a backup copy of a mySQL database?

To make a backup copy of your mySQL database, please follow these steps:

Option A
1. Login to the Members Control Panel at https://controlpanel.netfirms.com
2. Click Hosting
3. Choose Databases
4. Click MySQL
4. For the database you wish to backup, click the corresponding phpMyadmin link
5. Click the database that you wish to backup (eg. d01234567)
6. Click Export
7. Click the appropriate option:
-Structure only
-Structure and data (recommended)
-Data only
8. Click the "Save as File" option
9. Click the "Go" button

Option B
If your database is too large to backup via phpMyAdmin, you may backup the database through an SSH session if your plan supports it (SSH available on Advantage and Business plans):
Your MySQL databases can be administered through an SSH session via command line (especially if you have large sized data to import/export):

First, turn SSH on for your account:

1. Login to the Netfirms Control Panel at https://controlpanel.netfirms.com
2. Click Hosting
3. Click Settings
4. In the SSH section, use the pull-down menu to enable SSH if it's not yet enabled

5. Then find an SSH client such as WinSCP (available for free from http://prdownloads.sourceforge.net/winscp/winscp380.exe?download )

SSH connections can be established with the following login credentials:

Username
Password
Host: ssh.netfirms.com (port 22)

6.
Using Netfirms File Manager or the touch command in SSH, create a file called dbBackupFile.sql. The file may reside anywhere inside your /www folder.

7. To make a backup copy of your mysql database via a SSH session:

%/usr/local/nf/bin/mysqldump -e --force --quick -h mysqlhost -u Username -pPassword DatabseID > dbBackupFile.sql

(You will then be prompted to enter your database password.)

Option C
You may use a PHP or Perl script to backup your MySQL data.

The following sample codes (you can name the file dbBackupFile.php in place it inside your www folder) will create a backup .sql file of your database inside your www folder:

PHP

<?php
$command = "/usr/local/nf/bin/mysqldump -hmysqlhost -uUsername -pPassword dbid > backup.sql";
exec($command,$error);
if ($error) {
echo "Error: ". $error;
}
?>

Perl/CGI

#!/usr/bin/perl
print "Content-type: text/htmlnn";
$cmd=system "/usr/local/nf/bin/mysqldump -uu70459875 -p8c2f28 d60417018 > perldbbackup.mysl";
if ($cmd)
{
print "Error!!!!";
}
else
{print "Sucess!!!!";
}

Option D: SCHEDULING YOUR DATABASE BACKUPS
To create a cron job to schedule your database backups please click here for further instructions.

How helpful was this article to you?


.: Powered by Lore 1.5.6
Visit Netfirms.com Web Hosting | Copyright © 1998 - 2009 Netfirms, Inc. All Rights Reserved.