<@U0A71G31CDV> Are there any blogs that discuss ba...
# questions-and-troubleshooting
s
@Rocky Are there any blogs that discuss backup and restore strategies and best practices?
r
Yes, there are several blogs and guides that discuss backup and restore strategies, especially for production environments and the newer shared-data architecture. *1. Disaster Recovery & Cluster Snapshots (StarRocks v3.5+)* With the release of StarRocks 3.5, a major focus was placed on Cluster Snapshots, which are designed for shared-data (compute-storage separated) architectures. * StarRocks Disaster Recovery on Kubernetes: A Practical Guide to Cluster Snapshot: This blog provides a detailed workflow for using the Cluster Snapshot mechanism. It covers how to capture the complete cluster state (including metadata like users and permissions) and back it up to object storage (S3/GCS/HDFS). * Introducing StarRocks 3.5: This post highlights how cluster-level snapshots fill the gap for disaster recovery in shared-data deployments, allowing for recovery within minutes. *2. Production-Grade Incremental Backups (External Tooling)* For large-scale deployments where full backups are too costly or slow, the community (specifically Deep.BI) has published guides on incremental strategies: * Production-Grade Incremental Backups for StarRocks: This article discusses the limitations of native snapshot commands at the petabyte scale and introduces a lightweight CLI tool (
starrocks-backup-and-restore
) to automate partition-level incremental backups. * Introducing starrocks-backup-and-restore: Focuses on the "why" behind the tool, discussing state management, metadata tracking, and the "small-file trap" in backups. *3. Official Documentation & Best Practices* While not a "blog," the official Back up and restore data documentation contains a "Usage notes" section that functions as a best practices guide, recommending: * Parallel Loading: During migrations, load data to both the old and new clusters in parallel for a period to verify correctness. * Load Balancing: Perform backups during off-peak hours as they consume significant cluster resources. * Schema Consistency: Ensure table schemas match when restoring by overwriting, or use the
AS
keyword to rename tables during restore to avoid conflicts. Key Strategies Mentioned: * Shared-Nothing (Traditional): Uses
BACKUP
and
RESTORE
commands to create snapshots of databases/tables in a repository (S3, HDFS, etc.). * Shared-Data (Modern): Uses Cluster Snapshots for a more automated, low-cost disaster recovery approach that captures the entire system state. * Incremental Approach: Use external automation to track changed partitions and back up only the deltas to save on storage and network costs. References • administration/user_privs/authorization/User_privilege.md • administration/management/Backup_and_restore.md • sql-reference/sql-statements/account-management/GRANT.md
s
@Rocky I want to find the frequency, periodic
r
In StarRocks, "frequency" and "periodic" scheduling usually refer to one of the following four areas. Depending on what you are trying to configure, the syntax and minimum intervals vary: 1. Scheduled Tasks (
SUBMIT TASK
)
StarRocks allows you to schedule SQL statements (like
INSERT INTO ... SELECT
or
CREATE TABLE AS SELECT
) to run at specific intervals. * Syntax:
SUBMIT TASK <name> SCHEDULE EVERY (INTERVAL 1 DAY) AS <sql_statement>;
* Minimum Frequency: Controlled by the FE configuration
task_min_schedule_interval_s
(default is 10 seconds). * Units: You can use
SECOND
,
MINUTE
,
HOUR
, or
DAY
. 2. Materialized View Refresh Asynchronous Materialized Views (MVs) can be set to refresh on a periodic schedule. * Syntax:
Copy code
sql
    CREATE MATERIALIZED VIEW mv1
    REFRESH ASYNC EVERY (INTERVAL 1 HOUR)
    AS SELECT ...;
* Minimum Frequency: Controlled by
materialized_view_min_refresh_interval
(default is 60 seconds). Setting this too low can cause high CPU/memory usage on the FE. 3. Routine Load (Kafka Ingestion) If you are referring to how often StarRocks consumes data from Kafka: * Parameter:
max_batch_interval
inside the
PROPERTIES
of your
CREATE ROUTINE LOAD
job. * Default: 10 seconds. * Range: 5 to 60 seconds. * Best Practice: It is generally recommended to keep this at 10 seconds or higher to prevent generating too many small tablet versions (metadata overhead). 4. Automatic Partitioning When creating tables, you can define a periodic "step" for automatic partition creation. * Syntax:
PARTITION BY RANGE (date_col) (START ("2023-01-01") END ("2024-01-01") EVERY (INTERVAL 1 DAY))
* This defines the "width" or frequency of each partition. ────────── Which one are you looking for? If you are looking for Backup/Restore frequency, StarRocks does not have a built-in "cron" for backups yet; most users use an external tool (like a Kubernetes CronJob or
starrocks-backup-and-restore
CLI) to trigger the
BACKUP
command periodically (e.g., once every 24 hours). References • sql-reference/sql-statements/loading_unloading/routine_load/CREATE_ROUTINE_LOAD.md • sql-reference/sql-statements/loading_unloading/ETL/SUBMIT_TASK.md • administration/management/FE_configuration.md • sql-reference/sql-statements/table_bucket_part_index/CREATE_TABLE.md References • sql-reference/sql-statements/loading_unloading/ETL/SUBMIT_TASK.md • sql-reference/sql-statements/loading_unloading/routine_load/CREATE_ROUTINE_LOAD.md • sql-reference/sql-statements/table_bucket_part_index/CREATE_TABLE.md • administration/management/FE_configuration.md • sql-reference/sql-statements/cbo_stats/CREATE_ANALYZE.md
s
@Rocky I mean frequency and periodic backup strategy
r
For a robust periodic backup strategy in StarRocks, the "frequency" and "periodicity" are typically determined by your data volume and recovery requirements. Because StarRocks does not have a built-in backup scheduler, most production environments use external automation (like CronJobs or Airflow) to trigger the following strategies: 1. Recommended Frequencies A common industry standard (often called the Full-Incremental Hybrid) is used to balance storage costs with recovery speed: * Daily Full Backup: Recommended for smaller datasets (under 1TB) or critical small dimension tables. * Weekly Full + Daily "Incremental": For larger datasets (1TB–100TB+), run a full backup once a week and back up only specific changed partitions daily. * Hourly Snapshots: For mission-critical tables where data loss must be minimal, you can trigger partition-level backups every hour. 2. The "Partition-based" Periodic Strategy Native StarRocks
BACKUP
commands are technically "full" snapshots, but you can achieve an incremental effect by backing up by partition: * How it works: Instead of backing up the whole table, your script targets only the newest partitions (e.g.,
PARTITION (p20231027)
). * Benefit: This drastically reduces the backup window and network bandwidth for large fact tables. * Automation Tooling: The community-developed starrocks-backup-and-restore CLI is specifically designed to automate this. It tracks which partitions have changed and manages the "chain" of full and incremental snapshots for you. 3. Shared-Data vs. Shared-Nothing Strategies The strategy differs significantly depending on your StarRocks architecture: * Shared-Nothing (Traditional): You must manually coordinate the
BACKUP SNAPSHOT
commands to a repository (S3/HDFS). * Shared-Data (Compute-Storage Separated, v3.5+): Use the Cluster Snapshot feature. This is more automated and captures the entire cluster state (including metadata like users and permissions) to object storage. It is the preferred DR strategy for modern deployments. 4. Operational Best Practices * Off-Peak Scheduling: Always schedule backups during low-traffic windows (e.g., 2:00 AM) because the snapshot process consumes FE and BE resources. * Inventory Grouping: Group your tables into categories. _ _High-Frequency:* Transactional tables (back up daily/hourly). _ _Low-Frequency:* Reference/Dimension tables (back up weekly). * Retention Policy: Don't keep snapshots forever. A typical policy is to keep the last 7 daily snapshots and 4 weekly snapshots. You must manually delete old snapshots from your storage (S3/HDFS) as StarRocks does not currently auto-purge them. * Verification: Periodically test a
RESTORE
to a separate "staging" cluster to ensure your periodic backups are actually functional. References • administration/management/Backup_and_restore.md • sql-reference/sql-statements/backup_restore/BACKUP.md • administration/cluster_snapshot.md • integrations/airflow.md References • administration/management/Backup_and_restore.md • administration/cluster_snapshot.md • sql-reference/sql-statements/backup_restore/BACKUP.md • faq/Exporting_faq.md • integrations/airflow.md