2019-03-27 09:32:29 +01:00
|
|
|
---
|
2019-11-05 13:46:00 +01:00
|
|
|
title: Backup & Restore
|
|
|
|
sort_key: C
|
2019-03-27 09:32:29 +01:00
|
|
|
---
|
|
|
|
|
2019-11-05 13:46:00 +01:00
|
|
|
Most important info first: **REMEMBER YOUR PASSWORD** and **BACKUP YOUR KEYSTORE**.
|
2019-09-04 13:51:21 +02:00
|
|
|
|
2019-11-05 13:46:00 +01:00
|
|
|
## Data Directory
|
2019-03-27 09:32:29 +01:00
|
|
|
|
2019-11-05 13:46:00 +01:00
|
|
|
Everything `geth` persists gets written inside its data directory. The default data
|
|
|
|
directory locations are platform specific:
|
2019-03-27 09:32:29 +01:00
|
|
|
|
|
|
|
* Mac: `~/Library/Ethereum`
|
|
|
|
* Linux: `~/.ethereum`
|
2022-03-20 18:15:02 +07:00
|
|
|
* Windows: `%LOCALAPPDATA%\Ethereum`
|
2019-03-27 09:32:29 +01:00
|
|
|
|
2019-11-05 13:46:00 +01:00
|
|
|
Accounts are stored in the `keystore` subdirectory. The contents of this directories
|
|
|
|
should be transportable between nodes, platforms, implementations (C++, Go, Python).
|
2019-03-27 09:32:29 +01:00
|
|
|
|
2019-11-05 13:46:00 +01:00
|
|
|
To configure the location of the data directory, the `--datadir` parameter can be
|
|
|
|
specified. See [CLI Options](../interface/command-line-options) for more details.
|
2019-03-27 09:32:29 +01:00
|
|
|
|
2019-11-05 13:46:00 +01:00
|
|
|
Note the [ethash dag](../interface/mining) is stored at `~/.ethash` (Mac/Linux) or
|
|
|
|
`%APPDATA%\Ethash` (Windows) so that it can be reused by all clients. You can store this
|
|
|
|
in a different location by using a symbolic link.
|
2019-03-27 09:32:29 +01:00
|
|
|
|
|
|
|
## Cleanup
|
|
|
|
|
|
|
|
Geth's blockchain and state databases can be removed with:
|
|
|
|
|
|
|
|
```
|
|
|
|
geth removedb
|
|
|
|
```
|
|
|
|
|
2019-11-05 13:46:00 +01:00
|
|
|
This is useful for deleting an old chain and sync'ing to a new one. It only affects data
|
|
|
|
directories that can be re-created on synchronisation and does not touch the keystore.
|
2019-03-27 09:32:29 +01:00
|
|
|
|
2019-11-05 13:46:00 +01:00
|
|
|
## Blockchain Import/Export
|
2019-03-27 09:32:29 +01:00
|
|
|
|
|
|
|
Export the blockchain in binary format with:
|
2019-11-05 13:46:00 +01:00
|
|
|
|
2019-03-27 09:32:29 +01:00
|
|
|
```
|
|
|
|
geth export <filename>
|
|
|
|
```
|
|
|
|
|
2019-11-05 13:46:00 +01:00
|
|
|
Or if you want to back up portions of the chain over time, a first and last block can be
|
|
|
|
specified. For example, to back up the first epoch:
|
2019-03-27 09:32:29 +01:00
|
|
|
|
|
|
|
```
|
|
|
|
geth export <filename> 0 29999
|
|
|
|
```
|
|
|
|
|
2019-11-05 13:46:00 +01:00
|
|
|
Note that when backing up a partial chain, the file will be appended rather than
|
|
|
|
truncated.
|
2019-03-27 09:32:29 +01:00
|
|
|
|
|
|
|
Import binary-format blockchain exports with:
|
2019-11-05 13:46:00 +01:00
|
|
|
|
2019-03-27 09:32:29 +01:00
|
|
|
```
|
|
|
|
geth import <filename>
|
|
|
|
```
|
|
|
|
|
2021-09-20 11:15:05 +02:00
|
|
|
_See https://eth.wiki/en/howto/blockchain-import-and-export-instructions for more info_
|
2019-03-27 09:32:29 +01:00
|
|
|
|
|
|
|
|
2019-11-05 13:46:00 +01:00
|
|
|
And finally: **REMEMBER YOUR PASSWORD** and **BACKUP YOUR KEYSTORE**
|