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.

3 thoughts on “Cryptocoin Mining on Mac OS X – Wallet Backups

  1. Coinkle

    Every time I run through the “Automator” steps the “Run Shell Script” fails
    Not sure what I am doing wrong. I’ve followed the steps to the “T”.

    Reply
  2. Jeffox

    Nate (if I may): First off – many thanks for your work on all of this. Your articles and blog entries have introed me to an entirely new world…for which I am probably ill-prepared. To wit: When I (think I) followed your instructions above to create a wallet backup action and attempt to run the new app, I get this message: The action “Run Shell Script” encountered an error. Check the action’s properties and try running the workflow again.

    iMac running 10.8 using MultiBit as wallet. I tried entering the script as:

    cd ~/Library/Application Support && rsync -R ./*/wallet.dat /Volumes/Wallet Backups/

    and as:

    cat cd ~/Library/Application Support && rsync -R ./*/wallet.dat /Volumes/Wallet Backups/

    (because “cat” appeared in the Run Shell Script window by default)

    I am no programmer (hence my being ‘ill-prepared’), so forgive my clumsy boldness. I just hope I am not the only one that might benefit from any insight you might offer.

    Cheers and Best,

    Jeffox

    Reply

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>