• 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Synchronizing .PHP Files on Production and Development Servers?

#1
[eluser]Vik[/eluser]
I've just moved my CI app to its production server, and I'm finalizing a few things before launching the site.

I find that sometimes I edit files directly from the production server, and sometimes I edit files on my local development server. For example, if something's acting differently on the production server than it does locally, I want to edit the files directly from the production server. But if I'm doing a file search across all files for some text, it's far faster to search the local copies of the files.

When I edit a file on one side, I copy them to the other, but it's a hassle, and there's a good chance I might miss a file that needs to be copied.

What strategies and/or software do people use to synchronize files on a production server with those on a local development server, so as to be sure that the files on both sides are always updated to the latest versions/

#2
[eluser]Grahack[/eluser]
There's a load of good ideas in this discussion. I personally use sitecopy and never modify files directly on the server.

#3
[eluser]Phil Sturgeon[/eluser]
Cant stress enough the usefulness of SVN. You dont realise how handy it is until you use it on a few projects, then you wont go back. Even if its only a local repositry, its handy to track your changes, then have a nice full copy.

Simply export it now and then and chuck the whole thing on all the servers, can probably automate that if you got some smarts, but I havent figured it out yet.

And yea... dont edit files directly on the server! >.<

#4
[eluser]tonanbarbarian[/eluser]
Being a linux devote, and using KDE as my desktop I use Krusader
It is a twin panel file browser with built in FTP and can do a file/directory comparison, and it can do it asynchronously
So in the left panel I load the live site via FTP, in the right I load the development site.
I run the comparison tool and it shows me all the files on the right that have changed compared to the left. I can then check individual files to see what the changes were and then decide on a file be file basis if I want to upload.
I believe there is similar features in a windows tool called Midnite Commander or something. Only problem is it does not look, or work quite as well as Krusader (one more reason never to go back to windoze)

We also use CVS (rather than SVN) and while there are tools for CVS that allows you to export the entire site, we always check before overwriting live files because we build the sites for clients and we do allow them to make whatever changes they want, although they almost never change code files thankfully.

#5
[eluser]Jim OHalloran[/eluser]
I'll second thepyromaniac's suggestion... It's Subversion all the way for me. I run both dev and production ciopies as Subversion working copies. Make changes in your working copy.commit to subversion, update the server's working copy. Make changes on the server? No worries, jut commit those to subversion and update your dev copy.

Jim.

#6
[eluser]Grahack[/eluser]
About "twin panel file browsers":
That's what took me too sitecopy for updating source code.
I find it a hassle to browse in one panel, and then have to browse again in the another one (we're lucky there is no third or fourth panel...). What could be a revolution: paralel browsing. Once you reach two related directories (one in each panel), you tick a checkbox and then every move you make in one panel is done in the other.
Dunno if it's been implemented somewhere...

EDIT: Ooops, when trying to reach FireFTP's dev team, I found that it already has it.
[quote author="from FireFTP help pages - - -"]
What is "Keep directories in sync while navigating"?
If you specify both an Initial Local and Initial Remote directory this feature becomes available. Once it's enabled and you've connected to your server - every directory change you make, whether on the local or remote side, will be mirrored by the opposite side. This feature assumes that both sides are similar, if not exactly the same, in content. So, if I have a folder on my remote directory called "blah" and also a directory called "blah" on my local side then when I open the "blah" directory on either side, the opposite side will also open the matching directory. This is particularly useful for web designers who have local and remote copies of their files and who do not wish to have to change directories on both sides when uploading and downloading files. Personally, out of all the features I've created for FireFTP I think this one's my favorite - it's such a time saver - it makes me feel warm and fuzzy inside Smile
[/quote]
Thanks to this discussion to point me this!

#7
[eluser]tonanbarbarian[/eluser]
Krusader has this feature.
If i browser to the application folder on the live site and then the application folder on the local site I can then click the sync-browse button and every move i make on the live is mirrored on the local

but the syncronise directories feature i mentioned before is also able to work recursively
so I can simply go to the root of the site on both live and local and then hit sync directories and it will search through all sub folders finding anything that has changed. I can then choose to sync to the live and all of the changes, including needed deletions will be done.

#8
[eluser]Phil Sturgeon[/eluser]
OK I know im dragging up old posts here, but I have found a perfect solution! I have a working copy on my dev site and the live site. live will be trunk, dev will be the branch I am working on or trunk depending on what I want to test on that enviroment.

It might sound a little nuts, but having SVN working copy on your server means you can easily deploy the new version of the site. Commit your local changes to the repo, then just SSH in and update!

This step-by-step guide will assume SVN binaries are already installed and you have SSH access.

1.) Log in via Putty or Terminal:

Quote:ssh [email protected]

2.) Get to your public_web root. This will probably be something like /home/user/public_html/ but could vary.

Quote:cd /home/user/public_html

3.) Then simply check the repo out.

Quote:svn co http://svn.whatever.com/repo/trunk .

DONT forget the "." at the end, otherwise you will get a folder in your root called trunk. The "." means this folder.

4.) When you look at your web root you will probably now see Internal Server Error 500 and start freaking out. Have no fear, chown is here!

The files you checked out master-less, like a Ronin wandering with no direction. The following command will let them know who's boss and set their owner/group.

Quote:sudo chown -R <username>:<username> ../public_html

What next?
To update your working copy, you can repeat steps 1 and 2 to log back in, then simple type:

Quote:svn update

It's very damn satisfying to watch the entire new site deploy in under 30 seconds, and you can rest assured that you didn't forget a file or delete the wrong thing.

Enjoy!

#9
[eluser]bscott[/eluser]
I consider a version control system a must for all development work.

I develop on a windows machine and my version control system of choice is subversion (TortoiseSVN). The subversion repository is backed up locally and to Amazon S3 using Jungle Disk.

If you are not already using a version control system in conjunction with backups then put it at the top of your to-do list - one day it will save your life.

I use a variety of methods for publishing depending on the situation.

SynchBackSE would be ideal in your situation where you sometimes edit files on your production server and need to synch those changes with your development machine.

Super Flexible File Synchronizer is similar and may also be of interest.

#10
[eluser]Phil Sturgeon[/eluser]
If you you use the same working copy on your local box as your production server then when you out and about you can just make changes, commit and update when you get home. Dont even need SynchBackSE ^_^


Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  


  Theme © 2014 iAndrew  
Powered By MyBB, © 2002-2021 MyBB Group.