<p>I've looked at Bitcoin's <code>backupwallet</code> code, and that error is triggered by a filesystem error. I can't tell what kind of filesystem error it is, though. Please open debug.log in the Bitcoin directory. There should be a line like</p>

<pre><code>&lt;date + time&gt; error copying wallet.dat to &lt;path&gt; - &lt;kind of error&gt;
</code></pre>

<p>This is the most common type of error:</p>

<pre><code>error copying wallet.dat to &lt;dest&gt; - boost::filesystem::copy_file: Access is denied: "&lt;src&gt;", "wallet.backup"
</code></pre>

<p>This means Bitcoin is trying to backup your wallet to C:\Program Files\Bitcoin. You don't have the permissions to backup there. To fix this, run </p>

<pre><code>backupwallet "C:\Users\&lt;username&gt;\AppData\Roaming\Bitcoin\wallet.backup"
</code></pre>

<p>instead.</p>

CC BY-SA 3.0
2015-01-28T04:04:52.390Z
2016-08-29T19:31:41.207Z
2016-08-29T19:31:41.207Z
Nick ODell
<p>Running both the terminal that is running the "bitcoind" command and the terminal that runs the backup command  with administrator privileges worked for me, saving in the "daemon" default folder.</p>

CC BY-SA 4.0
2018-07-22T02:22:22.707Z
2018-07-22T02:22:22.707Z
Willian Rigo
<p>I downloaded and ran bitcoin-qt to play around with.</p>

<p>First thing I did was create a wallet passphrase. </p>

<p>The second thing I did was try to create a wallet backup.</p>

<p>Then I got this message:
Error: Wallet backup failed! (code -4)</p>

<p>If I simply delete the wallet file (no coins on it yet) and then restart bitcoin, everything works fine.  But if I try to encrypt the wallet and then create a backup I get the error again.</p>

<p>What am I missing?</p>

<pre><code>&gt;getinfo
{
"version" : 90300,
"protocolversion" : 70002,
"walletversion" : 60000,
"balance" : 0.00000000,
"blocks" : 340782,
"timeoffset" : -3,
"connections" : 8,
"proxy" : "",
"difficulty" : 41272873894.69702100,
"testnet" : false,
"keypoololdest" : 1422415118,
"keypoolsize" : 101,
"unlocked_until" : 1422419612,
"paytxfee" : 0.00000000,
"relayfee" : 0.00001000,
"errors" : ""
}

&gt;backupwallet wallet.backup
Error: Wallet backup failed! (code -4)
</code></pre>

<p>When looking at the debug.log file I see this error:</p>

<pre><code>2015-01-27 16:07:36 error copying wallet.dat to wallet.backup - boost::filesystem::copy_file: Access is denied: "C:\Users\Matthew\AppData\Roaming\Bitcoin\wallet.dat", "wallet.backup"
</code></pre>

<bitcoin-core><wallet><backup><rpc-error-4>
Error: Wallet backup failed! (code -4) when setting up bitcoin-qt for first time
theporpoise
# Error: Wallet backup failed! (code -4) when setting up bitcoin-qt for first time

(Asked by: username_0 on 2015-01-28)

I downloaded and ran bitcoin-qt to play around with.

First thing I did was create a wallet passphrase.

The second thing I did was try to create a wallet backup.

Then I got this message:
Error: Wallet backup failed! (code -4)

If I simply delete the wallet file (no coins on it yet) and then restart bitcoin, everything works fine. But if I try to encrypt the wallet and then create a backup I get the error again.

What am I missing?

```
>getinfo
{
"version" : 90300,
"protocolversion" : 70002,
"walletversion" : 60000,
"balance" : 0.00000000,
"blocks" : 340782,
"timeoffset" : -3,
"connections" : 8,
"proxy" : "",
"difficulty" : 41272873894.69702100,
"testnet" : false,
"keypoololdest" : 1422415118,
"keypoolsize" : 101,
"unlocked_until" : 1422419612,
"paytxfee" : 0.00000000,
"relayfee" : 0.00001000,
"errors" : ""
}

>backupwallet wallet.backup
Error: Wallet backup failed! (code -4)

```

When looking at the debug.log file I see this error:

```
2015-01-27 16:07:36 error copying wallet.dat to wallet.backup - boost::filesystem::copy_file: Access is denied: "C:\Users\Matthew\AppData\Roaming\Bitcoin\wallet.dat", "wallet.backup"

```

**Tags:** bitcoin-core, wallet, backup, rpc-error-4


---

## 2 answers

### Answer by username_1 on 2015-01-28. Score: 3 | Accepted answer

I've looked at Bitcoin's `backupwallet` code, and that error is triggered by a filesystem error. I can't tell what kind of filesystem error it is, though. Please open debug.log in the Bitcoin directory. There should be a line like

```
<date + time> error copying wallet.dat to <path> - <kind of error>

```

This is the most common type of error:

```
error copying wallet.dat to <dest> - boost::filesystem::copy_file: Access is denied: "<src>", "wallet.backup"

```

This means Bitcoin is trying to backup your wallet to C:\Program Files\Bitcoin. You don't have the permissions to backup there. To fix this, run

```
backupwallet "C:\Users\<username>\AppData\Roaming\Bitcoin\wallet.backup"

```

instead.


---

### Answer by username_2 on 2018-07-22. Score: 0

Running both the terminal that is running the "bitcoind" command and the terminal that runs the backup command with administrator privileges worked for me, saving in the "daemon" default folder.


---

