Simplify VPS Migration with Clonezilla: A Step-by-Step Guide

Simplify VPS Migration with Clonezilla: A Step-by-Step Guide

30.11.2023
Author: HostZealot Team
2 min.
746

Clonezilla is an open-source partition and disk imaging software. The program intends to help users perform systems backup, recovery, and deployment. Clonezilla can also assist you in migrating your virtual private server.

This is your guide on how to migrate your VPS server with Clonezilla.

The Significance of VPS Backup: Protecting Your Data

Backing up your VPS server is an important step to save you from stress. Data loss can occur for various reasons, some of which you might not be able to foresee. Therefore, backing up a VPS server should become routine to prevent unfortunate consequences of data loss.

Server backup can be performed automatically (through specialized software like Clonezilla) and manually. Manual backup requires some technical knowledge, so the easier way would be to use the preconfigured solutions to migrate a server.

The thing is, depending on what you use a VPS for (if you are a hosting provider, for example) your server could store other users' data. If you have clients as a hosting provider, they rely on your server to protect and secure their data. Therefore, you need to think ahead about backing up your server and the data it contains.

If you are using the VPS services of a hosting provider, they may assure you that they take all the necessary security measures; however, there's no harm in asking your hosting provider for additional backup manipulations to avoid potential issues.

Besides, already having a backed-up version of your VPS server makes it easier to migrate if needed.

Here's how you can approach your server backup:

  • Choose the data you need to back up.

Backing up the entire server might take a while. So, it's better to choose the priority data you want to make a copy of first. If you have already backed up your server, you only need to migrate the recent changes, thus reducing the backup time.

  • Select a backup software.

You can back up your data remotely or locally. Remote backup usually uses the cloud or network, while local backup stores the data on local devices. We recommend using Clonezilla as a simple and free migrating solution.

  • Duplicate your backups.

You should consider doubling your backup if something happens to the original.

  • Make backups regular.

Setting a schedule for backups will save you a lot of trouble, and you will always know that you're ready for any case scenario.

Many server backup solutions exist for various operating systems, including Linux, Windows, and Mac. Many of them are free to download and use. So why not use it to your advantage?

You can easily back up your VPS server through Clonezilla. Let's see what features it brings.

Exploring the Capabilities of Clonezilla

Clonezilla is free, but it offers a lot of professional-grade features. It is a reliable and customizable disk imaging tool, making the cloning process accessible and easy. Clonezilla allows users to clone using a USB, a local disk, or a network.

Now, here are some features of Clonezilla you should know about:

  • Support of multiple filesystems
  • Creating an image of a disk or partition at any time
  • Support of one disk image restoring to multiple devices
  • Options for encrypted disk images and reading from the SSH server
  • Support of multiple partition systems
  • System deployment over the network
  • Automation using commands

Clonezilla allows one to easily create an ISO image of a hard disk or partition and migrate it to an HDD, an SSH server, a network share, or network filesystems.

What You Need Before You Begin

To migrate or back up your VPS, your hosting provider needs to permit you to load VPS from ISO images.

Unfortunately, Clonezilla currently doesn't support live disk imaging or cloning. So before you create a disk image with Clonezilla, you need to switch off your VPS and make an ISO image from a recovery or live ISO.

Regarding operating systems, Clonezilla has a Debian, Arch Linux, and Ubuntu repository. If your hosting provider offers an option of a custom ISO image option, you can use the Live ISO version of Clonezilla without downloading the additional software. Among the available operating systems, it's better to use the Ubuntu server (not the desktop ISO version) with Clonezilla Live ISO since the desktop version uses a lot of RAM. If you have insufficient RAM, you'll face technical issues with Clonezilla while using the Ubuntu desktop.

This Clonezilla tutorial will use an Ubuntu server as an example.

Step 1: Initiating Your VPS via ISO Image

We'll guide you through the phases of the first step of initiating your VPS migration through an ISO image created with Clonezilla.

  1. First, you need to access your VPS control panel and link the Ubuntu ISO image to the VPS.
  2. Create a VNC (Virtual Network Computing) connection to the VPS. You can request a VNC from your hosting provider.
  3. Turn off your VPS and run it from the Ubuntu ISO image (you can ask your hosting provider for instructions on this step).
  4. Select the device you want to boot up your VPS from through the boot menu by pressing "ESC" (or "F12") in the VNC window.
  5. Select DVD\CD drive for the VPS to load the Ubuntu ISO image; after that, the Ubuntu installer should be active.
  6. Choose a language in the Ubuntu installer.
  7. Establish the network connection.
  8. Press Ctrl+Alt+F2 in the VPS window; then, you'll see a virtual terminal.
  9. Make sure your VPS and network connection are synchronized through "ping 8.8.8.8".
  10. Once you have ensured that the VPS is connected, install Clonezilla through the following commands:
sudo apt-add-repository universe
sudo apt update
sudo apt install clonezilla net-tools sshfs ecryptfs-utils binutils e2fsprogs screen

Step 2: Safeguarding Your VPS Data with Clonezilla

In order to avoid losing the SSH session in case of disruptions in a network connection, you can use the GNU screen utility. To start the GNU screen, you can use commands like "screen".

  • Once you have a GNU screen running, press Enter after the introduction text to use the line of commands.
  • Boot Clonezilla by using the "sudo clonezilla" command.
  • Once Clonezilla is running, you can use Clonezilla wizard or Clonezilla command-line interface. We recommend choosing Clonezilla Wizard as it is more beginner-friendly.
  • In the Clonezilla wizard, choose a mode: device-image mode (creates the current disk or partition image) or device-device mode (clones between two disks without creating an image). The further steps will be viable for the Clonezilla's device-image mode.
  • Choose a place to save a cloned disk image. There are many options, but for this tutorial, we're choosing disk cloning an image to another server through an SSH connection.
  • Put in the IP address or the name of the SSH server you will save your disk image on.
  • Pick the SSH port.
  • Put in the username.
  • Enter the directory existing within your SSH server where you want to save your disk image.
  • Type in an SSH password.
  • Choose the "beginner" or an "expert" Clonezilla mode according to your technical knowledge.
  • Next, you can choose an image of an entire disk or a specific partition; the next steps are for the entire disk option available with Clonezilla.
  • Name the image.
  • Choose a disk for backup and a compression algorithm for the image; if you're you need help with choosing, use a default Clonezilla disk backup option.
  • Consider if you want to check or repair the disk file systems before backing it up. The disk check is supposed to be quick, so we recommend you do that.
  • Choose if you want to see whether the disk image is restorable (Clonezilla won't write any data on the hard drive).
  • Choose if you want your disk image to be encrypted; we recommend an encrypted disk image specifically if you're using a network for backup.
  • Choose the action after a reboot.
  • Then Clonezilla configures commands that correspond with all of your former actions so that the next time you want to disk back up, you can just enter those commands and complete the process.
  • To encrypt the disk image, type in a passphrase twice in Clonezilla.
  • Press "y" to start saving the disk image.
  • Once the disk image is saved, reboot your VPS.

Transferring to a Different VPS Hosting Provider

If you want to switch to another hosting provider for your VPS, you need to start a new VPS with a new hosting provider first. Then, you can migrate your disk image to your new VPS. The VPS migration is similar to the backup procedure. However, here are a few steps you need to pay attention to.

  • Boot up your new VPS from Ubuntu ISO, establish a network connection, and install Clonezilla.
  • Then use "fdisk" to create a partition table or file systems in Clonezilla; for this, you can use the following commands on your old VPS:
sudo fdisk -l /dev/sda

For disk partitions from your old VPS:

sudo fdisk /dev/sda
  • Erase existing partitions by pressing "o"; press "g.o" for the MBR partition table or "g" for the GPT partition table.
  • Press "n" to create a new partition; press "p" to select the primary one.
  • Type "1" to create /dev/sda1.
  • Press Enter for the default sector.
  • For the/dev/sda1 directory, use the exact sector location as your old VPS.
  • Press "n" to create a second partition.
  • Press "w", once the partitions are created.
  • Boot up Clonezilla, using “sudo clonezilla”.
  • Start the Clonezilla wizard.
  • Choose a device-image Clonezilla mode.
  • Assign where the Clonezilla image will be read from; pick "Use SSH server".
  • Choose the "restoredisk" to restore the image from a local disk.
  • After the disk restoration is complete, run "ip addr" to get the address of the primary network interface that you might need for configuring the network connection.
  • Restart your new VPS; you might need to update the Ubuntu OS here.

If you see the "Unable to find target partition sda1" error in restoring the Clonezilla image to the new VPS, your version of Ubuntu will likely not support the commands for Clonezilla to create disk partitions. In this case, use "fdisk" to make the needed disk partitions before running Clonezilla to transfer the image to your new VPS.

Configuring Network Connection for Your New VPS

After transferring the image to your new VPS through Clonezilla, reboot it without live OS.

  • Log in through the VNC console and update network configuration; use "sudo nmtui", if you use CentOS or RHEL.
  • Reboot your connection for the changes to apply.
  • Edit the network configuration through /etc/netplan directory if you use Ubuntu.
  • Use the "sudo netplan apply" command to apply changes.

After these four VPS migration steps, your new VPS should be able to connect to the network.

The time of the VPS setup with Clonezilla can differ and depends on data size and setup complexity, involving how customized the server you currently use is in terms of settings.

Concluding Your VPS Migration with Clonezilla

With this tutorial, you'll be able to successfully complete VPS migration through Clonezilla.

You can also migrate VPS from shared hosting to virtual private hosting. If this is your case and you're using the same provider, ask them to perform the server migration. Otherwise, you can create a data backup and upload it to your new VPS.

Related Articles