2019-03-27 03:32:29 -05:00
|
|
|
---
|
2019-11-05 06:46:00 -06:00
|
|
|
title: Backup & Restore
|
|
|
|
sort_key: C
|
2019-03-27 03:32:29 -05:00
|
|
|
---
|
|
|
|
|
2019-11-05 06:46:00 -06:00
|
|
|
Most important info first: **REMEMBER YOUR PASSWORD** and **BACKUP YOUR KEYSTORE**.
|
2019-09-04 06:51:21 -05:00
|
|
|
|
2019-11-05 06:46:00 -06:00
|
|
|
## Data Directory
|
2019-03-27 03:32:29 -05:00
|
|
|
|
2019-11-05 06:46:00 -06:00
|
|
|
Everything `geth` persists gets written inside its data directory. The default data
|
|
|
|
directory locations are platform specific:
|
2019-03-27 03:32:29 -05:00
|
|
|
|
|
|
|
* Mac: `~/Library/Ethereum`
|
|
|
|
* Linux: `~/.ethereum`
|
|
|
|
* Windows: `%APPDATA%\Ethereum`
|
|
|
|
|
2019-11-05 06:46:00 -06: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 03:32:29 -05:00
|
|
|
|
2019-11-05 06:46:00 -06: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 03:32:29 -05:00
|
|
|
|
2019-11-05 06:46:00 -06: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 03:32:29 -05:00
|
|
|
|
|
|
|
## Cleanup
|
|
|
|
|
|
|
|
Geth's blockchain and state databases can be removed with:
|
|
|
|
|
|
|
|
```
|
|
|
|
geth removedb
|
|
|
|
```
|
|
|
|
|
2019-11-05 06:46:00 -06: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 03:32:29 -05:00
|
|
|
|
2019-11-05 06:46:00 -06:00
|
|
|
## Blockchain Import/Export
|
2019-03-27 03:32:29 -05:00
|
|
|
|
|
|
|
Export the blockchain in binary format with:
|
2019-11-05 06:46:00 -06:00
|
|
|
|
2019-03-27 03:32:29 -05:00
|
|
|
```
|
|
|
|
geth export <filename>
|
|
|
|
```
|
|
|
|
|
2019-11-05 06:46:00 -06: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 03:32:29 -05:00
|
|
|
|
|
|
|
```
|
|
|
|
geth export <filename> 0 29999
|
|
|
|
```
|
|
|
|
|
2019-11-05 06:46:00 -06:00
|
|
|
Note that when backing up a partial chain, the file will be appended rather than
|
|
|
|
truncated.
|
2019-03-27 03:32:29 -05:00
|
|
|
|
|
|
|
Import binary-format blockchain exports with:
|
2019-11-05 06:46:00 -06:00
|
|
|
|
2019-03-27 03:32:29 -05:00
|
|
|
```
|
|
|
|
geth import <filename>
|
|
|
|
```
|
|
|
|
|
|
|
|
_See https://github.com/ethereum/wiki/wiki/Blockchain-import-export for more info_
|
|
|
|
|
|
|
|
|
2019-11-05 06:46:00 -06:00
|
|
|
And finally: **REMEMBER YOUR PASSWORD** and **BACKUP YOUR KEYSTORE**
|