Backup Bitcoin wallet.dat

Bitcoin is a fascinating subject both from the technical and social viewpoints. While there is a lot of people online talking about how to use it and whether you should use it, there seems to be far fewer people talking about how the wallet works from a backup perspective. This seems strange as your wallet contains your money and if you do not understand how it works you might loose your money.If you don't care about the WHY and just want the answer jump to the bottom of this post.

The first thing to understand is that your wallet does not contain the actual money. Your wallet contains a lot of public/private key pairs (I'm assuming you understand the basics of public/private key cryptography - if not I'll be writing something up on that soon inspired by the latest portforwardpodcast). The blockchain contains the list of who has which bitcoins.

Every time you are sent money it is sent to one of your public keys and only your private key is able to send that money on again. As your bitcoin client downloads each new block it compares it with the keys in your wallet and adds or subtracts the amounts sent to/from your keys.

This is part of the security of Bitcoin as if someone tries to send you bitcoins your client can see if they actually have those bitcoins to send by looking back through the blockchain. If everything is correct then the transaction will be included in the next block generated which is the first confirmation. By the time you have 6 confirmations you can be pretty sure the money is yours.

The public/private keys can become used in two ways so your wallet.dat file contains 100 spare keys for future use (you can change this default to anything you want). A new public/private key pair is automatically generated each time you send or receive bitcoins to help improve the anonymity of bitcoin. Each new key pair is added to the end of the list and every time a new key pair is needed the oldest spare one is used.

You can see this happening when you receive bitcoins - the client shows your current bitcoin address on its main window. When you receive some bitcoins a new address from the list of spares will become active and a new address will be generated and added to the end of the spare list. Since your wallet still contains the old address you can still receive funds sent to it without any problems.

Backup Bitcoin wallet OS X

Backup Bitcoin wallet Linux

Bitcoin wallet.dat

Bitcoin wallet dat

Backup Bitcoin wallet Mac