How to Migrate Node Data to a Target Computer

I’m providing a general procedure for how to migrate all existing xx network data to a target computer. I do this with some reservations because it is impossible to write a fool-proof, step-by-step guide that does everything one wants, the way one wants it done. It just cannot be because there are too many factors. The only way I feel comfortable providing a procedure that has the least chance to fail is to include everything (the xxnetwork directory, including chain, and the relevant PostgreSQL database). You will need to use common and technical sense along with the information provided.

NOTICE #1: Do not take any action until you have reviewed this entire post thoroughly and have carefully considered the amount of time that is required. Some of the individual steps take many minutes, if not hours to complete. I feel comfortable saying the entire process will take at least a couple of hours.

NOTICE #2: For steps that require longer times to complete I provide a note, Ex: (Time Req: 3-5 min.) However, these times are estimates and depend on factors such as disk I/O, CPU and/or network connection.

NOTICE #3: You must configure the target computer as a node. Here is where you need to use common and technical sense. Not all steps from the Node Handbook are required. For example, you do not need to “Download Software” and “Generate Identity Information” since it’s part of the data you are migrating. However, some steps must be completed before proceeding past Step 5, such as installing the OS, " Updating Software and Installing Dependencies" and “Database Setup”.

Are you sure you’re ready? Let’s begin.

On the existing node computer:

Step 1: Stop, and as a precaution to avoid conflicts, disable the xx network services.

$ sudo systemctl stop xxnetwork-cmix xxnetwork-chain
$ sudo systemctl disable xxnetwork-cmix xxnetwork-chain

Step 2. Backup the node database into xxnetwork.
Input the password found in the database section of /opt/xxnetwork/config/cmix.yaml

$ cd /opt/xxnetwork
$ pg_dump -h -U cmix -d cmix_node > cmix_node.pgsql

Step 3. Compress the xxnetwork directory. (Time Req: 10+ min.)

$ cd /opt
$ sudo tar -czvf node-data.tar.gz xxnetwork

Step 4. Get the hash of the tarball. (Time Req: 2+ min.)
Make a note of the output. You need the hash to compare to the output of Step 7.

$ cd /opt
$ sha256sum node-data.tar.gz

Step 5. See NOTICE #3

Step 6. Transfer node-data.tar.gz to the /opt directory of the target node computer. You will need to determine how best to accomplish transferring many gigabytes of data from the existing computer to the target computer. I can only say this could take many minutes to many hours depending on how you transfer the data.

On the target node computer:

Step 7. Get the hash of the tarball. (Time Req: 2+ min.)
If the output does not match the output of Step 4, the transfer was not successful, and you must transfer the data again.

$ cd /opt
$ sha256sum node-data.tar.gz

Step 8. Decompress the tarball. (Time Req: 10+ min.)

$ cd /opt
$ sudo tar -xvf node-data.tar.gz

Step 9. Change ownership of xxnetwork.

$ sudo chmod -Rv $USER:$USER /opt/xxnetwork

Step 10. Restore the node database.
Assuming you used the same database password as the existing node, input the password found in the database section of /opt/xxnetwork/config/cmix.yaml

$ cd /opt/xxnetwork
$ psql -h -U cmix -d cmix_node < cmix_node.pgsql

Step 11. Modify the cmix.yaml and/or service files if necessary.

Step 12. Install the service files.

$ sudo ln -s /opt/xxnetwork/xxnetwork-cmix.service /etc/systemd/system
$ sudo ln -s /opt/xxnetwork/xxnetwork-chain.service /etc/systemd/system

Step 13. Reload the systemd service files.

$ sudo systemctl daemon-reexec

Step 14. Enable the services.

$ sudo systemctl enable xxnetwork-cmix.service
$ sudo systemctl enable xxnetwork-chain.service

Step 15. Start the services.

$ sudo systemctl start xxnetwork-chain.service
$ sudo systemctl start xxnetwork-cmix.service

Step 16. Remove the tarball and node database backup file.
After you have verified the migration is successful and the cmix and chain processes are running properly you can remove the files used during migration.

$ sudo rm /opt/node-data.tar.gz
$ rm /opt/xxnetwork/cmix_node.pgsql
1 Like