Total Posts: 3
I was recently searching for how to restore from Magento’s backup tool (Admin > System > Tools > Backups), but couldn’t find the answer in the forum. Here’s the solution that worked for me. (Caveat: I don’t accept any responsibility whatsoever for your site. If you don’t feel comfortable doing the following and screw up your site, don’t blame me.)
First of all, any time you use Magento to make a backup, it creates a .gz backup file (a type of compressed file) in /var/backups/ . If you’re like me, maybe it took a while to find out where it was storing them.
Secondly, you have two options for restoring your backup. You don’t need to empty out your current database before doing either of these as they will overwrite everything.
Option 1) This option is much easier, but will only work if your database is relatively small (like 2MB or less).
- Use an FTP program to download the .gz back up from /var/backups/ . If you have more than one backup, you’ll have to look at the create dates and guess which one is the one you want.
- Login to phpMyAdmin
- Navigate to store’s database
- Click the Import tab
- Click the Browse button, find your .gz file on your computer, and hit Go.
- Note: phpMyAdmin has limits on the size of the database you can upload, so your database must be pretty small (like 2MB or less). If you have 50,000+ items and a 50MB database like I had, you’re going to have to look at option 2. (Alternatively, I’ve heard you can get fancy with changing limits in .ini files, but I didn’t go that route.)
- Now, looking at old posts from 2009 and before, I’ve seen people say that you need to add several lines of code at the beginning of your database file to preserve foreign key constraints. I’m not sure if this is still true, but I’ve backed up and restored my database a couple different ways and haven’t run into this problem.
- And that’s it. Navigate to your site, and hopefully, it should have worked - at least it did for me.
Option 2) If you have a large database and shell access (SSH), here’s another option. I had to do this because phpMyAdmin was imposing a 2MB limit on me. (Note: you probably do not have access to SSH if you only have cheap hosting.)
- Login to your SSH program
- Navigate to the var/backups folder in your Magento installation. (If you don’t know how to do this, you really need to learn SSH and maybe find a SSH commands cheat sheet.)
- Execute the following line. Use it exactly as I’ve written here, except substitute each [stuff] (including the [ and ] ) with your own info.
gunzip < [yourBackUpDB].gz| mysql -u[username] -p[password] [mySQLDataBase]
- If you can’t get that to work, contact your hosting provider. They provided me with this code and it worked perfectly for me.
Both of these worked for me. Also, I was able to use these solutions to duplicate a database, say for example, from a development to a production environment. (Although this is a completely separate topic that requires changing some values in your local.xml file and also 2 fields in your database.)
If you want more info on backing up Magento, here’s a good blog post I found:
Best of luck. I hope this was helpful.