Ok, I think I got it.
Here is a short guide based on this bitcoin wiki article.
Notes:
- This does not concern backing up your keys. If you lost your wallet, or your keys, and you made the backup discussed here beforehand, this backup will not help you recover your lost coins. This will only save you some bandwidth/time/storage.
- Don't load a database to your node unless you absolutely 100% trust the integrity of that database copy:
when you copy someone's database in this way, you are trusting them
absolutely. Bitcoin Core treats its block database files as 100%
accurate and trustworthy, whereas during the normal initial sync it
treats each block offered by a peer as invalid until proven otherwise.
If an attacker is able to modify your block database files, then they
can do all sorts of evil things which could cause you to lose
bitcoins. Therefore, you should only copy block databases from Bitcoin
installations under your personal control, and only over a secure
connection.
Answers to the questions in the post
- The directories that need to be (fully) copied are:
.bitcoin/blocks/
.bitcoin/chainstate/
- No extra steps needed to be done in order to just back-up the database. (This does not cover backing up your own bitcoin and keys, also there are extra steps in order to also load the database to another installation, read on to the next point)
- In order to load a saved database to another installation, first delete the database of the target installation, than copy the backed up blockchain database files in their place.
Detailed guide
I'm going to assume that you're in your target installation's folder (probably ~/.bitcoin
) so this is the time to do
cd /path/to/your/target/installation/folder/.bitcoin/
Back up your database:
first, make sure this node is shut off. than make the backup:
tar cfz /path/to/your/backup/blockchain_database.tar.gz blocks/ chainstate/
Now you have a backup of the database. You are probably going to take this backup to some other computer, or just keep it somewhere and than do the next steps when you want to load the database to some other node.
now again, make sure that the relevant node is shut off.
Delete the target installation's database
rm -r blocks/ chainstate/
Extract the database from backup to target installation:
tar xfz /path/to/your/backup/blockchain_database.tar.gz