<p>The original move to a directory per wallet file was motivated due to an issue with the way Berkeley DB behaved when multiple databases were opened in the same database environment, which are tied to directories containing the database. In particular, the issue is that BDB creates a database environment log which contains data from all of the databases open. This creates issues with backing up and portability as database logs need to be backed up as well.</p>
<p>With the transition away from BDB to SQLite, it is possible that we move back to the old way. However current discussions around that seem to indicate that that move is unlikely.l</p>

CC BY-SA 4.0
2021-02-20T01:09:34.170Z
Interesting. Can you elaborate on why the database logs need to be backed up, though? Why are those important? Am I putting myself at risk for not using or backing up them?
Mickel S.
CC BY-SA 4.0
2021-02-20T01:27:00.430Z
BDB writes to the log before they are written to the database file. It is possible to create a situation where a record exists only in the log and not the database itself (the wallet.dat file). This is dangerous as only backing up the database file will cause you to lose anything that was only written to the log and not the database yet. So yes, you should be backing up the database logs and you are putting yourself at risk if you are not.
Ava Chow
CC BY-SA 4.0
2021-02-20T01:27:02.727Z
Bitcoin Core will try to ensure that everything from the logs is in the database file, and remove the logs afterwards. But it is possible to create a situation where the logs exist after the shutdown.
Ava Chow
CC BY-SA 4.0
2021-02-20T01:00:44.777Z
2021-02-20T01:00:44.777Z
Ava Chow
<p>I've noticed that Bitcoin Core and its API now strongly prefers to make a separate sub-dir in your datadir for each wallet, such as &quot;lukewarm&quot;, which then contains a wallet.dat, instead of just having &quot;lukewarm.dat&quot; in the data dir.</p>
<p>Why was this change made? I can't tell you how much scary work it would be for me to update my own system into this new method. I refer to my wallets by their .dat filename and that's their internal label that I use to keep track of everything in my database.</p>
<p>I know that Bitcoin Core <em>also</em> supports the old way (different-named .dat files in the data dir), but for how long? And why was this change made to begin with? It seems to create some kind of log files or something which seem to contain nothing of value. What's that about? Am I missing out by clinging to the old way? I don't understand why it wants to segment wallets into wallet.dat files in their own sub-dirs.</p>

<bitcoin-core>
Why did Bitcoin Core switch from wallet.dat, cold.dat, lukewarm.dat, etc., into "sub-dirs"?
Mickel S.
# Why did Bitcoin Core switch from wallet.dat, cold.dat, lukewarm.dat, etc., into "sub-dirs"?

(Asked by: username_0 on 2021-02-20)

I've noticed that Bitcoin Core and its API now strongly prefers to make a separate sub-dir in your datadir for each wallet, such as "lukewarm", which then contains a wallet.dat, instead of just having "lukewarm.dat" in the data dir.

Why was this change made? I can't tell you how much scary work it would be for me to update my own system into this new method. I refer to my wallets by their .dat filename and that's their internal label that I use to keep track of everything in my database.

I know that Bitcoin Core *also* supports the old way (different-named .dat files in the data dir), but for how long? And why was this change made to begin with? It seems to create some kind of log files or something which seem to contain nothing of value. What's that about? Am I missing out by clinging to the old way? I don't understand why it wants to segment wallets into wallet.dat files in their own sub-dirs.

**Tags:** bitcoin-core


---

## 1 answers

### Answer by username_1 on 2021-02-20. Score: 1

The original move to a directory per wallet file was motivated due to an issue with the way Berkeley DB behaved when multiple databases were opened in the same database environment, which are tied to directories containing the database. In particular, the issue is that BDB creates a database environment log which contains data from all of the databases open. This creates issues with backing up and portability as database logs need to be backed up as well.

With the transition away from BDB to SQLite, it is possible that we move back to the old way. However current discussions around that seem to indicate that that move is unlikely.l

> **Comments:**
> **username_0**: Interesting. Can you elaborate on why the database logs need to be backed up, though? Why are those important? Am I putting myself at risk for not using or backing up them?  
> **username_1**: BDB writes to the log before they are written to the database file. It is possible to create a situation where a record exists only in the log and not the database itself (the wallet.dat file). This is dangerous as only backing up the database file will cause you to lose anything that was only written to the log and not the database yet. So yes, you should be backing up the database logs and you are putting yourself at risk if you are not.  
> **username_1**: Bitcoin Core will try to ensure that everything from the logs is in the database file, and remove the logs afterwards. But it is possible to create a situation where the logs exist after the shutdown.  

---

