Duplicate Sugar CRM instance for Development

If you have email archiving enabled, you need to disable it before attempting this copy, also disable any special scheduled jobs that you may have.

This copy should be done out of hours to ensure that there is no impact, and if you could shut the Apache server down this would be even better.

The steps that we will follow are:

  • Shut the web server down
  • Copy the Sugar live folder outside the web server path
  • Change the config files
  • Clone the MySQL database
  • Copy the test Sugar folder back into the web servers path
The assumption here is that the folder that SugarCrm is installed in is called crm and the test / devlopment environment will be crmdev. The database is called sugarcrm_pro and sugarcrm_prodev respectively.
sudo su
cd /
mkdir sugarcrm_temp

If you can stop the Apache server

service httpd stop

Copy the crm installation folder in /var/www/html to a new folder name

cp -R /var/www/html/crm /sugarcrm_temp/crmdev

You then need to edit the config.php file and ammend the DB variable to match the new database that will be created in the next steps.

cd /sugarcrm_temp/crmdev
vi config.php

Look for the lines around dbconfig and change the db_name to match the database below.

We now need to create the database in Mysql.

mysql -u username -p -h servername 
create database sugarcrm_prodev;

To ensure that the database has been created

show databases;

if you already have cloned the database you will need to drop the database first.

drop database sugarcrm_prodev;
create database sugarcrm_prodev;

To ensure that the database has been created

show databases;

We then just need to duplicate the database, this is a built in function and can be achieved with mysqldump

The basic syntax is

NOTE that this should all be on a single line, there should be no carriage return or line feed when pasting it into the command line (the wordpress editor also messes around with the — infront or password it should read – – so when copy and pasting make sure there is a single space in between the dashes)

mysqldump -u {source_username} --password={source_password} -h {source_server} {source_db_name} |
 mysql -u {dest_username} --password={dest_password} -h {dest_server} {dest_db_name}

unfortunately I can not give you an example with letting you know my username and passwords but the syntax is pretty easy just ensure that the {dest_db_name} matches the database name from above.

To ensure that you have copied the database correctly we can run a few tests.

mysql -u username -p -h servername 
use sugarcrm_pro;
select count(id) from contacts;

Take a note of the number

use sugarcrm_pro;
select count(id) from contacts;

These should match perhaps the copy will be 1 or 2 less depending on how busy your database, if you shut you web server down these should match exactly.

Once the database has been cloned

cd /sugarcrm_temp
mv crmdev /var/www/html/
cd /var/www/html/
chown -R apache:apache crmdev

You will need to change the apache:apache to match the user and group that runs the web server in your environment.

Remember to restart the schedules and the email archiving  in he live environment.

NOTE the address changes so you will need to re-issue the email address, I created a vcard and then just sent it out to all the user so that they could update the information.

Example of vcard file


Save this as a vcf file and you are good to go


One Comment on “Duplicate Sugar CRM instance for Development”

  1. […] To create a mysql dump there are a few options, output to a sql file that then can be user to create the database or straight to the remote data base. Cloning to a remote database can be found in the Duplicate Sugar CRM instance […]

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s