Skip to main content
Back to Category

Server Migration Guide

Step-by-step guide to safely migrating your data, websites, and applications to a REXE server with minimal downtime.

Read time: 15 min General Information
server migrationdata transferwebsite migrationbackuprsyncDNS
Author
REXE Teknoloji Network & Security Team
Editor
REXE Teknoloji Technical Editorial
First published
Last updated

Introduction

Server migration is the process of transferring all data, applications, and configurations from your existing server to a new one. With proper planning, you can minimize downtime and prevent data loss.

Pre-Migration Preparation

1. Take Inventory

hljs bash
# Running services
systemctl list-units --type=service --state=running

# Installed packages
dpkg --get-selections > /tmp/packages.txt  # Debian/Ubuntu

# Open ports
ss -tlnp

# Crontab
crontab -l > /tmp/crontab_backup.txt

# Disk usage
df -h
du -sh /var/www/ /home/ /etc/

# Databases
mysql -e "SHOW DATABASES;"

2. Take Backups

hljs bash
# Web files
tar -czf /tmp/www_backup.tar.gz /var/www/

# Database backup
mysqldump --all-databases -u root -p > /tmp/all_databases.sql

# Config files
tar -czf /tmp/etc_backup.tar.gz /etc/

3. Lower DNS TTL

Lower DNS TTL 24-48 hours before migration:

Current TTL: 86400 (24 hours)
New TTL: 300 (5 minutes)

Migration Methods

hljs bash
# Pull files from old server to new server
rsync -avz --progress \
    -e "ssh -p 22" \
    root@old_server_ip:/var/www/ \
    /var/www/

# Config files
rsync -avz --progress \
    -e "ssh -p 22" \
    root@old_server_ip:/etc/nginx/ \
    /etc/nginx/

# Database
rsync -avz --progress \
    -e "ssh -p 22" \
    root@old_server_ip:/tmp/all_databases.sql \
    /tmp/

Method 2: SCP File Transfer

hljs bash
# Single file
scp root@old_server_ip:/tmp/backup.tar.gz /tmp/

# Directory
scp -r root@old_server_ip:/var/www/ /var/www/

Application-Specific Migration

Website (Nginx/Apache)

hljs bash
# 1. Transfer web files
rsync -avz root@old_ip:/var/www/ /var/www/

# 2. Transfer Nginx config
rsync -avz root@old_ip:/etc/nginx/sites-available/ /etc/nginx/sites-available/

# 3. Transfer SSL certificates
rsync -avz root@old_ip:/etc/letsencrypt/ /etc/letsencrypt/

# 4. Restart Nginx
nginx -t && systemctl restart nginx

Database (MySQL/MariaDB)

hljs bash
# On old server: dump
mysqldump --all-databases -u root -p > /tmp/all_db.sql

# On new server: import
mysql -u root -p < /tmp/all_db.sql

Docker Applications

hljs bash
# Save images
docker save myapp:latest | gzip > /tmp/myapp.tar.gz

# Transfer
rsync -avz root@old_ip:/tmp/myapp.tar.gz /tmp/

# Load on new server
docker load < /tmp/myapp.tar.gz

DNS Cutover

  1. Fully prepare and test the new server
  2. Update DNS A record to new IP
  3. Wait for TTL (5 minutes if you lowered it to 300)
  4. Verify new server is working
  5. Keep old server active for a few days (for rollback)
hljs bash
# Check DNS propagation
nslookup domain.com 8.8.8.8
nslookup domain.com 1.1.1.1

Post-Migration Checks

hljs bash
# Check all services are running
systemctl status nginx mysql php8.2-fpm

# Test website
curl -I https://domain.com

# Check SSL certificate
curl -vI https://domain.com 2>&1 | grep -E '(SSL|expire|issuer)'

# Check logs
tail -f /var/log/nginx/error.log

Don't shut down the old server immediately after migration. Keep it active for at least 1 week. Some users may still reach the old server due to DNS caching.

Conclusion

Planning is critical for a successful server migration. Take a full backup before migration, lower DNS TTL, and thoroughly test before going live. Our technical support team can assist if you encounter issues during migration.

Frequently Asked Questions

Will there be downtime during server migration?

With live migration using rsync, downtime is minimized. If you lower DNS TTL beforehand, the DNS cutover completes in 5 minutes. Total downtime is typically 5-15 minutes.

How should I migrate my database?

Export all databases with mysqldump, transfer to the new server, and import. For large databases, you can use rsync with live replication or MySQL replication.

How long does DNS propagation take?

It depends on the TTL value. If you lowered TTL to 300 seconds (5 minutes) beforehand, the change propagates in 5-10 minutes. With the default 24-hour TTL, it can take up to 24 hours.

When can I shut down the old server after migration?

Wait at least 1 week. Some users may still reach the old server due to DNS caching. After 1 week, if traffic has fully moved to the new server, you can shut down the old one.

Related Articles

Network TrafficInbound GbpsOutbound Gbps