Backup and Restore

Introduction

Running a Change Chain node allows you to participate in the network by validating transactions, contributing to network security, and earning mining rewards. To ensure the continuity of your node's operation in case of hardware failures, software issues, or unforeseen disasters, it's essential to have a reliable backup and restore strategy.

This guide provides detailed instructions on how to back up and restore your Change Chain node efficiently. By focusing on the essential files unique to your node, you can minimize downtime and quickly recover your node without having to back up large volumes of data.


Essential Files to Backup

The essential files that uniquely identify your Change Chain node are:

  1. nodekey: This file contains the private key that defines your node's identity (NodeID) on the network.

  2. Wallet Files (if applicable): If your node manages any wallets or accounts, you should back up the keystore files associated with them.

Location of Essential Files

By default, these files are located in the following directory:

  • Linux/macOS: ~/.changechain/

  • Windows: C:\Users\YourUsername\.changechain\


Backup Procedure

Step 1: Locate the Essential Files

Navigate to the directory where your node's data is stored.

Linux/macOS:

bashCopy codecd ~/.changechain/

Windows (Command Prompt):

cmdCopy codecd %USERPROFILE%\.changechain\

Step 2: Identify the Files to Backup

  • nodekey: The file that stores your node's private key.

  • Keystore Directory (if applicable): Contains wallet files.

To ensure data integrity, it's recommended to stop your node before copying the files.

bashCopy code# If you started your node manually
Ctrl + C

# If your node runs as a service
sudo systemctl stop changechain

Step 4: Copy the Files to a Safe Location

Copy the essential files to a secure backup location, such as an external hard drive or a secure cloud storage service.

Example:

bashCopy codecp nodekey /path/to/backup/location/
cp -r keystore /path/to/backup/location/  # If you have keystore files

Important Notes:

  • Security: Ensure that the backup location is secure. Anyone with access to these files can impersonate your node or access your wallets.

  • Privacy: Do not share these files with anyone. Keep them encrypted if possible.

Step 5: Restart the Node (If Stopped)

If you stopped your node in Step 3, restart it.

bashCopy code# If you start your node manually
./changechain

# If your node runs as a service
sudo systemctl start changechain

Restore Procedure

Step 1: Install Change Chain Node on the New Machine

Set up the Change Chain node on the new machine by following the Running a Change Chain Node guide.

Step 2: Stop the Node on the New Machine

Before restoring the backup files, stop the node if it's running.

bashCopy code# If you started your node manually
Ctrl + C

# If your node runs as a service
sudo systemctl stop changechain

Step 3: Replace the Essential Files

Copy the backed-up files to the appropriate directory on the new machine.

Example:

bashCopy codecp /path/to/backup/nodekey ~/.changechain/
cp -r /path/to/backup/keystore ~/.changechain/  # If you have keystore files

Ensure that the file permissions are correctly set:

bashCopy codechmod 600 ~/.changechain/nodekey

Step 4: Restart the Node

Start the node on the new machine.

bashCopy code# If you start your node manually
./changechain

# If your node runs as a service
sudo systemctl start changechain

Step 5: Verify Node Identity

After the node starts, verify that it retains the original NodeID.

Retrieve the NodeID

bashCopy codecurl -X POST --data '{
    "jsonrpc":"2.0",
    "id"     :1,
    "method" :"admin_nodeInfo"
}' -H 'content-type:application/json;' 127.0.0.1:9651

Check that the NodeID matches the one from your previous node.


Database Backup and Restore (Optional)

While the blockchain data can be re-downloaded through the bootstrapping process, you may choose to back up the database to reduce synchronization time.

Backup the Database

Step 1: Stop the Node

bashCopy codesudo systemctl stop changechain

Step 2: Compress the Database Directory

bashCopy codetar -czvf changechain_db_backup.tar.gz ~/.changechain/geth/chaindata

Note: Compressing the database may take some time depending on its size.

Restore the Database

Step 1: Transfer the Backup to the New Machine

Copy the changechain_db_backup.tar.gz file to the new machine using scp, rsync, or any secure file transfer method.

Example using scp:

bashCopy codescp changechain_db_backup.tar.gz user@newmachine:/path/to/destination/

Step 2: Extract the Database

bashCopy codetar -xzvf changechain_db_backup.tar.gz -C ~/.changechain/geth/

Step 3: Start the Node

bashCopy codesudo systemctl start changechain

Step 4: Verify Synchronization

Check the node logs or use RPC methods to ensure the node is synchronized and functioning correctly.


Important Considerations

  • Single Instance per NodeID: Ensure that only one instance of your node is running with the same NodeID. Running multiple nodes with the same identity can lead to network issues and may affect your mining rewards.

  • Security of Backup Files: Keep your backup files secure. Unauthorized access to your nodekey can compromise your node's identity.

  • Wallet Security: If you manage wallets or accounts on your node, ensure that the keystore files are also securely backed up and restored.

Last updated