How to Make an Incremental Server Migration with WHM and rsync

January 25, 2025 / Servers, Hosting & Email

This article explains how to make an Incremental server migration using WHM and rsync. Migrating a server can be a difficult task, but executing an incremental migration using WHM and rsync can ease the process. This method guarantees nominal downtime and transfers only the altered or latest files, making it a perfect choice for large datasets or servers with active websites.

Here’s a detailed guide to help you carry out an incremental server migration with ease:

Prerequisites:

  1. You need root access to both the source and destination servers through SSH.
  2. WHM installed on both servers.
  3. Rsync installed on both servers.
  4. A good network connection between both servers.

Follow the steps:

  1. Prepare the Destination Server:
    1.  Log into WHM on the destination server.
    2. Create the user accounts and configurations to mirror the source server.
      1. Go to Accounts > Create a New Account to add hosting accounts for your websites.
        create a new account
    3. Set up DNS settings to guarantee that the new server will take over hosting once the migration is complete.
      DNS settings
  2. Set Up SSH Access:
    1. Generate SSH keys on the source server if not previously created:
      ssh-keygen -t rsa
    2. Copy the SSH public key from the source server to the destination server using:
      ssh-copy-id user@destination-server-ip
    3. This will let you connect without entering a password each time.
  3. Perform the First Sync:
    1.  Log in to the source server through SSH and run the subsequent rsync command to start the primary synchronization:
      rsync -avz --exclude=/home/user/tmp /home/ user@destination-server:/home/
    2. Explanation of flags:
      • -a (archive mode) preserves file permissions, timestamps, and symbolic links.
      • -v (verbose) shows the transfer details.
      • -z compresses data for faster transfer.
      • –exclude allows you to exclude certain files (e.g., temporary files).
    3. Repeat the rsync command to copy other directories like databases or configuration files if required.
  4. Perform Incremental Syncs:
    1.  After the first full sync, use incremental backups by running rsync with the  –inplace option to copy only the changes made since the previous sync:
      rsync -avz --inplace user@source-server:/home/ user@destination-server:/home/
    2. The –inplace flag ensures that changes are directly applied to the destination server’s files instead of creating new copies.
  5. Final Synchronization:
    1.  After the incremental transfers, perform a final sync to ensure that all recent changes have been copied over:
      rsync -avz --inplace user@source-server:/home/ user@destination-server:/home/
    2. Once this is completed, verify that all files are up to date on the new server.
  6. Update DNS and Test the New Server:
    1.  Update the DNS records to point to the new server IP on the destination server.
    2. Test the websites hosted on the new server to ensure everything is functioning correctly.
  7. Clean Up and Decommission the Old Server:
    1. Once the migration is complete and the new server is fully operational, you can remove the old server’s DNS records.
    2. Optionally, back up any remaining important data from the old server before decommissioning it.

By now, you should have a clear understanding of how to manage server settings and use rsync for incremental data transfer. This approach is perfect for large websites or applications that require constant updates during the migration process.

Spread the love