Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!


How do you migrate/sync/copy web server to different machine with minimum downtime?
New on LowEndTalk? Please Register and read our Community Rules.

All new Registrations are manually reviewed and approved, so a short delay after registration may occur before your account becomes active.

How do you migrate/sync/copy web server to different machine with minimum downtime?

postcdpostcd Member

Hello,

there is Apache, MySQL web server (in my case it is with cPanel control panel) based on the OpenVZ VPS 250GB size.

I need to move it to another machine, both machines owned by one company, located in same city, same 1Gbit internet connection, SSH only access, source is 7.2K RPM drives raid 1, destination is SSD. I can keep same IP, because provider told me they can schedule IP subnet change from source to destination server at a day/time i choose.

Here is my rough idea what can be done to move this rather large VPS with minimum downtime and i hope you can advise better steps that can achieve shorter downtime of the hosted website/s:


  • I can let the vzdump or vzmigrate tools do the backup of the source VPS and restore it on destination machine. So i have solid working copy of around 99% of all the data (1% is the data changed in the meantime on the source VPS), good basis for next rsync.

  • i assign secondary IP to the destination VPS so i can access it and i disable all important services like chksrvd, httpd, mysqld, exim, pure-ftpd on the destination VPS not to make a mess during future rsyncing

  • i disable cpanel updates in source VPS WHM

i setup this raw rsyncing and monitoring bash script:

https://pastebin.com/RAiNRUvY

Please how you would modify the steps to minimize downtime of the hosted website/s? Thank you

Comments

  • dwtbfdwtbf Member

    Maybe:

    Spin two VM, one existing, one new. Do rsync to new VM from old, when complete then slowly start pushing traffic to new VM via DNS, upon no traffic for a period greater than 20 minutes, shutdown old VM, provider change IP over to new.

    1. Install apache/mysql & apache or w.e you're using on a new server
    2. rsync your files to a new server
    3. test the site using a placeholder domain/sub-domain
      If #3 works proceed to step #4
    4. Point your dns to your new server.
  • WSSWSS Member

    Don't forget to alter your DNS TTL now, so you can have your zone cached for less time to prep for migration. After all's good and done, change your IPs in DNS and then put the TTL back.

  • How many domain in the cpanel? If it's in lower number use cloudflare with cdn on and poofff no downtime, if there is big number of domain just lower the ttl dan do it before the old server down so when it's down all record was migrated to new server

  • postcdpostcd Member
    edited July 2017

    thx for input, i do not need to change IPs (provider can re-route it at set time to new machine). If i do it without IP change, i would need to use mentioned script and find some command which can tell me whether the IP is still routed to old server and do automated rsycning.

    But if i change IP, then the DNS propagation will be involved which means people with cached old IP will still go to old server and de-synchronize things unless i shut down old server or setup some iptables redirection rule for them.
    http://www.webhostingtalk.com/showthread.php?t=924957&p=6701464#post6701464
    http://revsys.com/writings/quicktips/ssh-tunnel.html
    http://debuntu.org/how-to-redirecting-network-traffic-to-a-new-ip-using-iptables/
    I would also need to manipulate DNS TTL's (there is a bulk tool for that in cPanel), replace old IP by new IP inside DNS zone files and then reload DNS zones and i am unsure if this is all needed in order to make websites loading on new IP VPS.

    The method with leaving on old IP seems more elegant to me, only to find live(no-cache) Linux command that would tell me to which server IP is routed.

  • WSSWSS Member

    You're looking for 'ip' with iptools2, or netstat/route/ifconfig with iptools1.

    You might want to clarify with your host that this is what you want to do- they may have you on completely different subnets.

  • edfoxedfox Member
    1. Get first server, freeze and clone it to the second location

    2. Set the first server as a reverse proxy of the second new server

    3. Change your DNS or whatever and wait until everything propagates

    4. Delete old server

    That's how I did it

Sign In or Register to comment.