Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
.idea/
.vscode/
.cursor/
.claude/
*.swp
*.swo
*~
Expand All @@ -24,4 +25,4 @@ coverage/

# Cargo lock for library crates (keep for binary)
# Cargo.lock

CLAUDE.md
11 changes: 11 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ clap_complete = "4.5"
serde = { version = "1.0", features = ["derive"] }
serde_json = "1.0"
toml = "0.9"
quick-xml = { version = "0.38", features = ["serialize"] }

# Error handling
thiserror = "2.0"
Expand Down
100 changes: 100 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,75 @@ rc event list local/my-bucket
rc event remove local/my-bucket arn:aws:sns:us-east-1:123456789012:topic
```

### Lifecycle (ILM) Operations

```bash
# Add lifecycle rule: expire objects after 30 days with prefix filter
rc ilm rule add local/my-bucket --expiry-days 30 --prefix "logs/"

# Add lifecycle rule: transition to remote tier after 90 days
rc ilm rule add local/my-bucket --transition-days 90 --storage-class WARM

# List lifecycle rules
rc ilm rule list local/my-bucket

# Edit an existing rule
rc ilm rule edit local/my-bucket --id rule-abc123 --expiry-days 60

# Remove a specific rule or all rules
rc ilm rule remove local/my-bucket --id rule-abc123
rc ilm rule remove local/my-bucket --all

# Export/import lifecycle configuration (JSON)
rc ilm rule export local/my-bucket > lifecycle.json
rc ilm rule import local/my-bucket lifecycle.json

# Manage remote storage tiers
rc ilm tier add rustfs WARM local --endpoint http://remote:9000 --access-key ak --secret-key sk --bucket warm-bucket
rc ilm tier list local
rc ilm tier info WARM local
rc ilm tier remove WARM local --force

# Restore a transitioned (archived) object
rc ilm restore local/my-bucket/archived-file.dat --days 7
```

### Bucket Replication

```bash
# Replication requires versioning on both source and destination buckets
rc version enable local/my-bucket
rc version enable remote/target-bucket

# Configure a remote alias with the destination RustFS endpoint URL.
# rc normalizes the remote target endpoint to the host:port form expected by
# the RustFS admin API when creating replication targets.
rc alias set remote http://remote:9000 ACCESS_KEY SECRET_KEY

# Add a replication rule
rc replicate add local/my-bucket \
--remote-bucket remote/target-bucket \
--priority 1 \
--replicate delete,delete-marker,existing-objects

# List replication rules
rc replicate list local/my-bucket

# View replication status/metrics
rc replicate status local/my-bucket

# Update a replication rule
rc replicate update local/my-bucket --id rule-1 --priority 2

# Remove replication rules
rc replicate remove local/my-bucket --id rule-1
rc replicate remove local/my-bucket --all

# Export/import replication configuration (JSON)
rc replicate export local/my-bucket > replication.json
rc replicate import local/my-bucket replication.json
```

### Admin Operations (Cluster)

```bash
Expand Down Expand Up @@ -189,6 +258,8 @@ rc admin heal status local --json
| `version` | Manage bucket versioning |
| `tag` | Manage bucket and object tags |
| `quota` | Manage bucket quota |
| `ilm` | Manage lifecycle rules, storage tiers, and object restore |
| `replicate` | Manage bucket replication |
| `completions` | Generate shell completion scripts |

### Admin Subcommands
Expand All @@ -202,6 +273,35 @@ rc admin heal status local --json
| `admin info` | Display cluster information (cluster, server, disk) |
| `admin heal` | Manage cluster healing operations (status, start, stop) |

### ILM Subcommands

| Command | Description |
|---------|-------------|
| `ilm rule add` | Add a lifecycle rule to a bucket |
| `ilm rule edit` | Edit an existing lifecycle rule |
| `ilm rule list` | List lifecycle rules on a bucket |
| `ilm rule remove` | Remove lifecycle rules from a bucket |
| `ilm rule export` | Export lifecycle configuration as JSON |
| `ilm rule import` | Import lifecycle configuration from JSON |
| `ilm tier add` | Add a remote storage tier |
| `ilm tier edit` | Edit tier credentials |
| `ilm tier list` | List all configured storage tiers |
| `ilm tier info` | Show details for a specific tier |
| `ilm tier remove` | Remove a storage tier |
| `ilm restore` | Restore a transitioned (archived) object |

### Replicate Subcommands

| Command | Description |
|---------|-------------|
| `replicate add` | Add a new replication rule |
| `replicate update` | Update an existing replication rule |
| `replicate list` | List replication rules for a bucket |
| `replicate status` | Show replication status and metrics |
| `replicate remove` | Remove replication rules |
| `replicate export` | Export replication configuration as JSON |
| `replicate import` | Import replication configuration from JSON |

## Output Format

### Human-Readable (default)
Expand Down
43 changes: 43 additions & 0 deletions crates/cli/src/commands/ilm/mod.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
//! ilm command - Manage bucket lifecycle (ILM) rules, tiers, and restores
//!
//! Add, edit, list, remove, export, and import lifecycle rules;
//! manage remote storage tiers; restore transitioned objects.

pub mod restore;
pub mod rule;
pub mod tier;

use clap::{Args, Subcommand};

use crate::exit_code::ExitCode;
use crate::output::OutputConfig;

/// Manage bucket lifecycle (ILM) configuration
#[derive(Args, Debug)]
pub struct IlmArgs {
#[command(subcommand)]
pub command: IlmCommands,
}

#[derive(Subcommand, Debug)]
pub enum IlmCommands {
/// Manage lifecycle rules on a bucket
#[command(subcommand)]
Rule(rule::RuleCommands),

/// Manage remote storage tiers
#[command(subcommand)]
Tier(tier::TierCommands),

/// Restore a transitioned (archived) object
Restore(restore::RestoreArgs),
}

/// Execute the ilm command
pub async fn execute(args: IlmArgs, output_config: OutputConfig) -> ExitCode {
match args.command {
IlmCommands::Rule(cmd) => rule::execute(cmd, output_config).await,
IlmCommands::Tier(cmd) => tier::execute(cmd, output_config).await,
IlmCommands::Restore(args) => restore::execute(args, output_config).await,
}
}
Loading