Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

I would like to rsync some HTML files to a webserver that are in production form. To get them in production form I have to trivially insert a ".production" string in a script tag. I can do this with this sed command:

sed 's/steal\.js/steal\.production\.js/g' */*.html

I know I can sed -i inplace and rysync those files then sed -i them back when I'm done, but I'd like to be able to do something like rsync standard out to a destination file on the remote machine. This way I wouldn't ever need to worry about corrupting my html files by canceling the script in mid transfer.

Any recommendations on how to approach this?

share|improve this question

2 Answers 2

If you've got a little spare disk space (it's cheap these days, right?), you could do a local rsync from your development tree to a second copy of the project -- a "staging" tree -- on your development box. Then perform whatever production modifications you need on the staging tree, and do the "real" rsync from the staging tree to the production server.

You can keep the staging tree around for extra deployment speed, or delete it afterwards to free up space; it's up to you.

Or, you could keep the staging tree on the production server instead. In this case, you can do just one rsync, make your changes, then do a few quick directory renames so that the staging tree is now the production tree, and the old production tree is now the staging tree. This way you never have a partially updated site in production.

share|improve this answer

I would suggest that having to access different file names on devel and production boxes is a hack you should consider removing.

  • You could use version control to keep a devel and a production branch of the same project. Keep merging the devel into your production branch but use your little script to keep the code in production state before commiting that branch. Use your server to checkout the production branch, or only rsync that one across.
  • You could have a bit of server side code decide which filename to use: if (hostname = productionserver) ...
  • You could use a server side redirect to serve up different files under the same request url based on hostname or some sort of tag file inside your project.
share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.