Bitcoin Forum

Bitcoin => Development & Technical Discussion => Topic started by: tsubasa1380 on November 27, 2018, 06:02:20 PM



Title: "backupwallet(importwallet)" command VS "copy" command
Post by: tsubasa1380 on November 27, 2018, 06:02:20 PM
Q: What is a difference between bitcoin-core "backupwallet(importwallet)" command and unix "copy" command ?

I'm planning to move "wallet.dat" to new server bought a few days ago.

I looked over books how to move "wallet.dat" and understood as below.

--「Mastering Bicoin」 Andreas M. Antonopoulos----
Commands: backupwallet, importwallet, dumpwallet
Next, we will practice creating a wallet backup file and then restoring the wallet from
the backup file. Use the backupwallet command to back up, providing the filename as
the parameter. Here we back up the wallet to the file wallet.backup:

  $ bitcoin-cli backupwallet wallet.backup
  $
Now, to restore the backup file, use the importwallet command. If your wallet is locked,
you will need to unlock it first (see walletpassphrase in the preceding section) in order
to import the backup file:

  $ bitcoin-cli importwallet wallet.backup
  $
---------------------------------------------------------------

I have a question.

Why not use unix "copy" command and then overwrite "wallet.dat" ?

Is there anything wrong with this approach ?


Title: Re: "backupwallet(importwallet)" command VS "copy" command
Post by: Forsyth Jones on November 27, 2018, 07:00:30 PM
Q: What is a difference between bitcoin-core "backupwallet(importwallet)" command and unix "copy" command ?
None.

you don't need to use the command line to back up the wallet. Just run the Bitcoin Core software and go to "File" will appear several options, among them, click the "backup wallet" option, then a window will appear for you to select the directory you would like to save your backup file, name the file to: bitcoin wallet backup or something like that and that's it.

You can do this same backup from the command line using the commands: "backupwallet" or "dumpwallet."

The "dumpwallet" option will dump all private keys in your wallet into a file that you specify during the execution of the command. Ex: dumpwallet "Desktop/bitcoin-keys-backup.key you should encrypt this file later because it is fully readable. That is why command line options are only recommended for users who have a certain experience with Bitcoin, do not use the Bitcoin Core command line unless you know what you are doing...


Title: Re: "backupwallet(importwallet)" command VS "copy" command
Post by: tsubasa1380 on November 27, 2018, 07:34:30 PM
Why not use unix "copy" command and then overwrite "wallet.dat" ?

Because not everyone uses Linux/Unix terminal and the guide mention how to backup wallet from bitcoin-cli

Is there anything wrong with this approach ?

AFAIK no, perhaps only permission to copy file with copy/cp command
Thank you for the quick response !

I am happy to hear your experience.

I have one more question about  backup "wallet.dat".

I am running a full node bitcoin server.
And I hope to backup "wallet.dat" every day by using cron which kicks shell scripts.
In this shell script, using "backupwallet" command is better than "copy" command ?
There are hundreds of both singlesig addresses and multisig address in this "wallet.dat".
Is it true that  using wallet.dat command takes much time than using copy command ?

Which do you recommend for backup ?


Title: Re: "backupwallet(importwallet)" command VS "copy" command
Post by: gmaxwell on November 27, 2018, 08:27:54 PM
You cannot back up the wallet by copying without shutting down the software first.  The backupwallet rpc lets you back up while running.


Title: Re: "backupwallet(importwallet)" command VS "copy" command
Post by: tsubasa1380 on November 28, 2018, 02:05:26 AM
You cannot back up the wallet by copying without shutting down the software first.  The backupwallet rpc lets you back up while running.

I understood as follows.
In case with copy command,
If the file(wallet.dat)  is being written, it will cause problems.
Is this okay?