0item(s)

You have no items in your shopping cart.

Product was successfully added to your shopping cart.

Properly Backup Your Magento

Properly Backup Your Magento

Magento Control Panel Backup

There are several options in the admin panel for backing up a Magento store. You can find them in the “Tools” section of the “System” menu on the main menu bar. There are three types of backup to choose from:

System Backup — This will take all of the files that comprise the Magento store and a dump of the data and package them into a tar archive.

Database and Media Backup — This includes the database and the contents of the media folder, but not other assets like theme files.

Database backup — This does what you’d expect.

One benefit of backing up this way is that Magento allows rollbacks to previous backups, which means that if you make a configuration error or accidentally delete files you can restore the system to its earlier state.

In some cases you’ll want to back up the database and the files separately, and it’s also useful to know how to do a manual backup, so we’ll run through the process of backing up outside of the Magento admin panel.

Please note, you must have a backup of both the files and the database to restore a Magento site. Just copying the files off the server is not enough; the database is essential.

Back Up Files

The best way to back up all of your files (excluding the database) is to connect to your hosting account with FTP or SFTP, and copy the folder that contains all of the Magento files onto a local machine, a remote server, or to a cloud storage service like Amazon’s S3.

Manually Backup The Database

There are several ways to dump a MySQL database: that is, to create a file that contains the SQL instructions necessary to reconstitute the database at a later time.

Hosting companies that use control panels like InterWorx provide access to the database via phpMyAdmin, which is a comprehensive database management tool. To back up, find phpMyAdmin in the hosting control panel and choose “export” from the menu bar. In many cases you can stick with the “Quick” option, but, if you have more than one database in the same MySQL install, for example, choose the “Custom” option and find the relevant database in the drop-down list. Unless you know what you’re doing, leave the other options alone.

Scroll to the bottom of the page, and click “Go”. A dump of the database will be downloaded and you can store it with the files you downloaded earlier or somewhere else.

Alternatively, the database can be dumped from the command line with the command:

mysqldump -h HOST -u USER -p DATABASENAME > FILENAME.sql

Replace the capitalized strings with the relevant information about your database. This will produce the same file as the earlier process, which you should then copy off the server and put somewhere safe.

You should be aware that when you manually dump the database, Magento isn’t given the chance to insert special statements into the file to disable the integrity checking features that it uses. When you try to re-import a database without those statements you’ll generate an error that is similar to:

Cannot add or update a child row: a foreign key constraint fails

To deactivate constraint checking you’ll need to add some SQL statements to the top and bottom of the file. There’s a great guide to restoring a Magento database, including how to deactivate constraint checking on the Magento Wiki.

Don’t wait until you need a backup to make one. Backing up your Magento site should be part of your regular maintenance routine.

Topic: Magento Help

Category: Magento 1 Help

Comments