Magento CE – Best Practices for Backing Up a Local Development Site Using MAMP

backupce-1.9.1.0databaseMySQL

I apologize in advance at the low level of this question, but I'm very new to Magento and just beginning my career as a developer.

I have successfully built a local development site on Magento CE 1.9.1 using MAMP. I am the sole developer on this small project.

I was wondering what are the best practices for backing up the local site as I continue to add to and improve it? Not only would I want backups of the site, but in a sense I would also have some version control going on without setting up Git or SVN (which may be a bit of overkill at this time).

A few other quick questions:

  1. If I disable the Apache and MySQL servers would it then be enough to copy the entirety of the MAMP folder and Magento folder to offsite storage periodically?

  2. Do I need to create exports of the database using PHPMyAdmin in addition to step 1?

  3. Should I also create and then download System and Database/Media backups from inside the Magento back-end?

  4. Before backing up the entire Magento store, do I need to disable things such as indexing, the cache, or put the store in maintenance-mode first? What impact (if any) is there when backing up a database that is possibly in use?

  5. Lastly, I installed the Magento folder inside of the MAMP applications folder (at the direction of a well reviewed Magento development book). Are there any other files or folders outside of MAMP that I should be backing up? (The database is located in: Applications\MAMP\db\mysql).

The help is much appreciated! Hopefully other newbies like myself would find the answers to these questions useful.

P.S. I tried beforehand to find the answers to these questions but there seems to be very little out there regarding the fundamentals of how to do backups using best practices.

Best Answer

First off, welcome to the wide world of Magento! Here's a great article with details on different ways to backup Magento that give a good breakdown for a lot of this. The article is geared towards a running server setup but mostly the same rules apply for your local MAMP setup. A lot of pertinent information can be found there.

If I disable the Apache and MySQL servers would it then be enough to copy the entirety of > the MAMP folder and Magento folder to offsite storage periodically?

No need to disable Apache / MySQL. You can backup Magento with everything running. Essentially Magento will either 1) make changes to files or 2) make changes to the database. Most backup methods for the files (drag / drop files to backup, use shell commands like cp or rsync, etc.) will work fine if files are actively being modified such as the var/cache within Magento. The only thing that will happen is maybe at the time of copying the version you have is slightly older because it was updated right after you copied it.

Do I need to create exports of the database using PHPMyAdmin in addition to step 1?

As for MySQL, you should use the mysqldump command (more details in the blog article link above). This will have MySQL do the backup for you so no need to worry about actively using the database. The only concern is that it can add load to the host computer during backup that could slow things down but it shouldn't crash anything. You could also use PHPMyAdmin to do your backup without it crashing / harming anything (again might just slow it down).

Should I also create and then download System and Database/Media backups from inside the >Magento back-end?

Depends. If you're comfortable using command line to move, copy, rsync etc. files then I would skip the Magento backup manager. It can sometimes have issues and be a bit slower. You could use it but not needed in addition to regular backup methods.

Before backing up the entire Magento store, do I need to disable things such as indexing, >the cache, or put the store in maintenance-mode first? What impact (if any) is there when >backing up a database that is possibly in use?

No no and no. You're fine to backup an active running site. The only thing you could do to maybe save yourself a step later would be to either entirely flush the Magento cache storage before backup or just exclude the var/cache/ directory from your backups. It's automatically regenerated upon using Magento either from the Admin or front end.

As for the DB performance, again it can impact performance but that depends entirely on the size of the database and your hardware. If the site is just in dev it's likely a small database (unless you have tens of thousands of products).

Lastly, I installed the Magento folder inside of the MAMP applications folder (at the >direction of a well reviewed Magento development book). Are there any other files or >folders outside of MAMP that I should be backing up? (The database is located in: ?>Applications\MAMP\db\mysql).

I haven't used MAMP much but as for Magento it really consists of 1) the files and 2) the database. Unless it's like some of those goofy installation tools chances are all the Magento files are contained within 1 directory. If that's the case, just making a backup of that directory and then a backup of the database would be enough. Apache configs, tuned mysql settings, etc. are all a different story but with the files and database you could then re-install or setup that Magento site elsewhere (either on your MAMP or deploy to a server, etc.)

And as already stated, GIT is always nice ;)

Related Topic