> ## Documentation Index
> Fetch the complete documentation index at: https://docs.skale.space/llms.txt
> Use this file to discover all available pages before exploring further.

# Migrate SKALE Node with SGXWallet to New Server

> Step-by-step guide for migrating a SKALE node and SGXWallet to a new server

This guide provides instructions for migrating a SKALE node and SGXWallet to a new server following the recommended migration process.

## Prerequisites

Before starting the migration, ensure you have:

* Access to both the current and new servers
* Administrative privileges on both systems
* Secure network connection between servers

<Warning>
  Make sure backup is created before starting migration. You can use the `skale node backup .` command to create a backup of your current node and save `sgx_data` folder for SGX wallet as well as `sgxwallet_backup_key.txt`
</Warning>

## Migration Steps

### Migrate SGX

<Steps>
  <Step title="Set up the new SGX server">
    Prepare a new server with:

    * Ubuntu 22.04 LTS (Jammy Jellyfish)
    * SGX-enabled Intel processor
    * 8 physical cores
    * 16 GB RAM
    * 200 GB disk mounted as `/`
    * Swap size equal to half of the RAM size
  </Step>

  <Step title="Install the packages required for SGX">
    ```bash theme={null}
    sudo apt-get update && sudo apt-get upgrade -y
    sudo apt-get install -y docker.io docker-compose-plugin
    sudo apt-get install -y build-essential make cmake gcc g++ yasm python libprotobuf10 flex bison automake libtool texinfo libgcrypt20-dev libgnutls28-dev
    sudo apt-get install -y docker
    sudo apt-get install -y libelf-dev cpuid
    ```

    <Warning>
      After installing Docker, make sure that the `live-restore` option is enabled in `/etc/docker/daemon.json`. See the [Docker documentation](https://docs.docker.com/config/containers/live-restore/) for more information.
    </Warning>
  </Step>

  <Step title="Verify that the processor supports Intel SGX">
    ```shell theme={null}
    cpuid | grep SGX:
    ```

    Expected output:

    ```text theme={null}
    SGX: Software Guard Extensions supported = true
    ```
  </Step>

  <Step title="Disable automatic updates">
    Only update the SGXWallet server when critical security fixes are available. SGXWallet uses low-level technology, and kernel updates may break the system. SGX is currently tested on 5.15\* kernels, so avoid minor kernel updates as well.

    Prevent `apt update` from updating the kernel:

    ```shell theme={null}
    sudo apt-mark hold linux-generic linux-image-generic linux-headers-generic
    ```

    If you configured unattended upgrades, add the following lines to `/etc/apt/apt.conf.d/50unattended-upgrades` to prevent automatic kernel updates:

    ```text theme={null}
    Unattended-Upgrade::Package-Blacklist {
            "linux-generic";
            "linux-image-generic";
            "linux-headers-generic";
    };
    ```
  </Step>

  <Step title="Configure the firewall">
    Configure the firewall between the SGXWallet and node servers.
  </Step>

  <Step title="Download the SGXWallet source code">
    Clone the SGXWallet repository:

    ```shell theme={null}
    git clone https://github.com/skalenetwork/sgxwallet/
    cd sgxwallet
    git checkout stable
    ```
  </Step>

  <Step title="Enable SGX on the new server">
    The SGXWallet repository includes the `sgx_enable` utility. Run it to enable SGX:

    ```shell theme={null}
    sudo ./sgx_enable
    ```

    Install the SGX driver:

    ```shell theme={null}
    cd scripts
    sudo ./sgx_linux_x64_driver_2.11.b6f5b4a.bin
    cd ..
    ```

    <Note>
      Reboot your machine after installing the driver.
    </Note>

    Check the driver installation by confirming that the `isgx` device is available:

    ```shell theme={null}
    ls /dev/isgx /dev/sg0
    ```

    If you don't see the `isgx` device, follow the [SGX driver troubleshooting guide](https://github.com/skalenetwork/sgxwallet/blob/develop/docs/enabling-sgx.md).
  </Step>

  <Step title="Copy the SGXWallet data to the new server">
    Securely transfer the SGXWallet data from the old server:

    ```bash theme={null}
    # On the old server, create the backup
    tar -czf sgx_data_backup.tar.gz -C sgxwallet/run_sgx sgx_data

    # Transfer the backup to the new server
    scp sgx_data_backup.tar.gz user@new-server:/path/to/transfer/

    # On the new server, extract the backup to the correct location
    cd sgxwallet/run_sgx
    tar -xzf /path/to/transfer/sgx_data_backup.tar.gz
    ```

    <Warning>
      After uploading the backup to the new server, make sure that `sgxwallet_backup_key.txt` is stored in `sgx_data`.
    </Warning>
  </Step>

  <Step title="Set the image version and backup flag">
    Edit `sgxwallet/run_sgx/docker-compose.yml`:

    * Change the image version to `skalenetwork/sgxwallet:1.9.0-stable.4`.
    * Add `-b` to the existing command section. Do not replace the entire command.
  </Step>

  <Step title="Start SGXWallet">
    ```bash theme={null}
    cd sgxwallet/run_sgx
    docker-compose up -d

    # Verify that SGXWallet is running
    docker-compose ps
    docker-compose logs
    ```
  </Step>
</Steps>

### Migrate Node

<Steps>
  <Step title="Set up the new node server">
    Prepare a new server with:

    * Ubuntu 22.04 LTS (Jammy Jellyfish)
    * 8 physical cores
    * 32 GB RAM
    * 100 GB disk mounted as `/`
    * 2 TB additional disk (not mounted)
  </Step>

  <Step title="Install the packages required for the node">
    ```bash theme={null}
    sudo apt-get update && sudo apt-get upgrade -y
    sudo apt-get install -y docker.io docker-compose-plugin nftables
    ```

    <Warning>
      After installing Docker, make sure that the `live-restore` option is enabled in `/etc/docker/daemon.json`. See the [Docker documentation](https://docs.docker.com/config/containers/live-restore/) for more information.
    </Warning>
  </Step>

  <Step title="Disable automatic updates">
    The SKALE node is currently tested on 5.15\* kernels, so avoid minor kernel updates as well.

    Prevent `apt update` from updating the kernel:

    ```shell theme={null}
    sudo apt-mark hold linux-generic linux-image-generic linux-headers-generic
    ```

    If you configured unattended upgrades, add the following lines to `/etc/apt/apt.conf.d/50unattended-upgrades` to prevent automatic kernel updates:

    ```text theme={null}
    Unattended-Upgrade::Package-Blacklist {
            "linux-generic";
            "linux-image-generic";
            "linux-headers-generic";
    };
    ```
  </Step>

  <Step title="Back up the node on the old server">
    ```bash theme={null}
    skale node backup .
    ```

    This creates a backup tarball, such as `skale-node-backup-YYYY-MM-DD-HHMMSS.tar.gz`.
  </Step>

  <Step title="Copy the backup and configuration to the new server">
    ```bash theme={null}
    scp skale-node-backup-*.tar.gz user@new-server:/path/to/new/location/
    scp .env user@new-server:/path/to/new/location/
    ```
  </Step>

  <Step title="Download node-cli">
    ```bash theme={null}
    curl -L https://github.com/skalenetwork/node-cli/releases/download/2.6.2/skale-2.6.2-Linux-x86_64 > /usr/local/bin/skale
    chmod +x /usr/local/bin/skale

    # Verify the installation
    skale --version
    ```
  </Step>

  <Step title="Restore the node from the backup">
    Navigate to the directory that contains the backup tarball, then restore the node:

    ```bash theme={null}
    skale node restore skale-node-backup-*.tar.gz .env
    ```
  </Step>
</Steps>

<Tip>
  Keep the old server running until you've fully verified the new setup is working correctly. This allows for quick rollback if needed.
</Tip>
