With this guide, you can transfer the entire contents of an instance to a new one and migrate its public IP address in the process.

Creating a new instance

To do this you will first need to login to your account on Civo.com and navigate to the Instances menu to launch an instance without a public IP address. We will be moving the public IP address of your old instance to this new one later in the guide.

For consistency, we recommend launching a new instance with the same operating system as the current instance to be migrated. If you are using Ubuntu, create the instance with root as the initial user, and have the system assign a password. If your old instance is running Centos, use centos as your initial user, with an assigned password.

**Please note: do NOT assign an SSH key to this new instance at creation. Your old server will not have your SSH Private Key to authenticate with your new instance during the sync process. Instead, have the platform assign a password to your new instance.

Private IP only

Please note that you should launch the new instance with no public networking. To do this, on the 'Create New Instance' page, in the networking section, ensure the option for 'Public IP address' is set to 'none'. We are going to copy all files from the broken instance onto this new one and then move the IP address over.

Migrating your data

Once your new instance has launched, log in to your current instance and rsync the data over to your new instance.

The command you will need to run is:

rsync --sparse -aAXv / --exclude={"/dev/*","/proc/*","/sys/*","/tmp/*","/run/*","/etc/network/*","/mnt/*","/media/*","lost+found","/boot/*","/usr/src/*","/lib/modules/*"} root@10.97.93.15:/

Things to note about this command:

Accessing the random password

  • it will ask for a password. You can copy this on your instance page for the new instance, under 'view SSH information'. Copy it from the site and paste it in when required.
  • / is the location of the file system we want to copy, in this case the root filesystem.
  • we are excluding all the files defined in --exclude= because they are system files that we do not want to copy.
  • 10.97.93.15:/ is the internal IP of our newly created instance, followed by a colon, and then / being the destination location on the newly created instance where we want the files to be copied to.
  • after the files are copied, you may see an error: "rsync error: some files/attrs were not transferred (see previous errors) (code 23) at main.c(1183) [sender=3.1.1]". This is expected, as some files are not able to be copied - these will already exist on the new instance as they are system files.

If you have external volumes mounted on your old instance, you will be able to simply unmount them and re-attach to your new instance. For instructions for working with volumes, please refer to this guide: https://www.civo.com/learn/configuring-block-storage-on-civo.

Moving your IP address

Once the data has all been copied over you can move your current public IP address over to your newly created instance by running the following command on our Command-Line Interface: civo instance move-ip newInstanceName publicIPAddress, e.g:

$ civo instance move-ip test1 185.136.235.192
Moved the IP 185.136.235.192 to the instance test1 (9660a154-be46-403b-ba1c-ee7244b61ec5)

Securing the new instance

It is important to secure the new instance to prevent any attacks, as it was set up with a password. Follow this guide for basic steps you can take to harden your server.