Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

I am buying 2 dedicated servers (one for live hosting, 1 for staging environment).
Four questions:

  1. How to keep the live server in sync with staging server? Goal is to run the sync everyday but I cant afford any downtime, so can staging mirror production yet production be usable by users during the sync process? And how to automate this process like a cron job maybe?

  2. I need to push files from staging to production, I assume this is done via FTP or how to automate this also from some tool?

  3. For my staging server, how to secure it internally? I have my main domain, ex: www.example.com So on the prod server this URL should be usable by everyone on the internet. On the staging server the same URL should be usable only by the internal people. I cannot use a subdirctory because I have lots of sub-domains/sub directories already as part of the site and I want to preserve the accurate URL structure for proper QA.

  4. I need to use version control for code, so i assume SVN is to be installed on both servers and they can be in sync although I am not sure how to seperate them between environments on SVN?

My DB is MySQL and MagnoDB.

share|improve this question
    
What OS are your servers running? –  Wesley Feb 18 '11 at 2:55
    
I am buying them soon (as soon as i figure out this part) so my OS choice is open. But it will be one of the linux packages - centOS or Ubuntu. –  MKnight Feb 18 '11 at 2:57

1 Answer 1

You'll have to forgive my examples, I'm a Windows sysadmin, but the same tools exist on Unix, I'm sure of it.

How to keep the live server in sync with staging server?

For HTML and peripheral files, this is simple. Just run a sync at a scheduled time each day. I use robocopy, but I believe rysnc will do the same job on *nix.

Goal is to run the sync everyday but I cant afford any downtime, so can staging mirror production yet production be usable by users during the sync process?

Not usually. If you need to do this, then what you actually need are TWO staging systems. One of them is live, and one of them is idle. You always sync to the idle one, and then switch the staging system over to the idle one once the sync is complete, so the idle one becomes live, and the old live one receives the next update.

Of course, this means that all users will be kicked off the system when the servers switch roles. You say they both have to be up 100% of the time, but really, can you afford 1 minute a day to do this? If you do it at say 3am (or another quiet time of the day) then the impact should be minimal.

And how to automate this process like a cron job maybe?

There's no simple answer to this. What we do with Windows and MSSQL is to do a robocopy from the live to the staging to update all the static files, and then do an MSSQL backup/restore over the staging database. This is all scripted and runs once a week, Sunday morning at 1am.

I need to push files from staging to production, I assume this is done via FTP or how to automate this also from some tool?

There are lots and lots of ways of doing this. Have a look around on this site, it's been asked before. rsync would probably be the best way of doign this.

For my staging server, how to secure it internally?... I cannot use a subdirctory because I have lots of sub-domains/sub directories already as part of the site and I want to preserve the accurate URL structure for proper QA.

You need a split DNS. The DNS servers that your QA users are on needs to return a different A record than your public users. There's no easy way of doing this. Personally, what we do is we just use a different hostname, so instead of www.example.com the internal DNS has an extra A record for staging.example.com. That A record is not exposed to the internet, so only people inside the office or the VPN can access it.

I need to use version control for code, so i assume SVN is to be installed on both servers and they can be in sync although I am not sure how to seperate them between environments on SVN?

SVN is a great way of doing this. When we need to deploy to staging ONLY, and not live, we fork the code and then do a checkout on the staging server. That way critical updates can still be deployed to the live system when ready, but the staging system is testing a not-production-ready codebase. Then, when we're done, we merge back into the main trunk and re-check-out the staging server so that they're all back on the same system.

share|improve this answer
2  
Just make sure your deployment system ends up linked to your source control system. If it's easier for you to check things into source control, then deploy them, you won't be tempted to make "one little fix" live, only to forget about it and overwrite it later. –  devicenull Feb 18 '11 at 3:33
    
For number 2, so you say there will be some downtime, maybe a minute? is that how it works with the big sites too like say Google? Never heard of them being down even for a second... Secondly is it SVN or CVS? –  MKnight Feb 18 '11 at 14:06
    
@MKnight - only the staging system will be down for a minute, not your live site. Google have thousands of servers. Google have thousands and thousands of servers, they can take a few of them offline without anyone knowing. Oh, and Google do go down occasionally, but it's generally internet-related, not server-related. Also, it's SVN. CVS compared to SVN is a behemoth that should be buried. There's also Git, which a lot of companies use these days. –  Mark Henderson Feb 18 '11 at 22:41

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.