Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save aussiehash/986e19fa78f2908c68f8b79f9999cc9f to your computer and use it in GitHub Desktop.
Save aussiehash/986e19fa78f2908c68f8b79f9999cc9f to your computer and use it in GitHub Desktop.
Samourai Dojo Copy Node Data
#### Copy over block data to your Dojo ####
## Written for use with Ubuntu Desktop 18.04 LTS ##
## On your machine running Dojo, open 2 terminals, we'll call them [terminal A] & [terminal Doc]
## In [terminal A] Check the size of your .bitcoin directory
$ df -hf ~/.bitcoin
## In [terminal A] Ensure you have enough hard drive space to copy over the content to the container.
$ df -h
## Under column `Filesystem` it should be something like /dev/sda2 , then read column `Avail` so see if you have space
## In [terminal Doc] login to the bitcoind docker container as root
$ sudo docker exec -u root -it bitcoind /bin/bash
## In [terminal Doc] Update and install a text editor
$ apt-get update && apt-get install nano
## Stopping bitcoind via 'sudo ./dojo.sh bitcoin-cli stop' shuts the container down, so I found it easiest to
## just add the following to bitcoin.conf and then stop the tor container to cut internet so the bitcoind
## container won't be able to download anything while copying the .bitcoin directory
## In [terminal Doc]
$ nano /home/bitcoin/.bitcoin/bitcoin.conf
## Add to bitcoin.conf
onlynet=onion
dnsseed=0
dns=0
## Save and exit
ctrl+x --> y --> return
## In [terminal A], restart the Dojo so changes to bitcoin.conf take effect
$ cd /path/to/docker/my-dojo/ && sudo ./dojo.sh stop
$ cd /path/to/docker/my-dojo/ && sudo ./dojo.sh start
## Pause the TOR container. This will stop bitcoind from downloading anything b/c it won't have an internet connection
## In [terminal A]
$ sudo docker container pause tor
## In [terminal Doc] Log back into the bitcoind container as root
$ sudo docker exec -u root -it bitcoind /bin/bash
## Clear out everything but bitcoin.pid and bitcoin.conf from the /.bitcoin directory
## In [terminal Doc]
$ mv /home/bitcoin/.bitcoin/bitcoin.conf /home/bitcoin/
$ mv /home/bitcoin/.bitcoin/bitcoind.pid /home/bitcoin/
$ rm -rf /home/bitcoin/.bitcoin/*
## In [terminal A] Get the container ID for bitcoind container
$ sudo docker ps | grep bitcoind | cut -d " " -f 1
## Copy the contents of your current full node's .bitcoin directory to the bitcoind docker container
## In [terminal A], (where XXXXXXXXXXXX is the full container ID for bitcoind)
$ sudo docker cp /path/to/.bitcoin/ XXXXXXXXXXXX:/home/bitcoin/.bitcoin/
## Go play with yourself for a bit while you wait...
## In [terminal Doc] When it's done... remove the bitcoin.conf & bitcoind.pid that you copied over,
## then move the Dojo's original bitcoin.conf and bitcoind.pid back
$ rm -rf /home/bitcoin/.bitcoin/bitcoin.conf
$ rm -rf /home/bitcoin/.bitcoin/bitcoind.pid
$ mv /home/bitcoin/bitcoin.conf /home/bitcoin/.bitcoin
$ mv /home/bitcoin/bitcoind.pid /home/bitcoin/.bitcoin
## In [terminal Doc] Change ownership of everything to bitcoin:bitcoin
$ chown bitcoin:bitcoin /home/bitcoin/.bitcoin/*
$ chown bitcoin:bitcoin /home/bitcoin/.bitcoin/blocks/*
$ chown bitcoin:bitcoin /home/bitcoin/.bitcoin/blocks/index/*
$ chown bitcoin:bitcoin /home/bitcoin/.bitcoin/chainstate/*
$ chown bitcoin:bitcoin /home/bitcoin/.bitcoin/indexes/*
$ chown bitcoin:bitcoin /home/bitcoin/.bitcoin/indexes/txindex/*
$ chown bitcoin:bitcoin /home/bitcoin/.bitcoin/wallets/*
## In [terminal Doc] Double check ownership of everything is bitcoin:bitcoin by going into each directory and executing
$ ls -la
## In [terminal Doc] Reinstall the text editor (it gets uninstalled after Dojo restart)
$ apt-get update && apt-get install nano
## In [terminal Doc] Revert your bitcoin.conf back to allow for clearnet connections
$ nano /home/bitcoin/.bitcoin/bitcoin.conf
## Remove from bitcoin.conf
onlynet=onion
dnsseed=0
dns=0
## Save and exit
ctrl+x --> y --> return
## In [termainl A] Restart the Dojo
$ cd /path/to/docker/my-dojo/ && sudo ./dojo.sh stop
$ cd /path/to/docker/my-dojo/ && sudo ./dojo.sh start
## In [terminal A] Check bitcoind progress
$ cd /path/to/docker/my-dojo/ && sudo ./dojo.sh logs bitcoind
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment