I've search for this problem a bit, but I had bad luck
despite of this, I'm sure it stands somewhere. So, sorry if I repeat the topic.
Yesterday I accidentally wipe off the file 'wallet.dat'. No problem: I took my backup and restored it. My backup was a bit old, so when I restarted bitcoin, the addresses stay but the balance, with all operations made after backup, blew up. The reason is, because bitcoin uses the same file, 'wallet.dat' to keep private keys, public keys and transactions.
The only solution I've found for restoring the balance was restart bitcoin in a new folder (conserving 'wallet.dat' and 'bitcoin.conf') and wait several hours for the block-data rebuild up.
So the question is: is there any more clever way to restore the balance!? The information about transactions is in the block chain, available to the program; I think the client program should have an option "rescan the blockchain" or similar for such occasions. And, even better, keep the transaction file away from priv. keys!