| 1 | # Monero Blockchain Utilities |
| 2 | |
| 3 | Copyright (c) 2014-2022, The Monero Project |
| 4 | |
| 5 | ## Introduction |
| 6 | |
| 7 | The blockchain utilities allow one to import and export the blockchain. |
| 8 | |
| 9 | ## Usage: |
| 10 | |
| 11 | See also each utility's "--help" option. |
| 12 | |
| 13 | ### Export an existing blockchain database |
| 14 | |
| 15 | `$ monero-blockchain-export` |
| 16 | |
| 17 | This loads the existing blockchain and exports it to `$MONERO_DATA_DIR/export/blockchain.raw` |
| 18 | |
| 19 | ### Import the exported file |
| 20 | |
| 21 | `$ monero-blockchain-import` |
| 22 | |
| 23 | This imports blocks from `$MONERO_DATA_DIR/export/blockchain.raw` (exported using the |
| 24 | `monero-blockchain-export` tool as described above) into the current database. |
| 25 | |
| 26 | Defaults: `--batch on`, `--batch size 20000`, `--verify on` |
| 27 | |
| 28 | Batch size refers to number of blocks and can be adjusted for performance based on available RAM. |
| 29 | |
| 30 | Verification should only be turned off if importing from a trusted blockchain. |
| 31 | |
| 32 | If you encounter an error like "resizing not supported in batch mode", you can just re-run |
| 33 | the `monero-blockchain-import` command again, and it will restart from where it left off. |
| 34 | |
| 35 | ```bash |
| 36 | ## use default settings to import blockchain.raw into database |
| 37 | $ monero-blockchain-import |
| 38 | |
| 39 | ## fast import with large batch size, database mode "fastest", verification off |
| 40 | $ monero-blockchain-import --batch-size 20000 --database lmdb#fastest --verify off |
| 41 | |
| 42 | ``` |
| 43 | |
| 44 | ### Import options |
| 45 | |
| 46 | `--input-file` |
| 47 | specifies input file path for importing |
| 48 | |
| 49 | default: `<data-dir>/export/blockchain.raw` |
| 50 | |
| 51 | `--output-file` |
| 52 | specifies output file path to export to |
| 53 | |
| 54 | default: `<data-dir>/export/blockchain.raw` |
| 55 | |
| 56 | `--block-stop` |
| 57 | stop at block number |
| 58 | |
| 59 | `--database <database type>` |
| 60 | |
| 61 | `--database <database type>#<flag(s)>` |
| 62 | |
| 63 | database type: `lmdb, memory` |
| 64 | |
| 65 | flags: |
| 66 | |
| 67 | The flag after the # is interpreted as a composite mode/flag if there's only |
| 68 | one (no comma separated arguments). |
| 69 | |
| 70 | The composite mode represents multiple DB flags and support different database types: |
| 71 | |
| 72 | `safe, fast, fastest` |
| 73 | |
| 74 | Database-specific flags can be set instead. |
| 75 | |
| 76 | LMDB flags (more than one may be specified): |
| 77 | |
| 78 | `nosync, nometasync, writemap, mapasync, nordahead` |
| 79 | |
| 80 | ## Examples: |
| 81 | |
| 82 | ```bash |
| 83 | $ monero-blockchain-import --database lmdb#fastest |
| 84 | |
| 85 | $ monero-blockchain-import --database lmdb#nosync |
| 86 | |
| 87 | $ monero-blockchain-import --database lmdb#nosync,nometasync |
| 88 | ``` |