go-ethereum/docs/_install-and-build/Backup--restore.md

66 lines
1.8 KiB
Markdown
Raw Normal View History

2019-03-27 03:32:29 -05:00
---
title: Backup & Restore
sort_key: C
2019-03-27 03:32:29 -05:00
---
Most important info first: **REMEMBER YOUR PASSWORD** and **BACKUP YOUR KEYSTORE**.
2019-09-04 06:51:21 -05:00
## Data Directory
2019-03-27 03:32:29 -05: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`
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
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
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
```
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
## Blockchain Import/Export
2019-03-27 03:32:29 -05:00
Export the blockchain in binary format with:
2019-03-27 03:32:29 -05:00
```
geth export <filename>
```
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
```
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-03-27 03:32:29 -05:00
```
geth import <filename>
```
2021-09-20 04:15:05 -05:00
_See https://eth.wiki/en/howto/blockchain-import-and-export-instructions for more info_
2019-03-27 03:32:29 -05:00
And finally: **REMEMBER YOUR PASSWORD** and **BACKUP YOUR KEYSTORE**