Zen Cart Logo
Forums / General Questions / How can I Duplicate Zen Cart shop directory (same server) ?

How can I Duplicate Zen Cart shop directory (same server) ?

Locked

Views: 4,188

Results 1 to 11 of 11
This thread is locked. New replies are disabled.
25 Sep 2008, 3:25 PM
#1
zcnb avatar

zcnb

Zen Follower

Join Date:
Jun 2008
Posts:
338
Plugin Contributions:
0

How can I Duplicate Zen Cart shop directory (same server) ?

As part of my attempt to devise a store update methodology, with minimal disruption to the live store, I would like to duplicate my Zen Cart directory (currently 'shop') along with its associated database.

Since I am able to SSH into my web host and work from the command line, my first thought was to simply use 'cp':

~/public_html> cp -R shop testshop
But then I realized that if I do only that, the newly created Zen Cart store (testshop) will be using the same MySQL database as the original shop.

Which means that any changes to the database made in one store, will be automatically reflected in the other. This defeats the purpose of my duplicated testshop since I want to use it to test new products, while the real live store is operational and running, without customers being exposed to this.

So, it seems that I need to duplicate not only the Zen Cart directory, but the associated MySQL database as well. I searched the subject and found two excellent articles:

I have installed Zen Cart to a directory. How do I rename or move that directory?

Is it possible to create/build a complete Zen-Cart setup on a test server and then install on a live server?

But while they provide very helpful hints that what I want to accomplish is possible (and some cues about key files that need to be modified properly), they assume the same database name.

My question now is: How do I duplicate Zen Cart's database (with a different name of course)?

I know that my question may be a pure MySQL issue rather than a Zen Cart one, but aside from needing to check for any Zen Cart related "side effects", I am hoping that the answer given here may be helpful to other Zen Cart users who (re)search for an optimal "live update" strategy.

Thanks,
Daniel

25 Sep 2008, 3:33 PM
#2
fairestcape avatar

fairestcape

Totally Zenned

Join Date:
Mar 2008
Location:
Cape Town & London (depends on the season)
Posts:
2,957
Plugin Contributions:
0

Re: How can I Duplicate Zen Cart shop directory (same server) ?

Once you have "cloned" all your files, and have what is a "duplicate" of all your code in a separate directory, you can use phpMyAdmin to make a copy of the database.

When you have a duplicate of the database, all you need do is adjust your configure.php files in the cloned store to point to the new database.

Before you "operate" your cloned store, you will probably need to run FIX CACHE KEY.

This php file can be found in the Free Software Addons.

After you have re-set the cache, your cloned store ought to work independently of your original store.

25 Sep 2008, 5:33 PM
#3
zcnb avatar

zcnb

Zen Follower

Join Date:
Jun 2008
Posts:
338
Plugin Contributions:
0

Re: How can I Duplicate Zen Cart shop directory (same server) ?

fairestcape:

Before you "operate" your cloned store, you will probably need to run FIX CACHE KEY.
Thank you very much for this tip, fairestcape. This is exactly the kind of Zen Cart specific information that I needed and I can't get from a general purpose MySQL newsgroup.

I intend to eventually post in this forum a step-by-step HowTo that describes how to duplicate a Zen Cart store directory, including a duplicate (i.e. not linked) database. I hope that this will help others as much as other posters helped me so far.

In the meanwhile here is a slight (but important) correction to the 'cp' shell command posted above:

~/public_html> cp -Rp shop testshopThis correction will preserve the original store's permissions (important for security). It assume a Linux host.

Also, here is a link to to FIX CACHE KEY add-on you mentioned.

Lastly, here is another useful link that describes how to backup and restore the database, although it seems to me that this not really what you mean by "use phpMyAdmin to make a copy of the database". The reason is that it restores from backup to the exact same database, with the exact same name. Is my observation correct?

If so, I think that what you were referring to by "use phpMyAdmin to make a copy of the database" is the "Copy database to:" in "Operations" tab in phpMyAdmin. Is this correct?

25 Sep 2008, 11:51 PM
#4
zcnb avatar

zcnb

Zen Follower

Join Date:
Jun 2008
Posts:
338
Plugin Contributions:
0

Re: How can I Duplicate Zen Cart shop directory (same server) ?

OK - I am so glad I am testing this before going live...

I find DrByte's fix_cache_key.php incredibly helpful in duplicating the Zen Cart shop directory to testshop. However, I am having problems running it, perhaps because when I created the testshop database, using cPanel, the password in database user's password in:

  • admin/includes/configure.php
  • includes/configure.php
    No longer matches the password I specified for the newly created testshop database.

How do I modify DB_SERVER_PASSWORD in both configure.php to match the password I specified when I created the testshop database?

26 Sep 2008, 1:21 AM
#5
zcnb avatar

zcnb

Zen Follower

Join Date:
Jun 2008
Posts:
338
Plugin Contributions:
0

Re: How can I Duplicate Zen Cart shop directory (same server) ?

zcnb:

How do I modify DB_SERVER_PASSWORD in both configure.php to match the password I specified when I created the testshop database?
OMG - I can't believe it's so simple: the password specified in both configure.php files at the define('DB_SERVER_PASSWORD' line is stored in clear text...

I just tried it and the fix_cache_key.php script worked!

But now, I have a totally different question:

Doesn't storing the database user password in clear text in the configure.php file constitute a potential security hole/risk?

26 Sep 2008, 1:28 AM
#6
fairestcape avatar

fairestcape

Totally Zenned

Join Date:
Mar 2008
Location:
Cape Town & London (depends on the season)
Posts:
2,957
Plugin Contributions:
0

Re: How can I Duplicate Zen Cart shop directory (same server) ?

zcnb:

Doesn't storing the database user password in clear text in the configure.php file constitute a potential security hole/risk?

That's why you MUST chmod the files to at least 644 (or better to 444 which is what I do). If this is not done a warning appears in the browser when you visit the site.
*
(Personal boast: My record for cloning a zenshop is just 11 minutes!)* :smartalec:

26 Sep 2008, 1:40 AM
#7
zcnb avatar

zcnb

Zen Follower

Join Date:
Jun 2008
Posts:
338
Plugin Contributions:
0

Re: How can I Duplicate Zen Cart shop directory (same server) ?

fairestcape:

That's why you MUST chmod the files to at least 644 (or better to 444 which is what I do). If this is not done a warning appears in the browser when you visit the site.
Thank you for quickly addressing my concern. Indeed, I always make sure those files have their permissions set to 444.

Still, 444 (as opposed to 440) means they are world-readable. Is this OK, in terms of security?

fairestcape:

(Personal boast: My record for cloning a zenshop is just 11 minutes!) :smartalec:
I envy you. :blush: When I first started this project, I knew nothing about web technology (and much less about PHP/MySQL ...). I hope that by the time I am done, I will be able clone a zenshop in 111 minutes. :smile:

26 Sep 2008, 4:44 AM
#8
drbyte avatar

drbyte

Sensei

Join Date:
Jan 2004
Posts:
63,513
Plugin Contributions:
176

Re: How can I Duplicate Zen Cart shop directory (same server) ?

The FAQ on copying data to/from an offline testing server, usually a PC, covers the same process, but instructs to use FTP to copy the files, since that's what most people have available to them. Most don't have SSH access let alone the knowledge to use command-line instructions on a Linux server.

Basically the process is this:

  1. Clone the files. Since you're working on the same server and same hosting account, AND you have shell access to your server, using your command-line "cp" approach is fine.

  2. Edit the cloned configure.php files to contain the correct database details for your testing database.

  3. Use phpMyAdmin to export your live database using the FAQ instructions.

  4. Use phpMyAdmin to restore your database backup into the database used for your testing site.

  5. Since you're running on the same server and hosting account, it's unlikely that you'll need to use fix_cache_key.php on your site.

26 Sep 2008, 1:32 PM
#9
zcnb avatar

zcnb

Zen Follower

Join Date:
Jun 2008
Posts:
338
Plugin Contributions:
0

Re: How can I Duplicate Zen Cart shop directory (same server) ?

DrByte, thanks for the duplication process outline you provided here. I intend to post a detailed HowTo ("step-by-step" or a checklist) that may be able to help others in some pitfalls that I went through. It will be Linux (web host) specific, but I believe that it will help many Zen Cart users.

DrByte:

  1. Since you're running on the same server and hosting account, it's unlikely that you'll need to use fix_cache_key.php on your site.
    Actually, I did need to use fix_cache_key.php in my case. In the first run its output was:
    Read DIR_FS_SQL_CACHE from configure.php: /home/myuserid/public_html/testshop/cache
    Found SESSION_WRITE_DIRECTORY in database: /home/myuserid/public_html/shop/cache

Now synchronizing...
Database now contains the following SESSION_WRITE_DIRECTORY:
/home/myuserid/public_html/testshop/cache

Finished.

Thanks again for this helpful script!

9 Oct 2008, 9:54 AM
#10
gayelston avatar

gayelston

New Zenner

Join Date:
Aug 2006
Location:
Wales
Posts:
80
Plugin Contributions:
0

Re: How can I Duplicate Zen Cart shop directory (same server) ?

Hi,
I've sort of cloned my shop, but I have no products in the categories.
Everything seems to be working fine except for that.
I copied my original shop files from my server to my desktop.
Renamed them to the name I wanted them to have on the server, because this is a new site selling part of the inventory of the present shop.
I had tried to do a straight copy over several times before but it just didn't work properly - couldn't see the shop no matter what I did - so I presumed there were some files not pointing to the right place but I was unable to fix it.
This time I did a complete new install, then I copied the renamed old shop, minus the configure files, over the new install on the server.
I then exported the old shop database, renamed it to the correct new shop database name, then imported the renamed database into the new shop's phpmysql place.
Everything works great.
I have the modules working properly and all the categories are there complete with their pictures etc.
Now comes the problem - I have no products in the categories!
No products, no pictures no nothing!
Just the categories themselves, that's all!
Where are the products kept?
When the database was imported it had the right number of queries executed etc, all seemed to be there.
All the files from the old shop were copied into the new shops folder, I even have fckeditor up and working, but no products.
Can you help at all please?
Steer me in the right direction?
Any help would be gratefully received.
Regards

Elston

http://www.artyfactsforcrafts.com
http://www.welshwiccashop.com

10 Oct 2008, 2:02 AM
#11
drbyte avatar

drbyte

Sensei

Join Date:
Jan 2004
Posts:
63,513
Plugin Contributions:
176

Re: How can I Duplicate Zen Cart shop directory (same server) ?

gayelston:

Hi,
I've sort of cloned my shop, but I have no products in the categories.
Everything seems to be working fine except for that.
I copied my original shop files from my server to my desktop.
Renamed them to the name I wanted them to have on the server, because this is a new site selling part of the inventory of the present shop.
I had tried to do a straight copy over several times before but it just didn't work properly - couldn't see the shop no matter what I did - so I presumed there were some files not pointing to the right place but I was unable to fix it.
This time I did a complete new install, then I copied the renamed old shop, minus the configure files, over the new install on the server.
I then exported the old shop database, renamed it to the correct new shop database name, then imported the renamed database into the new shop's phpmysql place.
Everything works great.
I have the modules working properly and all the categories are there complete with their pictures etc.
Now comes the problem - I have no products in the categories!
No products, no pictures no nothing!
Just the categories themselves, that's all!
Where are the products kept?
When the database was imported it had the right number of queries executed etc, all seemed to be there.
All the files from the old shop were copied into the new shops folder, I even have fckeditor up and working, but no products.
Can you help at all please?
Steer me in the right direction?
Any help would be gratefully received.
Regards

Elston

http://www.artyfactsforcrafts.com
http://www.welshwiccashop.com

Posting the same thing in multiple places all over the forum creates disjointed discussions, and leaves topics without any resolution. Please don't do that.
You already started a dedicated thread for the topic. Please keep it there: http://www.zen-cart.com/forum/showthread.php?t=110132