Showing results for 
Search instead for 
Did you mean: 

Git and Database versioning

Git and Database versioning

Hi Guys


I am looking to start using git to version some magento 2 sites that we have created, but we also want need to version the database because we dont want to overwrite the sales/customer or any other data that we want to keep on the production side.


so my 1st question is what files/directories should i put in the .gitignore and exclude from putting in the repository. 


secondly how do we go about the database as we cant just take a dump of the dev database and import on the staging or production server?


Hope this makes sense


Thanks in advanced



Re: Git and Database versioning

Hi Paul,



Regarding your two questions:


1- Here you an find the .gitignore file for Magento 2:















2- Backing up a database on a regular basis is really simple. The only thing you have to do is creating a shell script that runs the following commands on your development server:


mysqldump -u<username> -p<password> <database-name> 

In addition to that example, you have to add the shell commands to move the database dump to the remote staging/produciton server. Finally, you should create a cron job to run the script on a regular basis.

If my answer was useful, please give "Kudos" to this post.
If my answer helps you to resolve the problem, click on "Accept as Solution".