Skip to content

Instantly share code, notes, and snippets.

@csokun
Last active January 30, 2024 05:14
Show Gist options
  • Save csokun/d678d54d5c72e74a372096db08e7af16 to your computer and use it in GitHub Desktop.
Save csokun/d678d54d5c72e74a372096db08e7af16 to your computer and use it in GitHub Desktop.
Using stellar-etl to export ledgers|transactions|operations|effects|trades|assets|diagnostic_events
#!/bin/bash
# ref. https://github.com/stellar/stellar-etl/tree/master?tab=readme-ov-file#history-archive-commands
if [ $# -lt 3 ]; then
echo "Usage: $0 <export_type> <start_ledger> <end_ledger> [network]"
echo " $0 ledgers 2 500"
echo " $0 transactions 2 500 --futurenet"
echo " $0 operations 2 500 --testnet"
echo " $0 effects 2 500"
echo " $0 assets 2 500 --futurenet"
echo "===== History Archive URLs ====="
echo " Mainnet: http://history.stellar.org/prd/core-live/core_live_001/.well-known/stellar-history.json"
echo " Testnet: http://history.stellar.org/prd/core-testnet/core_testnet_001/.well-known/stellar-history.json"
exit 1
fi
export_type=$1
start_ledger=$2
end_ledger=$3
network=$4
output_file="${start_ledger}-${end_ledger}-${export_type}.txt"
docker_command="docker run --rm -v $PWD:/working stellar/stellar-etl stellar-etl"
if [ -n "$network" ]; then
docker_command+=" --$network"
fi
case $export_type in
ledgers|transactions|operations|effects|trades|assets|diagnostic_events)
$docker_command export_$export_type --start-ledger $start_ledger --end-ledger $end_ledger --output "/working/$output_file" --gcs-bucket ""
;;
*)
echo "Invalid export type: $export_type"
exit 1
;;
esac
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment