Cryptocoin Mining on Mac OS X – Wallet Backups

If you’ve taken cryptocoin mining beyond the hobby stages, you probably have at least one digital wallet on your system – possibly several. What happens if your OS were to crash? If you were to reinstall? Where would your accumulated cryptocurrency be?

Gone.

It is very important that you backup the private keys that secure your digital wallet so that you can restore them at a later time. Otherwise the keys required to claim ownership of your coins will be gone forever. It is also important that you backup your wallets regularly. It is not enough to backup your keys just once. See this entry on securing the bitcoind wallet for more details.

So what steps can you take on Mac OS X to keep your wallets backed up? Luckily OS X comes with several tools that help along the way. Additionally, the Unix foundation of OS X allows us to fall back on some time-tested solutions for this project.

Step One – Create an Encrypted Disk Image

Step one will be to create an encrypted disk image used to store the wallet.dat backups. This is what Steve Gibson refers to as “Pre-Internet Encryption” – encrypting important data before backing it up to the Web.

  1. Launch Disk Utility from the Applications folder
  2. Click New Image
  3. Save the image somewhere that is itself backed up (e.g. Dropbox or Wuala)
  4. For the name, specify Wallet Backups (so that the below scripts match)
  5. For Encryption, select either 128 or 256 (256 is more secure and should be plenty fast for this)
  6. Click Create

New Disk Image

Step Two – Create a Backup Script

Now that we have a secure place to store wallet backups, the next step is to create a script that will do the grunt-work. Namely it should mount the encrypted disk image, backup any wallet.dat files (we could have Bitcoin, Litecoin, and who knows what other digital wallets – get them all), and then unmount the encrypted image.

We can do all of this with Automator and a couple of shell scripts.

  1. Launch Automator from the Applications folder
  2. Select Application and click Choose
  3. Add a Get Specified Finder Items action
  4. Select the DMG file created in Step One
  5. Add a Mount Disk Image action
  6. Add a Run Shell Script action and enter:
    cd ~/Library/Application\ Support && rsync -R ./*/wallet.dat /Volumes/Wallet\ Backups/
  7. Add another Run Shell Script action and enter:
    diskutil unmount /Volumes/Wallet\ Backups/
  8. Click File, Save
  9. Save as BackupWallets.app in Applications

Complete Automator Application

Step Three – Schedule the Backup

Armed with encrypted storage and a backup script, the only thing left is to schedule the backup. The Unix foundation of OS X means we can do this by editing the system crontab, a configuration file that specifies the commands to run for cron, the Unix job scheduler.

  1. Launch Terminal from the Applications folder
  2. Enter the following and press Return:
    export EDITOR=nano && crontab -e
  3. Enter the following into the nano editor:
    # backup wallets at midnight every Sunday
    0 0 * * 0 open /Applications/BackupWallets.app
  4. Type Ctrl+X, Y, Return

crontab

Conclusion

And we’re done. You can check your disk image each Sunday after midnight to ensure that your wallets have been backed up. You can also run the BackupWallets.app application to backup your wallets on-demand.

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s