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?
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.
- Launch Disk Utility from the Applications folder
- Click New Image
- Save the image somewhere that is itself backed up (e.g. Dropbox or Wuala)
- For the name, specify Wallet Backups (so that the below scripts match)
- For Encryption, select either 128 or 256 (256 is more secure and should be plenty fast for this)
- Click Create
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.
- Launch Automator from the Applications folder
- Select Application and click Choose
- Add a Get Specified Finder Items action
- Select the DMG file created in Step One
- Add a Mount Disk Image action
- Add a Run Shell Script action and enter:
cd ~/Library/Application\ Support && rsync -R ./*/wallet.dat /Volumes/Wallet\ Backups/
- Add another Run Shell Script action and enter:
diskutil unmount /Volumes/Wallet\ Backups/
- Click File, Save
- Save as BackupWallets.app in Applications
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.
- Launch Terminal from the Applications folder
- Enter the following and press Return:
export EDITOR=nano && crontab -e
- Enter the following into the nano editor:
# backup wallets at midnight every Sunday
0 0 * * 0 open /Applications/BackupWallets.app
- Type Ctrl+X, Y, Return
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.