ViArt - PHP Shopping Cart
Select your currency:
American DollarBritish Pound
2.4.1. Backing up
Prev Index Next
It is highly recommended that you make regular backups of your ViArt Shop Database. This will protect you if you should ever suffer data loss due to hard disk crash, server problems or if you simply wish to revert to a previous state before changes were made. Also it is advisable to back up your data before upgrading ViArt e-commerce system.


Back Up the Database (Dumping data)

Note: You are supposed to use a mySQL database.

You can make a backup of your MySQL database using the 'mysqldump' program distributed with MySQL or, if you have phpMyAdmin installed you can run a backup dump very easily from its web console.

The command line for instruction for dumping data from the MySQL would be:

[mysql dir]/bin/mysqldump -u user_name -ppassword database_name > /path/viartdb_backup.sql



Example command:
c:\wamp\mysql\bin\mysqldump -u user_name -p viartdb > viartdb_backup.sql

This will create an SQL text output file: viartdb_backup.sql containing a complete dump of your database. You can import it later.


Restoring a Database Backup

mysql -u user_name -p viartdb < viartdb_backup.sql

SQL isn't the only output format you can save your MySQL databases in. The mysqldump program also lets you save records in a variety of different formats, including CSV or even your own custom delimiters.

To export in a different format you need to add the --fields-terminated-by argument to the mysqldump command line:

$ mysqldump -u root -ppassword --no-create-info --tab=/tmp --fields-terminated-by=',' viartdb

mysqldump will now generate in directory /tmp a separate file for every table from database viartdb with each field separated by a comma.

If you'd like a custom line-terminator, you can also use the --lines-terminated-by argument to mark each line with a particular delimiter.

Note: As ViArt Shop works with CSV format by default, it is recommended to use this format.


Importing Different Formats

You can also import in different formats. For example, if you had a tab-separated file containing table records, like this:

1 DHDU 2589 77.56
2 YHOO 3200 45.65
3 WMT 100 53.29

You could then use the mysqlimport tool to read the data into a MySQL database, like this:

$ mysqlimport -u root -ppassword --fields-terminated-by='\t' viartdb /tmp/portfolio.txt

Note: The base name of the source file determines the table into which the data is inserted. As part of your backup regimen, always keep at least two copies of each backup set (each one in a different location, preferable on a different physical drive).


Just in case

Hopefully, you won't ever have to restore a crashed database from your backups. But you'll sleep much easier knowing you have the tools to do it efficiently and with minimal inconvenience to your users if the worst should ever happen.

Read more about dumping MySQL databases and the various options for outputting in different formats (CSV, etc) at http://www.mysql.org/.
Prev Index Next
ViArt - PHP Shopping Cart