SpecialHigh-Speed NVMe Hosting & Cloud VPS • Fast 10Gbps Network • 24/7 Expert Support
View Offer
VPS Hosting6 min readJuly 3, 20261 Views

How to Take a Full Backup of a Linux VPS and Migrate It to Another VPS (Step-by-Step Guide)

Learn how to create a complete Linux VPS backup and restore it on a new VPS safely, including websites, databases, emails, configurations, and user data.

HostAsia Logo
HostAsia Engineering TeamVerified
Cloud Infrastructure & Security Specialists
Share:
How to Take a Full Backup of a Linux VPS and Migrate It to Another VPS (Step-by-Step Guide)

Table of Contents

18

Migrating a Linux VPS to a new server may seem complicated, but with the right approach, you can transfer your entire server—including websites, databases, emails, configurations, and user data—with minimal downtime.

In this guide, you'll learn how to create a complete Linux VPS backup and restore it on a new VPS safely.

Why Migrate a Linux VPS?

There are several reasons why you may need to migrate your VPS:

  • Upgrading to a faster server
  • Moving to a different data center
  • Better hardware and performance
  • Lower hosting costs
  • Improved security
  • Changing hosting providers

Before You Start

Before taking a backup, make sure:

  • You have root SSH access.
  • Both old and new VPS are running Linux.
  • The new VPS has enough storage.
  • Important services are stopped during backup (optional but recommended).

Step 1: Check Disk Usage

First, check how much data needs to be backed up.

df -h
du -sh /*

This helps ensure your new VPS has sufficient storage.

Step 2: Create a Full VPS Backup

A full server backup can be created using the tar command.

Run:

cd /
tar --exclude=/proc \
    --exclude=/sys \
    --exclude=/dev \
    --exclude=/run \
    --exclude=/mnt \
    --exclude=/media \
    --exclude=/tmp \
    --exclude=/lost+found \
    -czpf /root/vps-backup.tar.gz .

This backup includes:

  • Website files
  • Home directories
  • Databases
  • Apache/Nginx configuration
  • User accounts
  • Cron jobs
  • SSL certificates
  • System configuration

Step 3: Backup Databases

For MySQL or MariaDB, create a database dump.

mysqldump --all-databases --single-transaction --quick --lock-tables=false > /root/all-database.sql

If you're using PostgreSQL:

pg_dumpall > /root/postgres-backup.sql

Step 4: Backup Email (Optional)

If your VPS hosts email services such as Postfix or Dovecot, also back up:

/etc/postfix
/etc/dovecot
/var/vmail

Step 5: Transfer Backup to the New VPS

Use scp:

scp /root/vps-backup.tar.gz root@NEW_SERVER_IP:/root/
scp /root/all-database.sql root@NEW_SERVER_IP:/root/

Or use rsync for faster and resumable transfers:

rsync -avzP /root/vps-backup.tar.gz root@NEW_SERVER_IP:/root/

Step 6: Restore Backup on the New VPS

Extract the backup:

cd /
tar -xzpf /root/vps-backup.tar.gz

Step 7: Restore Databases

MySQL:

mysql < /root/all-database.sql

PostgreSQL:

psql -f /root/postgres-backup.sql postgres

Step 8: Install Missing Packages

If the new VPS is freshly installed, install the required software.

Example:

dnf install httpd mariadb-server php

or

apt install apache2 mariadb-server php

depending on your Linux distribution.

Step 9: Restart Services

Restart all major services.

systemctl restart httpd
systemctl restart nginx
systemctl restart mariadb
systemctl restart mysql
systemctl restart php-fpm
systemctl restart dovecot
systemctl restart postfix

Only restart the services that are installed on your server.

Step 10: Verify Everything

Before changing DNS:

  • Check websites.
  • Test database connections.
  • Verify email functionality.
  • Test SSL certificates.
  • Check cron jobs.
  • Confirm user permissions.
  • Review server logs.

Useful commands:

systemctl status apache2
systemctl status httpd
systemctl status nginx
journalctl -xe

Step 11: Update DNS

Once everything works correctly:

  • Update the A record to the new VPS IP.
  • Lower TTL before migration for faster propagation.
  • Wait for DNS propagation.

Alternative Method: Use rsync for Live Migration

If you want minimal downtime, use:

rsync -aAXHv --delete / root@NEW_SERVER_IP:/

Exclude virtual directories:

--exclude=/proc
--exclude=/sys
--exclude=/dev
--exclude=/run
--exclude=/tmp

Run rsync twice—the second run after stopping services—to synchronize only the changed files.

VPS Migration Checklist

  • ✅ Full file backup created
  • ✅ Database backup completed
  • ✅ Email data backed up
  • ✅ SSL certificates copied
  • ✅ User accounts migrated
  • ✅ Cron jobs verified
  • ✅ Applications tested
  • ✅ DNS updated

Common Migration Mistakes

  • Forgetting to back up databases
  • Restoring on a different Linux version without testing
  • Not copying SSL certificates
  • Ignoring file permissions
  • Changing DNS before testing the new server
  • Not verifying firewall rules

Best Practices

  • Always keep at least two backup copies.
  • Test the backup before deleting the old VPS.
  • Use rsync for large servers.
  • Keep software versions compatible between the old and new VPS.
  • Monitor logs after migration to catch any issues early.

Conclusion

Migrating a Linux VPS is straightforward when you follow a structured process. By creating a complete server backup, transferring it securely, restoring the data, and thoroughly testing the new environment, you can move your applications with minimal downtime and without data loss.

Whether you're upgrading hardware, switching hosting providers, or moving to a new location, following these steps ensures a smooth and reliable VPS migration.

Found this article helpful? Share with your peers:
Share:
HostAsia Logo

HostAsia Cloud Engineering Team

Verified Author

HostAsia provides enterprise cloud web hosting, NVMe VPS, and instant domain registration powered by Tier-4 India (Mumbai) and Singapore datacenters with automated GST billing and 24/7 technical support.

Discussion & Comments0

Ask questions, share real-world tips, or connect with fellow developers

Join the Community Discussion

Only verified HostAsia members can post comments to prevent spam and maintain high technical standards. Log in or create a free account to participate.

Loading discussion comments...

Related Guides & Articles

Continue exploring technical benchmarks and hosting tutorials

All Articles
Instant 60-Second Cloud Setup

Ready to Supercharge Your Website with Ultra-Fast NVMe Hosting?

Experience 10x faster load times with LiteSpeed enterprise caching, free SSL, automated cPanel migration, and Tier-4 Indian datacenters.

Why ChooseHostAsia?
•
99.9% Uptime SLA Guarantee•
Tier-4 Mumbai & SG Datacenters•
Why ChooseHostAsia?
•
Ultra-Fast NVMe Gen4 Storage•
Zero Egress Bandwidth Fees•
Why ChooseHostAsia?
•
24/7/365 Priority Support•
Free Wildcard SSL & Daily Backups•
Why ChooseHostAsia?
•
1-Click WordPress & App Deploys•
Instant UPI & NetBanking Setup•
Why ChooseHostAsia?
•
Enterprise Hardware DDoS Shield•
Rootless Cgroups Cloud Isolation•
Why ChooseHostAsia?
•
Trusted by 10,000+ Developers•
Free Automated cPanel Migration•
Why ChooseHostAsia?
•
99.9% Uptime SLA Guarantee•
Tier-4 Mumbai & SG Datacenters•
Why ChooseHostAsia?
•
Ultra-Fast NVMe Gen4 Storage•
Zero Egress Bandwidth Fees•
Why ChooseHostAsia?
•
24/7/365 Priority Support•
Free Wildcard SSL & Daily Backups•
Why ChooseHostAsia?
•
1-Click WordPress & App Deploys•
Instant UPI & NetBanking Setup•
Why ChooseHostAsia?
•
Enterprise Hardware DDoS Shield•
Rootless Cgroups Cloud Isolation•
Why ChooseHostAsia?
•
Trusted by 10,000+ Developers•
Free Automated cPanel Migration•
How to Take a Full Backup of a Linux VPS and Migrate It to Another VPS | HostAsia Blog | HostAsia