Verify a Bitcoin wallet backup by restoring it on regtest
A successful backup call proves the node wrote a file. A separate restore drill checks that a fresh wallet instance recognizes an address from that backup.
Capture a reference before backup
On a disposable regtest node, start with a loaded lab wallet and choose a new backup path writable by the node process. The example paths refer to the server filesystem. Use an unused destination wallet name for the restore.
addr=$(bitcoin-cli -regtest -rpcwallet=lab getnewaddress drill)
bitcoin-cli -regtest -rpcwallet=lab backupwallet /tmp/lab-drill-backup.dat
bitcoin-cli -regtest restorewallet drill-copy /tmp/lab-drill-backup.dat false
bitcoin-cli -regtest -rpcwallet=drill-copy getaddressinfo "$addr" | jq '{ismine, labels}'
Define what the drill demonstrates
Check that the restored wallet recognizes the recorded address and its label. The final false avoids loading the drill copy automatically at startup. A watch-only wallet can pass this recognition test too, so verify signing separately when recovery of signing ability is part of the requirement. Use only test keys in this exercise.
bitcoincore.org backupwallet · bitcoincore.org restorewallet · bitcoincore.org getaddressinfo