Author

Topic: bitcoin core wallet backup and wallet.dat file question. how to confirm? (Read 355 times)

HCP
legendary
Activity: 2086
Merit: 4363
When you "encrypt the wallet.dat", you're not actually doing a full file encryption. You are only encrypting certain records in the database file (for instance, the private keys, seed etc).

Other records like public keys, addresses etc are not encrypted. This is why you can start Bitcoin Core and load a wallet file without the wallet password. The password is only required for any actions that require the private keys to be decrypted (signing a transaction, signing a message, dumping private keys etc)

There are other wallets that do use a full file encryption option... Electrum is an example of this. If the full file encryption option is used, you cannot open the wallet at all without the wallet password.
newbie
Activity: 24
Merit: 21
that thought hit me after i posted that question, but good to confirm. thank you all so much. i am genuinely thankful for you all taking the time to answer my questions. this had helped me a lot.
legendary
Activity: 3290
Merit: 16489
Thick-Skinned Gang Leader and Golden Feather 2021
there was never a point at which i was asked for the passcode. i did encrypt the wallets before i backed them up. is that normal?
The password is for sending Bitcoin, not for viewing addresses. If you try for instance to dump a private key, it won't work without entering the password.

From Bitcoin Core Console:
Code:
dumpprivkey "address"

Reveals the private key corresponding to 'address'.
Then the importprivkey can be used with this output

Arguments:
1. address    (string, required) The bitcoin address for the private key

Result:
"str"    (string) The private key

Examples:
> bitcoin-cli dumpprivkey "myaddress"
> bitcoin-cli importprivkey "mykey"
> curl --user myusername --data-binary '{"jsonrpc": "1.0", "id": "curltest", "method": "dumpprivkey", "params": ["myaddress"]}' -H 'content-type: text/plain;' http://127.0.0.1:8332/
 (code -1)
Code:
walletpassphrase "passphrase" timeout

Stores the wallet decryption key in memory for 'timeout' seconds.
This is needed prior to performing transactions related to private keys such as sending bitcoins

Note:
Issuing the walletpassphrase command while the wallet is already unlocked will set a new unlock
time that overrides the old one.

Arguments:
1. passphrase    (string, required) The wallet passphrase
2. timeout       (numeric, required) The time to keep the decryption key in seconds; capped at 100000000 (~3 years).

Result:
null    (json null)

Examples:

Unlock the wallet for 60 seconds
> bitcoin-cli walletpassphrase "my pass phrase" 60

Lock the wallet again (before 60 seconds)
> bitcoin-cli walletlock

As a JSON-RPC call
> curl --user myusername --data-binary '{"jsonrpc": "1.0", "id": "curltest", "method": "walletpassphrase", "params": ["my pass phrase", 60]}' -H 'content-type: text/plain;' http://127.0.0.1:8332/
 (code -1)
newbie
Activity: 24
Merit: 21
thank you.

finally got around to testing the backups and they work. was able to confirm the same receive addresses showed up. however, there was never a point at which i was asked for the passcode. i did encrypt the wallets before i backed them up. is that normal?
legendary
Activity: 3290
Merit: 16489
Thick-Skinned Gang Leader and Golden Feather 2021
seems easier/faster to just copy that over instead of downloading it all again.
As long as you trust the source, you can do that. Don't forget the chainstate directory.
newbie
Activity: 24
Merit: 21
no, i meant the blockchain data (400 gigs or whatever) on the initial download. seems easier/faster to just copy that over instead of downloading it all again.
legendary
Activity: 2618
Merit: 6452
Self-proclaimed Genius
also, is there a way to back up the blockchain info and save those so i don't have to download the entire thing each time i set up a node?
"Blockchain info"? You're not talking about the online wallet with the same name, right?

For the blockchain and other data, just copy the entire data directory to your other computer (same directory) and it should run fully synced.
The default data directory is in: https://en.bitcoin.it/wiki/Data_directory#Default_Location
Exclude the "wallets" folder if you do not want to copy the wallets.
newbie
Activity: 24
Merit: 21
also, is there a way to back up the blockchain info and save those so i don't have to download the entire thing each time i set up a node?
newbie
Activity: 24
Merit: 21
sorry, had another question i figured id ask here.

i bought a second computer (computer 2) to just load btc core (not DL the whole block chain) and test my back ups. i know some of you said thats not necessary but i figured it doesn't hurt going through all the steps again for familiarity. anyway, once i do that and test the back ups, i may want to use computer 2 to run a full node all the time. currently my plain was to run the first computer to set up my btc core wallets, move btc, and shut it down.

if i restore the wallets on computer 2 to test, should i then remove those back ups and not have a wallet set up on computer 2 at all for security purposes or does it matter since i have back ups and the back ups are encrypted.

sorry if this the question is not clear.
newbie
Activity: 24
Merit: 21
again, thank you all. this has all helped a lot.
legendary
Activity: 3290
Merit: 16489
Thick-Skinned Gang Leader and Golden Feather 2021
Take note the way you exit Bitcoin Core doesn't matter (unless you use command kill), using shortcut Alt+F4 or press "X" on Bitcoin Core window will also show the pop up.
I've enabled "Options > Minimize on close", that's why Wink
legendary
Activity: 2870
Merit: 7490
Crypto Swap Exchange
how do I ensure Bitcoin core isn’t running when I go to copy the .dat files? I have been using qt and so I can “exit” it and I assume that closes it and stops it running but being new to Ubuntu I’m not sure.
If you exit Bitcoin Core (right mouse on the system tray icon), it gives a popup telling you to wait until it's done. Once the popup disappears, you're good to go.

Take note the way you exit Bitcoin Core doesn't matter (unless you use command kill), using shortcut Alt+F4 or press "X" on Bitcoin Core window will also show the pop up.



But if you're being very careful / paranoid, you could use this command (on terminal) to check if Bitcoin Core is still running.

Code:
ps aux | grep bitcoin

If Bitcoin Core (and other application name which contain "bitcoin") isn't running, the result should look like this.

Code:
user   157604  0.0  0.0   6256  2376 pts/1    S+   09:53   0:00 grep bitcoin
legendary
Activity: 3290
Merit: 16489
Thick-Skinned Gang Leader and Golden Feather 2021
how do I ensure Bitcoin core isn’t running when I go to copy the .dat files? I have been using qt and so I can “exit” it and I assume that closes it and stops it running but being new to Ubuntu I’m not sure.
If you exit Bitcoin Core (right mouse on the system tray icon), it gives a popup telling you to wait until it's done. Once the popup disappears, you're good to go.
newbie
Activity: 24
Merit: 21
This has all been very helpful, assuming I am understanding you all. Thank you.

This is another very noob question, but how do I ensure Bitcoin core isn’t running when I go to copy the .dat files? I have been using qt and so I can “exit” it and I assume that closes it and stops it running but being new to Ubuntu I’m not sure.
legendary
Activity: 3290
Merit: 16489
Thick-Skinned Gang Leader and Golden Feather 2021
when you say "I create all my backups on a file system level" do you mean you are backing up your entire linux? or the entire .bitcoin folder?
I don't care about the system files, usually I just backup my entire home directory. It does help I've symlinked my blocks directory to another drive, so that's easily excluded.

You should never delete a wallet.

You can do that but only if Bitcoin Core isn't running or your backup could be corrupted (with low chance).
That is a slight risk indeed. I make sure I have enough backups anyway.

each wallets are inside a folder with a 'wallet name', then you don't have to rename them in the first place, the wallet name is that folder's name.
I'm old fashioned, still having multiple different .dat files in my .bitcoin directory instead of their own subdirectories.
legendary
Activity: 2618
Merit: 6452
Self-proclaimed Genius
alright. so i found the wallets folder that has folders for both wallets i created. i can open each folder and now locate each "wallet.dat" file for each individual wallet. couple more questions

1) is there any reason i shouldn't just copy the entire "wallets" folder and save it to a few flash drives and burn it to a dvd, instead of ONLY the "wallet.dat" files themselves?
You can do that but only if Bitcoin Core isn't running or your backup could be corrupted (with low chance).

Quote from: fasttimes
2) for each "wallet.dat" file, i can change the name in front of ".dat" and it won't affect the file, but i would need to change it back to "wallet.dat" when try to restore, correct?
If you did the above, and each wallets are inside a folder with a 'wallet name', then you don't have to rename them in the first place, the wallet name is that folder's name.
If you rename the wallet.dat inside it, the folder wont work as a wallet and you won't be able to select it in "Open Wallet" menu.

Otherwise, you can rename the wallet.dat files and put them inside "wallets" folder (but outside of any folders inside)
and it will be available for selection in the "Open Wallet" menu even if they have a different name (your "wallet_name.dat" backups from "File->Backup Wallet" for example).
newbie
Activity: 24
Merit: 21
alright. so i found the wallets folder that has folders for both wallets i created. i can open each folder and now locate each "wallet.dat" file for each individual wallet. couple more questions

1) is there any reason i shouldn't just copy the entire "wallets" folder and save it to a few flash drives and burn it to a dvd, instead of ONLY the "wallet.dat" files themselves?

2) for each "wallet.dat" file, i can change the name in front of ".dat" and it won't affect the file, but i would need to change it back to "wallet.dat" when try to restore, correct?

3)

I've never used Bitcoin Core's File > Backup Wallet... feature, but instead always just manually copy my wallet.dat (ideally when Bitcoin Core is not running). , so I see no reason to make an exception for Bitcoin Core.

It is good practice to actually test your backup before relying on it. Testing is as simple as running it in Bitcoin Core.

when you say "I create all my backups on a file system level" do you mean you are backing up your entire linux? or the entire .bitcoin folder?

and when you say "testing is as simple as running it in bitcoin core" are you saying just change out the existing wallet.dat file with the one in just copied?
legendary
Activity: 3290
Merit: 16489
Thick-Skinned Gang Leader and Golden Feather 2021
and there should be address even if all ive done is create the wallet(s) and not used/received any btc to them?
I just tested in a new wallet: "Receiving addresses" is empty.
But if you click the Receive tap in Bitcoin Core, followed by "Create new receiving address", the wallet creates one. And those should be the same if you load a backup on different systems.
newbie
Activity: 24
Merit: 21
and there should be address even if all ive done is create the wallet(s) and not used/received any btc to them?
legendary
Activity: 3472
Merit: 3217
Playbet.io - Crypto Casino and Sportsbook
so if i want to from scratch i get a separate laptop, load btc core on there from a flashdrive (no internet) and then restore the wallet to that new instance of btc core? if the wallet name shows up in btc core, there the backup worked? is that correct?

No, not the wallet name it should be the address on that backup wallet.
So you need to check the addresses under window>receiving addresses new tab will pop up with the list of Bitcoin address.

Sample this one


Under that tab you can see the address on the right side it should be the same after you import the backup file to another laptop.
newbie
Activity: 24
Merit: 21
thank you all. this is very helpful.


It depends: it doesn't hurt to be overly thorough and start from scratch to see if you can restore everything from just the backup you made on a USB stick. I've actually done that years ago, but I don't do it anymore. It helped me believe my backup was enough Smiley
Note that a few more backups is better, just in case the USB stick breaks (after a while). I prefer to use different brands.

so if i want to from scratch i get a separate laptop, load btc core on there from a flashdrive (no internet) and then restore the wallet to that new instance of btc core? if the wallet name shows up in btc core, there the backup worked? is that correct?
legendary
Activity: 3290
Merit: 16489
Thick-Skinned Gang Leader and Golden Feather 2021
If your "hold wallet" is cold storage, for instance a paper wallet, a single address is indeed easy. But it's better for privacy to use a new address each time, and it's less risky to use a different paper wallet each time you add funds. That way you don't expose all your funds when you want to send a small part of it later on.
but isn;t a single address how these hardware wallets work? im way more nervous about having 50 different address and key pairs and losing 1 or more than keeping up with and securing  a single address and key pair.
Most (if not all) hardware wallets use more than one address. You don't need to backup each individual private key, they're all derived from the same (24) mnemonic seed words.
But that has nothing to do with Bitcoin Core.

Quote
so i can test the wallet backup in btc core without having to have a second computer running core?
It depends: it doesn't hurt to be overly thorough and start from scratch to see if you can restore everything from just the backup you made on a USB stick. I've actually done that years ago, but I don't do it anymore. It helped me believe my backup was enough Smiley
Note that a few more backups is better, just in case the USB stick breaks (after a while). I prefer to use different brands.
legendary
Activity: 2618
Merit: 6452
Self-proclaimed Genius
one last question that is a bit different. the only way to have one private key/public key pair for a particular wallet is to only have a single receive address, correct? i plan to set up a temporary wallet and then a hodl wallet for long term saving. for the hodl wallet, only having one address and one public/private key pair would be ok and simpler to keep track of if my short and medium term plan is to only fill the wallet and not spend, yes?
Will the funds be coming from a single source?
If yes, then I think it's fine to use a single address for the "hodl wallet", eg. ExchangeA -> hodl wallet's address;
but not if it's coming from multiple sources like your "temporary wallet" and exhanges, because you might end up linking those sources to each other and to your hodl wallet.

how often is it recommended to make a new back up copy of the wallet.dat file?
If says "HD" at the lower-right (says "HD key generation is enabled" when hovered), your current backup is enough to restore the newly derived addresses.
But if you want to keep the labels updated, update your backup as well.
legendary
Activity: 3472
Merit: 3217
Playbet.io - Crypto Casino and Sportsbook
how often is it recommended to make a new back up copy of the wallet.dat file?

2 to 3 times to make sure that you created a backup copy and make sure to put them in a separate folder if you have extra USB/HDD put it there and make sure to don't connect it to any device connected to the internet and test it 2 to 3 times to confirm that you have your original wallet.

I recently test to make a backup on the GUI using file>backup wallet it pops up and asks to give a wallet name after generated a wallet file it has a .dat file at the end so it means that on the Linux it doesn't show .dat at the end of the wallet file generated without using ls -a command it won't show the file extension.
newbie
Activity: 24
Merit: 21
thank you all very much for the responses. i just need to make absolutely sure i have the wallet.dat file/files for each wallet and several copies and i should be good to go. then i can test each back up to ensure its correct.

how often is it recommended to make a new back up copy of the wallet.dat file?
legendary
Activity: 2744
Merit: 3097
Top Crypto Casino
but isn;t a single address how these hardware wallets work? im way more nervous about having 50 different address and key pairs and losing 1 or more than keeping up with and securing  a single address and key pair. but again, im trying to figure this all out and not lose any coin in the process.
Bitcoin core wallets are deterministic wallets, meaning that all key pairs are derived from one seed. Therefore, you only need to back up is the wallet file and every time you restore that wallet you will get the same addresse. So, you don't have to back up each key pair individually.

Quote
so i can test the wallet backup in btc core without having to have a second computer running core?
Yes, just open the back up file and see if you get the same wallet.
newbie
Activity: 24
Merit: 21

Are you also a "super n00b" on Ubuntu? If so, you should make sure to understand what you're doing before funding the wallet with any substantial amount.

Yes, this is the first time i am using ubuntu solely for the purposes of trying to run a node to take custody of btc myself. im trying to learn. seems like this is the method least reliant on others, but it seems fairly cumbersome and tedious.


Ubuntu will show this as Trash in the file manager, with a trash bin icon. The real question is how you managed to trash your backup without knowing it!

yes, great question. i have no idea. i simply used the file>back up and then copied those files to a flashdrive. thats why im on here, trying to figure all this out. its not all exactly straightforward, but i appreciate folks responding here.


If your "hold wallet" is cold storage, for instance a paper wallet, a single address is indeed easy. But it's better for privacy to use a new address each time, and it's less risky to use a different paper wallet each time you add funds. That way you don't expose all your funds when you want to send a small part of it later on.

but isn;t a single address how these hardware wallets work? im way more nervous about having 50 different address and key pairs and losing 1 or more than keeping up with and securing  a single address and key pair. but again, im trying to figure this all out and not lose any coin in the process.


I've never used Bitcoin Core's File > Backup Wallet... feature, but instead always just manually copy my wallet.dat (ideally when Bitcoin Core is not running). I create all my backups on a file system level, so I see no reason to make an exception for Bitcoin Core.
It is good practice to actually test your backup before relying on it. Testing is as simple as running it in Bitcoin Core.

so i can test the wallet backup in btc core without having to have a second computer running core?

legendary
Activity: 3290
Merit: 16489
Thick-Skinned Gang Leader and Golden Feather 2021
I now want to back up these wallets so that i can make copies of the backups and not lose my coins. I have the following questions as i am very unsure how to know for certain if have everything properly backed up and saved.
I've never used Bitcoin Core's File > Backup Wallet... feature, but instead always just manually copy my wallet.dat (ideally when Bitcoin Core is not running). I create all my backups on a file system level, so I see no reason to make an exception for Bitcoin Core.
It is good practice to actually test your backup before relying on it. Testing is as simple as running it in Bitcoin Core.
super noob here
Are you also a "super n00b" on Ubuntu? If so, you should make sure to understand what you're doing before funding the wallet with any substantial amount.

i understand i can use the terminal and commands but im not familiar with doing that.
The terminal is the best thing Linux has to offer: I often use it, even though there's a graphical alternative. Once you understand the basics, it's fast and powerful.

when looking at the back up on a windows computer i did find a folder called .trash and in it was the .dat file for the wallet i backed up up "walletname".dat. so at least i know what im looking for now.

this is all in ubuntu, which i am completely new to, so perhaps it was hidden folder which can be made visible with a setting change.
Ubuntu will show this as Trash in the file manager, with a trash bin icon. The real question is how you managed to trash your backup without knowing it!

Quote
one last question that is a bit different. the only way to have one private key/public key pair for a particular wallet is to only have a single receive address, correct? i plan to set up a temporary wallet and then a hodl wallet for long term saving. for the hodl wallet, only having one address and one public/private key pair would be ok and simpler to keep track of if my short and medium term plan is to only fill the wallet and not spend, yes?
If your "hold wallet" is cold storage, for instance a paper wallet, a single address is indeed easy. But it's better for privacy to use a new address each time, and it's less risky to use a different paper wallet each time you add funds. That way you don't expose all your funds when you want to send a small part of it later on.
newbie
Activity: 24
Merit: 21
Thank you both very much.

for whatever reason when i backed up the wallets (file>backup wallet) what was created and visible was a single file that was not a .dat file. later when looking at the back up on a windows computer i did find a folder called .trash and in it was the .dat file for the wallet i backed up up "walletname".dat. so at least i know what im looking for now.

this is all in ubuntu, which i am completely new to, so perhaps it was hidden folder which can be made visible with a setting change. either way, i think i have my plan now and will know how to test to make sure it works.

one last question that is a bit different. the only way to have one private key/public key pair for a particular wallet is to only have a single receive address, correct? i plan to set up a temporary wallet and then a hodl wallet for long term saving. for the hodl wallet, only having one address and one public/private key pair would be ok and simpler to keep track of if my short and medium term plan is to only fill the wallet and not spend, yes?

thanks again for the responses.
legendary
Activity: 2618
Merit: 6452
Self-proclaimed Genius
2) I have actually created a backup file already, but the backup file that is created does not seem be a .dat file. when i save it to a USB stick or DVR and look at the file on a windows computer the file type says "21 file". is that correct or is the back up more than just the .dat which would be contained in the overall backup file?
Windows has an option to hide/show the file extension but since it says "Type: 21 file", it means that the extension isn't ".dat" which shouldn't be the case with "File->Backup Wallet".
You can display the extension in Windows in the 'file explorer' menu "View->File Name Extensions".

however, i suppose that is how i need to do it to make absolutely sure i have the right file/files. If i have two wallets created/set up, will each wallet have its own wallet.dat file? if so, how do i tell them apart? sorry, i know these are likely very basic questions.
Yes, 1 wallet = 1 backup with ".dat" extension.
You can set a name when you use "File->Backup wallet" but make sure that the correct wallet is selected in the "Wallet:" drop-down menu at the right,
you can also set a wallet name during wallet creation (in the later versions). IMO, naming those differently is enough to tell them apart from each other.
newbie
Activity: 24
Merit: 21
i did not go into any folder to get the wallet.dat file, i simply used the bitcoin-qt interface and used file > backup wallet and then saved that file to the documents folder, then copied to a USB stick.

i understand i can use the terminal and commands but im not familiar with doing that.

however, i suppose that is how i need to do it to make absolutely sure i have the right file/files. If i have two wallets created/set up, will each wallet have its own wallet.dat file? if so, how do i tell them apart? sorry, i know these are likely very basic questions.

getting a second computer to restore the backups sounds like a good idea as well. that will ensure i did everything correctly if i can restore to a new set up.
legendary
Activity: 3472
Merit: 3217
Playbet.io - Crypto Casino and Sportsbook
All question seems a bit the same they are all talks about the backup file.

What do I want to know is if what folder did you get the backup file?

The wallet file should have extension .dat  unless if your Windows Computer hide all extension that is why it doesn't show .dat file.
To find the bitcoin core wallet.dat file you can find the right folder under this path below

Code:
~/.bitcoin/

You should use this command below to see the file extension

Code:
ls -a
Then look for wallet.dat the name it was created by default


If you want to verify your backup you must have another device offline and install bitcoin core then import it there so that you can check if the addresses there are the same as what you see on the original wallet.
And I think it would be better if you could also dump the private keys of all addresses since you run it offline then it is safe to dump the private keys of each wallet you created.
newbie
Activity: 24
Merit: 21
super noob here. i have set up linux ubuntu on an old laptop. i have installed bitcoin core, verified, and DL'd the blockchain this past week (most up to date version). once the blockchain downloaded, i shut down btc core and the laptop and disconnected from the internet (for security?). then i restarted the laptop and btc core and created two wallets in btc core and encrypted both wallets and saved/protected the passcode.

I now want to back up these wallets so that i can make copies of the backups and not lose my coins. I have the following questions as i am very unsure how to know for certain if have everything properly backed up and saved.

1) by opening each wallet and selecting "backup wallet", will the file that is created be EVERYTHING i need in the event the laptop crashes or i have restore this wallet to a new computer?

2) I have actually created a backup file already, but the backup file that is created does not seem be a .dat file. when i save it to a USB stick or DVR and look at the file on a windows computer the file type says "21 file". is that correct or is the back up more than just the .dat which would be contained in the overall backup file?

3) is there a way, to confirm the back up i have made will actually work if it is actually needed? meaning, is there a way to test my backup?

4) my understanding is that if the BTC core wallet has "HD" in the bottom right, i don't need to dump the private keys, as the backup/wallet.dat file will have all that info. is this correct or do i need to make a physical backup of every private key as well.

thank you ahead of time. i really have searched for answers ahead of time, but i don't know what i don't know and not being able to recover things makes me extremely nervous.
Jump to: