Port of walletbackup.sh to Python.