开发者

How to do version control via ftp?

I have a web dev. client using a shared host that doesn't allow shell access, and thus no access to SVN, Git, etc. I've tried to convince him to move to one of the many cheap options that allow it, but he won't do it. If I use version control on my staging server开发者_如何转开发, are there any tools that will allow me to replicate the changes to production via ftp? Locally I have both mac & windows, the staging server is linux, so something that works on any of those platforms....


Using your Linux staging server you could keep a separate checked out copy that you use specifically for that host and then use a utility to mirror that directory with the host server.

LFTP is useful for this kind of thing. Its available for most Linux distributions and includes a 'mirror' function:

Mirror specified source directory to local target directory. If target directory ends with a slash, the source base name is appended to target directory name. Source and/or target can be URLs pointing to directories.


Some kind of ftp mirror software is what you need. Not tested it but a quick search gave me this Java application. You could run that over your up-to-date checked out repository.


Good thing for keeping SVN repo and FTP copy in sync is svn2web. May I suggest creating separate branch for production copy and do merges to that branch for uploading to production server.


You probably need to write a batch file that is able to

  1. Export the SVN repository
  2. Upload the exported files to your Linux server via FTP


Short of finding / implementing some FUSE based CoW file system that supports immutable versions .. I'd just find another (more developer friendly) host. As far as I know, no FTP server supports this natively, nor can I think of any elegant means of putting it in place with script hackery.

I could be wrong.


This question (and answer) really helped me just now as I implemented version control via gitolite on a separate server and lftp.

Here’s what I did:

  1. Set up gitolite on my ubuntu staging server
    1. created base repo (i.e. foo.git) on staging server
    2. cloned foo.git into working directory on staging server
    3. cloned foo.git into working directory on local development machine
  2. Developed locally
  3. Pushed changes to foo.git repo on staging server
  4. On staging server, logged into working directory, and pulled in changes from foo.git
  5. lftp-ed into shared host (like you mention above)
  6. Once in shared host, ran: mirror -R --only-newer --delete --parallel=10 /source/directory/ /target/directory

Notes on the mirror command options:

  • -R - this pushes the source/directory to the target/directory. (mirror pulls in from target to source without this, think reverse)
  • —only-newer - without this option, even if you only changed one file, the mirror command will send all the files in the source directory over to the target directory. with this option only the changed (newer) files are transferred over the wire.
  • —delete - deletes files that are no longer in the source directory but still in the target directory. one of my pushes involved deleting expired assets. without this option, the same files would have stayed put on my shared host after executing the mirror command.
  • —parallel=10 - transfers 10 files at once (instead of 1 by default). this made the process much faster

While this is what worked for me, I’m sure there are ways to improve on this. I was grateful for this question and thought i’d share my experience.


Rsync will do this over an FTP connection. You probably already have it installed if you’re on a Unix-like system.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜