Moving to a new server — when upgrading specs or changing the operating system or network
The specs, operating system and network (zone) of a server you're using can't be changed later. If you need higher specs or want to change the operating system or network, you need to get a new server and move your data. If you follow the steps in order, you can move with almost no interruption to your service.
Overall steps
- Order the new server — leave the old server as it is until the move is finished. If its expiry date is close, renew it first.
- Move your data
- Check that everything works on the new server
- Change the address people connect to (update your domain, or share the new IP for a game server)
- Wrap up the old server
Linux → Linux: copy directly between servers (rsync)
Copying directly from server to server, without going through your PC, is fast. Install rsync on both servers.
sudo apt install -y rsync
Connect to the new server and pull the folder from the old server. Replace username and old-server-ip with the old server's connection info. (It asks for the old server's password.)
rsync -avz --progress username@old-server-ip:/home/username/myfolder/ ~/myfolder/
- Write the
/at the end of the folder paths exactly as shown so that what's "inside" the folder gets moved. - If you've set the old server to log in with SSH keys only, it won't connect with a password. In that case, download to your PC and then upload to the new server. (Uploading and downloading files)
- If it gets cut off partway, running the same command again continues the copy.
Other things to move
- DB — Create a backup file on the old server, bring it to the new server, and restore it.
# On the old server
sudo mysqldump --all-databases > ~/db-all.sql
# On the new server (install the DB first)
rsync -avz username@old-server-ip:/home/username/db-all.sql ~/
sudo mysql < ~/db-all.sql
- Configuration files like
.env— If you moved the whole app folder, they come along with it. They're hidden files, so check withls -a. - Scheduled jobs — View the list with
crontab -lon the old server, and add them again withcrontab -eon the new server. - Nginx configuration — Move your configuration files from
/etc/nginx/sites-available/. Rather than moving HTTPS certificates, it's simpler to point your domain at the new server and then get new ones issued. - How programs are run — Register programs you ran with pm2 or systemd again on the new server, the same way. (Deploying your own web app to a server)
Minecraft server
- Move it after stopping the server completely with
stopin the old server's console. Copying while it's running can corrupt the world. - Move the entire server folder. (Including
world,plugins,server.propertiesand everything else)
rsync -avz --progress username@old-server-ip:/home/username/minecraft/ ~/minecraft/
- Install Java on the new server and start it. (Creating a Minecraft server (Java Edition, Paper and vanilla))
Windows server
- The simplest way is to compress the folders you're moving (right-click → Compress), download them to your PC, then upload them to the new server. (Uploading and downloading files)
- For a game server, stop the program on the old server before compressing.
Changing the address people connect to
- If you use a domain, change the A record to the new server's IP on your domain management site. It can take anywhere from a few minutes to a few hours for the new address to spread. Then get an HTTPS certificate issued on the new server. (Putting up a website)
- For a game server people join by IP, tell your friends or players the new IP.
Checklist before wrapping up the old server
- Have you confirmed that your service works properly on the new server?
- Are there any files left only on the old server? As a final step, make one more backup.
- If you don't renew the old server, it will be stopped and terminated after its expiry date, and a terminated server's data can't be recovered.