# Backup Worker Configuration
#
# This file configures the backup-worker service which exports metrics data
# from VictoriaMetrics to one or more cloud storage backends. The backup window
# is split into time-based shards that are processed concurrently for throughput.

mode = "deltalake" # metric/log/deltalake


# -----------------------------------------------------------------------------
# Source: VictoriaMetrics
# -----------------------------------------------------------------------------
# Configures the VictoriaMetrics instance to export data from.
[sources.victoriametrics]
enabled = false

# Victoriametrics server URL.
endpoint = "http://127.0.0.1:8428"

# HTTP request timeout for each export query. (default: 5m)
timeout = "5m"

# Duration of each time shard. The total backup window [startTime, endTime] is
# split into shards of this size and processed concurrently. Smaller intervals
# produce more shards and better parallelism but more objects in storage.
timeInterval = "1h"

# PromQL/Timeseries filter expression used to select which time series to export.
# Supports full VictoriaMetrics export filter syntax. (default: '{__name__=~".*"}')
match = '{__name__=~".*"}'

# Start of the backup window as a Unix timestamp (seconds). Required, must be > 0.
startTime = 1774799588

# End of the backup window as a Unix timestamp (seconds). Required, must be > startTime.
endTime = 1774842788


# -----------------------------------------------------------------------------
# Sink: Azure Blob Storage
# -----------------------------------------------------------------------------
# Writes backup data to an Azure Blob Storage container.
# Supports multiple authentication methods — choose one:
#   1. Connection string (connectionString)
#   2. Account name + credentials file (accountName + credentialsFile)
#   3. Account URL (accountUrl)
[sinks.azblob]
enabled = false

# Azure storage account name.
# accountName = "mystorageaccount"
#
# Custom blob service URL (optional, defaults to https://{accountName}.blob.core.windows.net).
# accountUrl = "https://mystorageaccount.blob.core.windows.net"
#
# Blob container name.
container = "vm-backup-test1"

# Path prefix within the container.
pathPrefix = "mandochen/vm-backups"

# Connection string for authentication (alternative to accountName + credentialsFile).
connectionString = "your-connection-string"

# Path to Azure credentials JSON file for authentication.
# credentialsFile = ""


# -----------------------------------------------------------------------------
# Sink: Google Cloud Storage (GCS)
# -----------------------------------------------------------------------------
# Writes backup data to a Google Cloud Storage bucket.
[sinks.gcs]
enabled = false

# GCS bucket name.
bucket = "vm-backup-test1"

# Path prefix within the bucket.
pathPrefix = "mandochen/vm-backups"
#
# Path to a GCP service account credentials JSON file.
credentialsFile = "your-credentials-file.json"
#
# Inline GCP service account credentials JSON string.
# Use either credentialsFile or credentialsJson, not both.
# credentialsJson = ''


# -----------------------------------------------------------------------------
# Sink: Alibaba Cloud OSS
# -----------------------------------------------------------------------------
# Writes backup data to an Alibaba Cloud OSS bucket.
[sinks.oss]
enabled = false

# OSS endpoint (e.g. "oss-cn-hangzhou.aliyuncs.com").
endpoint = "oss-ap-southeast-1.aliyuncs.com"

# OSS region (e.g. "cn-hangzhou").
region = "ap-southeast-1"

# OSS bucket name.
bucket = "vm-backup-test1"

# Path prefix within the bucket.
pathPrefix = "mandochen/vm-backups"

# Path to Alibaba Cloud credentials file (alternative to static keys).
# credentialsFile = ""

# Static access key credentials (alternative to credentialsFile).
accessKeyId = "your-access-key-id"
accessKeySecret = "your-access-key-secret"
securityToken = "your-security-token"


# -----------------------------------------------------------------------------
# Sink: AWS S3
# -----------------------------------------------------------------------------
# Writes backup data to an AWS S3 bucket using IAM role assumption (IRSA).
# Authentication is handled via AssumeRoleWithWebIdentity — do not configure
# static access keys when running inside EKS.
[sinks.s3]
enabled = false

# IAM role ARN to assume for S3 access. Used in EKS IRSA setups.
roleArn = "your-iam-role-arn"

# Optional external ID for the IAM role assumption. Leave empty if not required.
# externalId = ""

# AWS region of the S3 bucket.
region = "us-west-2"

# S3 bucket name.
bucket = "vm-backup-test1"

# Path prefix within the bucket. Backup files are written under this prefix.
# Example: with pathPrefix = "team/project", files land at s3://bucket/team/project/...
pathPrefix = "mandochen/vm-backups"


# -----------------------------------------------------------------------------
# Syncer: AzBlob File Copy
# -----------------------------------------------------------------------------
# Copies log or deltalake objects from one Azure Blob container to another.
#
# Log mode path layout (mode = "log"):
#   Source: diagnosis/data/{clusterId}/merged-logs/{YYYYMMDDHH}/{component}/
#   Dest:   {dest.pathPrefix}/{clusterId}/{YYYYMMDDHH}/{component}/
#
# Deltalake mode path layout (mode = "deltalake"):
#   Source: deltalake/{orgId}/{clusterId}/{component}/date={YYYYMMDD}/
#   Dest:   {dest.pathPrefix}/{orgId}/{clusterId}/{component}/date={YYYYMMDD}/
[syncers.azblob]
enabled = false

# Cluster identifier for shard path construction.
clusterId = "cluster1"

# Organization identifier (required for deltalake mode).
# orgId = "org1"

# Time range as Unix timestamps (seconds).
# Log mode: truncated to hour boundaries.
# Deltalake mode: truncated to day boundaries.
startTime = 1753779580
endTime = 1753782018

# Components to replicate (e.g., tidb, tikv, pd).
components = ["tidb", "tikv"]

# Source Azure Blob configuration.
[syncers.azblob.source]
container = "your-source-container"
# connectionString = "your-connection-string"
# accountName = "mystorageaccount"
# credentialsFile = ""

# Destination Azure Blob configuration.
[syncers.azblob.dest]
container = "your-dest-container"
pathPrefix = "diagnosis/data-backup"
# connectionString = "your-connection-string"
# accountName = "mystorageaccount"
# credentialsFile = ""


# -----------------------------------------------------------------------------
# Syncer: GCS File Copy
# -----------------------------------------------------------------------------
# Copies log or deltalake objects from one GCS bucket to another.
#
# Log mode path layout (mode = "log"):
#   Source: diagnosis/data/{clusterId}/merged-logs/{YYYYMMDDHH}/{component}/
#   Dest:   {dest.pathPrefix}/{clusterId}/{YYYYMMDDHH}/{component}/
#
# Deltalake mode path layout (mode = "deltalake"):
#   Source: deltalake/{orgId}/{clusterId}/{component}/date={YYYYMMDD}/
#   Dest:   {dest.pathPrefix}/{orgId}/{clusterId}/{component}/date={YYYYMMDD}/
[syncers.gcs]
enabled = false

# Cluster identifier for shard path construction.
clusterId = "cluster1"

# Organization identifier (required for deltalake mode).
# orgId = "org1"

# Time range as Unix timestamps (seconds).
# Log mode: truncated to hour boundaries.
# Deltalake mode: truncated to day boundaries.
startTime = 1753779580
endTime = 1753782018

# Components to replicate (e.g., tidb, tikv, pd).
components = ["tidb", "tikv"]

# Source GCS bucket configuration.
[syncers.gcs.source]
bucket = "your-source-bucket"
# credentialsFile = "your-credentials-file.json"
# credentialsJson = ''

# Destination GCS bucket configuration.
[syncers.gcs.dest]
bucket = "your-dest-bucket"
pathPrefix = "diagnosis/data-backup"
# credentialsFile = "your-credentials-file.json"
# credentialsJson = ''


# -----------------------------------------------------------------------------
# Syncer: OSS File Copy
# -----------------------------------------------------------------------------
# Copies log or deltalake objects from one OSS bucket to another.
#
# Log mode path layout (mode = "log"):
#   Source: diagnosis/data/{clusterId}/merged-logs/{YYYYMMDDHH}/{component}/
#   Dest:   {dest.pathPrefix}/{clusterId}/{YYYYMMDDHH}/{component}/
#
# Deltalake mode path layout (mode = "deltalake"):
#   Source: deltalake/{orgId}/{clusterId}/{component}/date={YYYYMMDD}/
#   Dest:   {dest.pathPrefix}/{orgId}/{clusterId}/{component}/date={YYYYMMDD}/
[syncers.oss]
enabled = false

# Cluster identifier for shard path construction.
clusterId = "cluster1"

# Organization identifier (required for deltalake mode).
# orgId = "org1"

# Time range as Unix timestamps (seconds).
# Log mode: truncated to hour boundaries.
# Deltalake mode: truncated to day boundaries.
startTime = 1753779580
endTime = 1753782018

# Components to replicate (e.g., tidb, tikv, pd).
components = ["tidb", "tikv"]

# Source OSS bucket configuration.
[syncers.oss.source]
endpoint = "oss-ap-southeast-1.aliyuncs.com"
region = "ap-southeast-1"
bucket = "your-source-bucket"
# accessKeyId = "your-access-key-id"
# accessKeySecret = "your-access-key-secret"
# securityToken = "your-security-token"
# credentialsFile = ""

# Destination OSS bucket configuration.
[syncers.oss.dest]
endpoint = "oss-ap-southeast-1.aliyuncs.com"
region = "ap-southeast-1"
bucket = "your-dest-bucket"
pathPrefix = "diagnosis/data-backup"
# accessKeyId = "your-access-key-id"
# accessKeySecret = "your-access-key-secret"
# securityToken = "your-security-token"
# credentialsFile = ""


# -----------------------------------------------------------------------------
# Syncer: S3-to-S3 File Copy
# -----------------------------------------------------------------------------
# Copies log or deltalake objects from one S3 bucket to another.
#
# Log mode path layout (mode = "log"):
#   Source: diagnosis/data/{clusterId}/merged-logs/{YYYYMMDDHH}/{component}/
#   Dest:   {dest.pathPrefix}/{clusterId}/{YYYYMMDDHH}/{component}/
#
# Deltalake mode path layout (mode = "deltalake"):
#   Source: deltalake/{orgId}/{clusterId}/{component}/date={YYYYMMDD}/
#   Dest:   {dest.pathPrefix}/{orgId}/{clusterId}/{component}/date={YYYYMMDD}/
[syncers.s3]
enabled = false

# Cluster identifier for shard path construction.
clusterId = "cluster1"

# Organization identifier (required for deltalake mode).
# orgId = "org1"

# Time range as Unix timestamps (seconds).
# Log mode: truncated to hour boundaries.
# Deltalake mode: truncated to day boundaries.
startTime = 1753779580
endTime = 1753782018

# Components to replicate (e.g., tidb, tikv, pd).
components = ["tidb", "tikv"]

# Source S3 bucket configuration.
[syncers.s3.source]
region = "us-west-2"
bucket = "your-source-bucket"

# IAM role for source bucket access (cross-account scenarios)
roleArn = "your-iam-role-arn"
# externalId = ""    # External ID for cross-account role assumption

# Destination S3 bucket configuration.
[syncers.s3.dest]
region = "us-west-2"
bucket = "your-dest-bucket"
pathPrefix = "diagnosis/data-backup"

# IAM role for dest bucket access (cross-account scenarios)
roleArn = "your-iam-role-arn"
# externalId = ""    # External ID for cross-account role assumption


# -----------------------------------------------------------------------------
# Checkpoint
# -----------------------------------------------------------------------------
# Tracks backup progress so interrupted runs can resume from the last completed
# shard instead of restarting from scratch.
[checkpoint]

# Directory path for storing checkpoint state files. (default: /tmp/backup-worker/checkpoint)
path = "/tmp/backup-worker"


# -----------------------------------------------------------------------------
# Execution
# -----------------------------------------------------------------------------
# Controls the parallelism and scheduling of backup shard processing.
[execution]

# Maximum number of shards to process concurrently. (default: 1)
concurrency = 2


# -----------------------------------------------------------------------------
# Retry Policy
# -----------------------------------------------------------------------------
# Configures retry behavior for transient failures during storage operations.
[retryPolicy]

# Maximum number of retry attempts per shard. (default: 3)
retryMaxAttempts = 3

# Wait interval between retry attempts. (default: 5s)
retryInterval = "5s"
