<p>What is the best solution for maintaining backup and revision control on live websites?</p>

<p>As part of my job I work with several live websites. We need an efficient means of maintaining backups of the live folders over time.  Additionally, updating these sites can be a pain, especially if a change happens to break in the live environment for whatever reason.</p>

<p>What would be ideal would be hassle-free source control. I implemented SVN for a while which was great as a semi-solution for backup as well as revision control (easy reversion of temporary or breaking changes) etc.</p>

<p>Unfortunately SVN places .SVN hidden directories everywhere which cause problems, especially when other developers make folder structure changes or copy/move website directories.  I've heard the argument that this is a matter of education etc. but the approach taken by SVN is simply not a practical solution for us.</p>

<p>I am thinking that maybe an incremental backup solution may be better.</p>

<p>Other possibilities include:</p>

<ol>
<li><a href="http://svk.bestpractical.com/view/HomePage" rel="nofollow noreferrer">SVK</a>, which is command-line only which becomes a problem.  Besides, I am unsure on how appropriate this would be.</li>
<li><p><a href="http://www.selenic.com/mercurial/wiki/" rel="nofollow noreferrer">Mercurial</a>, perhaps with some triggers to hide the distributed component which is not required in this case and would be unnecessarily complicated for other developers.  </p>

<p>I experimented briefly with Mercurial but couldn't find a nice way to have the repository seperate and kept constantly in-sync with the live folder working copy. Maybe as a source control solution (making repository and live folder the same place) combined with another backup solution this could be the way to go.  </p>

<p>One downside of Mercurial is that it doesn't place empty folders under source control which is problematic for websites which often have empty folders as placeholder locations for file uploads etc.</p></li>
<li><a href="http://samba.anu.edu.au/rsync/" rel="nofollow noreferrer">Rsync</a>, which I haven't really investigated.</li>
</ol>

<p>I'd really appreciate your advice on the best way to maintain backups of live websites, ideally with an easy means of retrieving past versions quickly.</p>

<p><strong>Answer replies:</strong></p>

<ul>
<li><p><em>@Kibbee</em>: </p>

<ul>
<li><p>It's not so much about education as no familiarity with anything but VSS and a lack of time/effort to learn anything else.  </p></li>
<li><p>The xcopy/7-zip approach sounds reasonable I guess but it would quickly take up a lot of room right?  </p></li>
<li><p>As far as source control, I think I'd like the source control to just say that "this is the state of the folder now, I'll deal with that and if I can't match stuff up that's your fault, I'll just start new histories" rather than fail hard.</p></li>
</ul></li>
<li><p><em>@Steve M</em>: </p>

<ul>
<li>Yeah that's a nicer way of doing it but would require a significant cultural change.  Having said that I very much like this approach. </li>
</ul></li>
<li><p><em>@mk</em>:</p>

<ul>
<li>Nice, I didn't think about using Rsync to deploy. Does this only upload the differences? Overwriting the entire live directory everytime we make a change would be problematic due to site downtime.</li>
</ul></li>
</ul>

<p>I am still curious to see if there are any more traditional options</p>

[{'answer_id': 27298, 'author': 'Steve M', 'author_id': 1693, 'author_profile': 'https://Stackoverflow.com/users/1693', 'pm_score': 3, 'selected': True, 'text': '<p>You can still use SVN, but instead of doing a checkout on your live environment, do an export, that way no .svn directories will be created. The downside, of course, is that no code changes on your live environment can take place. This is a good thing.</p>\n\n<p>As a general rule, code changes on production systems should never be allowed. The change should be made and tested in a development/test/UAT environment, then once confirmed as OK, you can tag that code in SVN with something like RELEASE-x-x-x. Then, on the live system, export the code with that tag.</p>\n'}, {'answer_id': 27299, 'author': 'Kibbee', 'author_id': 1862, 'author_profile': 'https://Stackoverflow.com/users/1862', 'pm_score': 1, 'selected': False, 'text': '<p>Any source control solution you pick is going to have problems if people are moving, deleting, or adding files and not telling the source control system about it.  I\'m not aware of any source control item that could solve this problem.  </p>\n\n<p>In the case where you just can\'t educate the people working on the project[1], then you may just have to go with daily snapshots.   Something as simple as batch file using xcopy to a network drive, and possibly 7-zip on the command line to compress it so it doesn\'t take up too much space would probably be the simplest solution.</p>\n\n<p>[1] I would highly disbelieve this, probably just more a case of people being too stubborn and not willing to learn, or do "extra work".  Nevermind how much time source control could save them when they have to go back to previous versions, or 2 people have edited the same file.</p>\n'}, {'answer_id': 27315, 'author': 'mk.', 'author_id': 1797, 'author_profile': 'https://Stackoverflow.com/users/1797', 'pm_score': 2, 'selected': False, 'text': "<p>We use option 3. Rsync. I wrote a bash script to do this along with some extra checking, but here are the basics of what it does.</p>\n\n<ol>\n<li>Make a tag for pushing to live. </li>\n<li>Run svn export on that tag.</li>\n<li>rsync to live.</li>\n</ol>\n\n<p>So far it has been working out. We don't have to worry about user conflicts or have a separate user for running svn up on the production machine.</p>\n"}, {'answer_id': 35428, 'author': 'cpm', 'author_id': 3674, 'author_profile': 'https://Stackoverflow.com/users/3674', 'pm_score': 1, 'selected': False, 'text': '<p>rsync will only upload the differences. I haven\'t personally used it, but <a href="http://diveintomark.org" rel="nofollow noreferrer">Mark Pilgrim</a> wrote a long time ago about how it even <a href="http://diveintomark.org/archives/2004/05/01/essentials" rel="nofollow noreferrer">handles binary diffs brilliantly</a>.</p>\n\n<p>svn+rsync sounds like a fantastic solution. I\'ll have to try that in the future.</p>\n'}]
['https://Stackoverflow.com/questions/27292', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/364/']