Error: Wallet backup failed! (code -4) when setting up bitcoin-qt for first time 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?

&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)


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"
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

&lt;date + time&gt; error copying wallet.dat to &lt;path&gt; - &lt;kind of error&gt;


This is the most common type of error:

error copying wallet.dat to &lt;dest&gt; - boost::filesystem::copy_file: Access is denied: "&lt;src&gt;", "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\&lt;username&gt;\AppData\Roaming\Bitcoin\wallet.backup"


instead.