Bitcoin Forum
April 27, 2024, 03:21:07 AM *
News: Latest Bitcoin Core release: 27.0 [Torrent]
 
  Home Help Search Login Register More  
  Show Posts
Pages: [1]
1  Other / Beginners & Help / Managing and protecting my wallets on: June 12, 2011, 01:51:22 PM
So, I was trying to participate in this thread: http://forum.bitcoin.org/index.php?topic=15068.0, and I couldn't find the reply button. After a few minutes, I realized I was relegated to this ghetto. So, I figured I'd post what I was going to post here.

Here's the ruby script I use to backup my wallet.dat file

Code:
require 'rubygems'
require 'zip/zip'  # http://rubyzip.sourceforge.net/

now = Time.now

wallet_location = '~/Library/Application Support/Bitcoin/wallet.dat'
backup_folder = '~/backups/bitcoin'

puts "Please ensure the Bitcoin client is not running"
print "Wallet name: "
wallet_name = gets.strip

backup_zip = "wallet-backup_#{wallet_name}_#{now.strftime('%Y-%m-%d')}_#{now.to_i}.zip"
backup_wallet = "wallet.dat.#{now.strftime('%Y-%m-%d')}.#{wallet_name}.aes-256-cbc"

md5 = `md5 -l -n #{wallet_location}`.strip

`openssl aes-256-cbc -a -salt -in #{wallet_location} -out #{backup_folder}/#{backup_wallet}`


info = <<EOF
Wallet MD5: #{md5}
Wallet Name: #{wallet_name}

Decryption command:
openssl aes-256-cbc -d -a -salt -in #{backup_wallet} -out wallet.dat
EOF

zip = Zip::ZipFile.open("#{backup_folder}/#{backup_zip}", true)
zip.get_output_stream(backup_wallet) { |f| f.puts(File.read("#{backup_folder}/#{backup_wallet}")) }
zip.get_output_stream('info.txt') { |f| f.puts(info) }
zip.close

File.delete("#{backup_folder}/#{backup_wallet}")

This script is based on a bash backup script found here: https://github.com/mrkva/BitcoinBackup.sh/blob/master/BitcoinBackup.sh I prefer ruby though, so I re-wrote it.

This script encrypts and backs up my wallet. It includes instructions of how to decrypt it, and an md5 hash of the decrypted wallet for verification purposes. After running the script, I upload the wallet to gmail and save it to a backup disk. I also verify that I can fully decrypt and access the wallet by decrypting it on a different computer with a fresh install of bitcoins.

What processes to others use to manage their wallet backups?
2  Bitcoin / Bitcoin Technical Support / [SOLVED]Lost some Bitcoins, what did I do wrong? on: June 11, 2011, 06:52:23 AM
I seemed to have lost some bitcoins, only 0.01, so not really a big deal, but this scares me. I'd like to get a better understanding of exactly where I went wrong. Here's the steps I followed:

1. Closed my Bitcoin client.
2. Copied wallet.dat to wallet-savings.dat
3. Transferred 0.01 BTC from my BTC Guild account to an address from wallet.dat.
4. Copied wallet-savings.dat over wallet.dat.
5. Opened up my Bitcoin client, and waited until the transaction showed up. After the blockchain caught up, the transaction, and the 0.01 BTC were there.
6. Closed my bitcoin client, and copied wallet-savings.dat over wallet.dat.
7. Re-opened my bitcoin client - this time the transaction never showed up. It's been a few hours now, and the transaction still isn't there - I seem to have lost that 0.01 BTC forever.

Obviously, step 6 was where I went wrong. I should never have just overwritten my wallet.dat. However, I did it somewhat intentionally, since I figured that the transaction should show up again, and I wanted to test that hypothesis.

So, what happened? If restoring from backup in step 4 didn't mess anything up, why did it break when I overwrote it the second time?

Thanks for any help. I'd really like to understand this so I don't mess anything up when dealing with larger amount of bitcoins.
Pages: [1]
Powered by MySQL Powered by PHP Powered by SMF 1.1.19 | SMF © 2006-2009, Simple Machines Valid XHTML 1.0! Valid CSS!