WordPress Site Migration: Zero-Downtime Host Moves & Git CI/CD

Moving a live production website from one web hosting server to another — or promoting code changes from a local developer machine through staging into production — is a high-stakes engineering operation. Executed poorly, migrations cause broken image paths, corrupted serialized database settings, missing SSL certificates, and hours of costly commercial downtime. In this master class, we cover the Zero-Downtime Migration Protocol and modern Git CI/CD automated deployment pipelines.

The Zero-Downtime Migration Protocol (Step-by-Step)

Follow this exact sequence to migrate a live domain with zero disruption to visitors:

Step 1: Lower DNS TTL (Time To Live) 48 Hours in Advance

Log in to your DNS provider (Cloudflare, Namecheap, GoDaddy). Locate your domain's A-record and lower the TTL (Time To Live) from the default 86400 seconds (24 hours) down to 300 seconds (5 minutes). This ensures that when you finally switch servers, global ISPs will pick up the new IP address within 5 minutes instead of caching the old server for days!

Step 2: Transfer Filesystem & MySQL Database

Transfer files via SFTP or command-line rsync. Export the MySQL database using wp db export or phpMyAdmin. Import the database onto the new server, and update wp-config.php with the new host's database credentials.

Step 3: Preview the New Server via Local "hosts" File

Never change public DNS blindly without testing! You can force your personal computer to load the domain from the new server's IP address by editing your computer's local hosts file:

  • Windows: C:\Windows\System32\drivers\etc\hosts (Open in Notepad as Administrator)
  • Linux / macOS: /etc/hosts (sudo nano /etc/hosts)
  • Add this entry pointing your domain to the new server IP:
    203.0.113.45   veewom.com   www.veewom.com
  • Open your browser and test the site thoroughly! Since only your machine is routed to the new IP, live visitors remain on the old server while you verify logins, forms, and checkouts safely.

Step 4: Update Public DNS & Provision SSL

Once verified, remove the hosts file test line, provision a free Let's Encrypt SSL certificate on the new server, and point your public DNS A-Record to the new server's IP address. Traffic will switch seamlessly with zero dropped packets!

Modern Professional Workflow: Git Version Control & CI/CD

Agency teams never edit code live on production servers via FTP. Instead, they track theme and plugin code inside a GitHub repository and deploy automatically via GitHub Actions:

# .github/workflows/deploy.yml - Automated SFTP Deployment on Git Push
name: Deploy Theme to Production

on:
  push:
    branches: [ main ]

jobs:
  web-deploy:
    name: Deploy
    runs-on: ubuntu-latest
    steps:
    - name: Checkout Code
      uses: actions/checkout@v3

    - name: Sync Theme Files via SFTP
      uses: SamKirkland/FTP-Deploy-Action@4.3.3
      with:
        server: ${{ secrets.FTP_SERVER }}
        username: ${{ secrets.FTP_USERNAME }}
        password: ${{ secrets.FTP_PASSWORD }}
        local-dir: ./
        server-dir: /public_html/wp-content/themes/veewom-theme/

Whenever a developer pushes code to the main branch on GitHub, the pipeline runs automated code linter tests and pushes only modified files to the production server in seconds!

What should be included in .gitignore for WordPress?

In web engineering exams: Never commit the entire WordPress core or wp-config.php into a public Git repository (which would expose database passwords!). Always commit only your bespoke custom theme (/wp-content/themes/my-theme/) or custom plugin directory.

Frequently Asked Questions (FAQ) - Student & Interview Review

Q1. What is the best 1-click migration plugin for beginners?

**All-in-One WP Migration** and **Duplicator** are the top beginner plugins. They package your database, plugins, media uploads, and theme into a single download file, and unpack it onto the destination site with automated URL search-and-replace.

Q2. Why do images break after migrating to a new domain name?

WordPress stores absolute URLs in the database (e.g. `http://old-domain.com/wp-content/uploads/photo.jpg`). If you change domains without running a serialized `wp search-replace`, image links continue pointing to the old server.

Q3. What is the difference between a Staging Environment and a Localhost Environment?

A **Localhost environment** runs locally on your PC (XAMPP/LocalWP) with no internet access. A **Staging environment** runs on a real web server under a password-protected subdomain, mirroring the exact PHP version, web server modules, and MySQL limits of production.

Explore Related WordPress Tutorials & Next Steps

Expand your CMS mastery by studying these tightly integrated WordPress development topics:

Backups & Disaster Recovery

Create full snapshots before initiating domain or web host migrations.

WP-CLI Command Automation

Update database serialized URLs accurately using wp search-replace.

Speed Optimization Architecture

Configure server caching and DNS routing on your new hosting server.

Security Hardening

Verify SSL certificates, file permissions, and firewall rules on launch.

Share Share on Facebook Share on Twitter Share on LinkedIn Pin on Pinterest Share on Reddit

You may also like this!