logo
logo

High-performance virtual servers in Russia and Europe.

    SERVICES
  • Virtual Servers
  • Dedicated Servers
  • Domains
    SUPPORT
  • Contact via Telegram
  • support@vdsok.guru
  • abuse@as202831.network
  • Contacts
    TOOLS
  • Looking Glass
    LEGAL INFORMATION
  • User Agreement
  • Privacy Policy
  • Public Offer
  • TrustPilot
© 2026 VDSok.guru. All rights reserved.
CryptoBot Lolz.Guru Heleket FreeKassa Lava.ru 2328.io NOWPayments
DMCA.com Protection Status
Knowledge BaseContentsPreparation and BackupTransferring Files to the New ServerRestoring the DatabaseSwitching DNSTesting Before the SwitchSSL Certificate on the New Server
GuidesMay 2, 20263 min

How to Migrate a Website to a New Server

Preparation and Backup

Before any migration, make a full backup. On the old server, create an archive of the website files:
tar -czf site-backup.tar.gz /var/www/yoursite/
Separately, dump the database. For MySQL:
mysqldump -u root -p dbname > db-backup.sql
For PostgreSQL:
pg_dump -U postgres dbname > db-backup.sql
Save your Nginx/Apache configs, crontab:
crontab -l > cron-backup.txt
Also save the list of installed packages. Verify that the backup is valid — try extracting the archive and make sure the SQL dump isn't truncated.

Transferring Files to the New Server

The most reliable method is rsync over SSH:
rsync -avz --progress /var/www/yoursite/ user@new-server:/var/www/yoursite/
Rsync transfers only changed files and can resume after a connection drop. An alternative:
scp -r /var/www/yoursite/ user@new-server:/var/www/yoursite/
However, scp doesn't support resuming. For large volumes (tens of gigabytes), use rsync with the --compress flag. Don't forget to transfer configuration files, including .env, if they're not in the repository.

Restoring the Database

On the new server, install the same DBMS version as on the old one — this will prevent compatibility issues. Create the database and user, then import the dump. For MySQL:
mysql -u root -p dbname < db-backup.sql
For PostgreSQL:
psql -U postgres dbname < db-backup.sql
After importing, verify integrity: open the database and run a few queries on key tables. Make sure all tables are present and the data is correct.

Switching DNS

2–24 hours before the migration, lower the DNS records TTL to 300 seconds (5 minutes) — this way old values will be flushed from caches faster. Once the new server is fully set up and tested, update the domain's A record to the new server's IP. DNS propagation takes anywhere from a few minutes to a day, depending on the TTL and providers. While DNS is switching over, both servers should be operational — some users will hit the old one, others the new one.

Testing Before the Switch

Don't switch DNS until you've confirmed that the site works on the new server. Add an entry to your local hosts file (replace the IP with your new server's address):
echo '1.2.3.4 yourdomain.com' >> /etc/hosts
Open the site in a browser and check: does authentication work, are images displayed correctly, are there any 500 errors. Check the Nginx/Apache logs for errors. Test forms, email sending, and other critical functionality.

SSL Certificate on the New Server

After switching DNS and waiting for propagation, issue a new SSL certificate on the new server:
sudo certbot --nginx -d yourdomain.com -d www.yourdomain.com
If you're using Cloudflare, SSL is proxied on their end, so a self-signed certificate or Cloudflare Origin Certificate is sufficient on the server. Don't forget to set up auto-renewal:
sudo certbot renew --dry-run
This will verify that the cron/timer for renewal is working.
Also read

SSH Setup — Keys, Security, and Aliases

3 min

Nginx as a Reverse Proxy with SSL

2 min

How to Connect to Your Server

2 min