3

Say I've received some Bitcoin using the Bitcoin Core wallet on some linux machine. Say I'm done playing for now.

So now I want to free some disk space by deleting the huge database from this machine (and maybe uninstalling the program after backing up wallet.dat?), but I do not want to have to download the whole blockchain again (which took forever the first time), so I want to back it up on some external drive, so I can just copy it back when I want to use Bitcoin Core again (on the same machine or on any other).

  • What are all the files and directories that I need to copy?
  • Are there any extra steps needed to be done other than copying the files?
  • What are the steps to load the saved database to a new installation of Bitcoin Core?

This will help me with my situation, but also, I thought our community could use such a guide posted here. Thanks!

1 Answer 1

4

Ok, I think I got it. Here is a short guide based on this bitcoin wiki article.

Notes:

  1. 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.
  2. 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:
    1. .bitcoin/blocks/
    2. .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/

  1. 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.

  1. Delete the target installation's database

    rm -r blocks/ chainstate/

  2. Extract the database from backup to target installation:

    tar xfz /path/to/your/backup/blockchain_database.tar.gz

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.