How to Transfer Data from One VPS to Another Without Downtime

🔹 Why This Is Needed

You may need to move data between VPS servers when:

  • upgrading to a new plan or provider;
  • migrating to a newer OS version;
  • changing data center or region;
  • updating infrastructure without interrupting production services.

The main goal — migrate your data without stopping the running website or application.

⚙️ 1. Preparation

1. Create a new VPS — preferably with the same operating system.

2. Check access:

  • SSH access to both servers
  • root privileges
  • port 22 open for SSH connections

3. Update both systems:

sudo apt update && sudo apt upgrade -y

4. Ensure there is enough free space on the new VPS to receive the data.

📦 2. Transferring Files and Databases

🔸 Option 1: rsync (recommended)

rsync -avz -e ssh /var/www/ root@NEW_SERVER_IP:/var/www/

  • -a – archive mode (preserves permissions and ownership)
  • -v – verbose output
  • -z – compress data

After initial sync, you can run rsync again just before DNS switch — it will copy only the changes.

🔸 Option 2: tar + scp

tar czf backup.tar.gz /var/www/

scp backup.tar.gz root@NEW_SERVER_IP:/root/

On the new VPS:

tar xzf backup.tar.gz -C /

🔸 Option 3: MySQL / MariaDB transfer

On the old VPS:

mysqldump -u root -p database_name > backup.sql

scp backup.sql root@NEW_SERVER_IP:/root/

On the new VPS:

mysql -u root -p database_name < /root/backup.sql

🌐 3. Testing on the New VPS

Before updating DNS, edit your local /etc/hosts file:

NEW_SERVER_IP yourdomain.com

Then check your website — this allows you to test it on the new server without DNS propagation.

🔄 4. Switching DNS Without Downtime

  1. Reduce DNS TTL to 300 seconds in advance.
  2. After confirming everything works on the new VPS, update the A record to the new IP.
  3. DNS propagation usually takes 5–30 minutes.
    During this time, traffic may still reach both servers — so run rsync again after DNS update to sync the final data.

🧱 5. Final Steps

  • Verify that backups are created.
  • Delete temporary files (backup.tar.gz, backup.sql).
  • Reinstall or reissue the SSL certificate if bound to IP.
  • If necessary, expand the disk and set up automatic backups.

🧩 6. Useful Tips

  • For complex stacks (WordPress, Laravel, Docker) — use rsync + mysqldump combo or Docker volume export.

For seamless transition, you can set up a temporary reverse proxy on the old VPS forwarding traffic to the new IP.