Skip to content

Commit

Permalink
[docker-compose] add data restore docker compose
Browse files Browse the repository at this point in the history
  • Loading branch information
sherry-x authored and bors-libra committed Jun 12, 2021
1 parent 7917821 commit e90bbb0
Show file tree
Hide file tree
Showing 3 changed files with 52 additions and 0 deletions.
1 change: 1 addition & 0 deletions docker/compose/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ This directory contains the following compose configurations:
* **client-cli**: creates a CLI client which connects to the above validator/faucet
* **public_full_node**: creates a public fullnode, and it can be configured to connect to any existing network (e.g. testnet, Mainnet).
* **monitoring**: creates a monitoring stack which can be used to collect metrics and virtulize it on a dashboard. This can be installed together with other compose configurations and provides simple monitoring for the deployment.
* **data-restore**: creates a diem db-restore job to restore a data volume from provided S3 bucket. This can be used to quickly restore fullnode for an exsiting blockchain to avoid spending long time on state-sync.

To use these compositions:
1. [Download](https://docs.docker.com/install/) and install Docker and Docker Compose (comes with Docker for Mac and Windows).
Expand Down
38 changes: 38 additions & 0 deletions docker/compose/data-restore/docker-compose.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
# This compose file can be used to restore data for a fullnode.
# You will need to provide the restore data source in the configuration.
version: "3.8"
services:
restore:
image: diem/tools:devnet
volumes:
- type: volume
source: db
target: /opt/diem/data
- type: volume
source: tmp
target: /tmp
- type: bind
source: ./s3-public.toml
target: /opt/diem/etc/s3-public.toml
read_only: true
# Provide the public S3 bucket and the sub directory you want to restore data from.
# Diem Association provides public data backup you can use, check the offical website.
environment:
- BUCKET=<S3 bucket>
- SUB_DIR=<sub directory of the S3 bucket>
- HOME=/tmp
- RUST_LOG=debug
command: >
sh -c "
/usr/local/bin/db-restore --concurrent-downloads 2 \
--target-db-dir /opt/diem/data/db auto \
--metadata-cache-dir /tmp/diem-restore-metadata \
command-adapter --config /opt/diem/etc/s3-public.toml
"
# update the db volume name to the one you want to restore if needed
# docker-compose usually add the project name (default is the directory name) as prefix of the volume name.
# so make sure you start this docker compose using same project name as the db you want to restore.
volumes:
db:
tmp:
13 changes: 13 additions & 0 deletions docker/compose/data-restore/s3-public.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
env_vars = []

[commands]
create_backup = 'echo "$BACKUP_NAME"'
create_for_write = '''
FILE_HANDLE="$BACKUP_HANDLE/$FILE_NAME"
echo "$FILE_HANDLE"
exec 1>&-
gzip -c | aws s3 cp - "s3://$BUCKET/$SUB_DIR/$FILE_HANDLE"
'''
open_for_read = 'aws s3 cp "s3://$BUCKET/$SUB_DIR/$FILE_HANDLE" - --no-sign-request | gzip -cd'
save_metadata_line= 'gzip -c | aws s3 cp - "s3://$BUCKET/$SUB_DIR/metadata/$FILE_NAME" --no-sign-request'
list_metadata_files = '(aws s3 ls s3://$BUCKET/$SUB_DIR/metadata/ --no-sign-request ||:) | sed -ne "s#.* \(.*\)#metadata/\1#p"'

0 comments on commit e90bbb0

Please sign in to comment.