Skip to content
Open
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
31 changes: 16 additions & 15 deletions config/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -75,20 +75,22 @@ If you want to contribute your own configuration, please

### Global Options `[global]`

| Attribute | Description | Default Value | Example Value | Environment Variable | CLI Option |
| ----------------- | --------------------------------------------------------------------------------- | ------------------ | ------------------------ | ------------------------------------------------ | ------------------- |
| check-index | If true, check the index and read pack headers if index information is missing. | false | | RUSTIC_CHECK_INDEX | --check-index |
| dry-run | If true, performs a dry run without making any changes. | false | | RUSTIC_DRY_RUN | --dry-run, -n |
| group-by | Group snapshots by any combination of host,label,paths,tags e.g. for "latest" | "host,label,paths" | | RUSTIC_GROUP_BY | --group-by, -g |
| log-level | Logging level. Possible values: "off", "error", "warn", "info", "debug", "trace". | "info" | | RUSTIC_LOG_LEVEL | --log-level |
| log-file | Path to the log file. | No log file | "/log/rustic.log" | RUSTIC_LOG_FILE | --log-file |
| no-progress | If true, disables progress indicators. | false | | RUSTIC_NO_PROGRESS | --no-progress |
| progress-interval | The interval at which progress indicators are shown. | "100ms" | "1m" | RUSTIC_PROGRESS_INTERVAL | --progress-interval |
| use-profiles | Array of profiles to use. Allows to recursively use other profiles. | Empty array | ["2nd", "3rd"] | RUSTIC_USE_PROFILE | --use-profile, -P |
| prometheus | URL of a Prometheus Pushgateway to push metrics to. | Not set | "http://gateway/" | RUSTIC_PROMETHEUS | --prometheus |
| prometheus-user | Username to authenticate to the Prometheus Pushgateway | Not set | "myuser" | RUSTIC_PROMETHEUS_USER | --prometheus-user |
| prometheus-pass | Password to authenticate to the Prometheus Pushgateway | Not set | "secret" | RUSTIC_PROMETHEUS_PASS | --prometheus-pass |
| opentelemetry | OpenTelemetry metrics endpoint (HTTP Protobuf) | Not set | "http://otel/v1/metrics" | RUSTIC_OTEL, OTEL_EXPORTER_OTLP_METRICS_ENDPOINT | --opentelemetry |
| Attribute | Description | Default Value | Example Value | Environment Variable | CLI Option |
| ----------------- | ------------------------------------------------------------------------------------------------- | ------------------ | ------------------------ | ------------------------------------------------ | ------------------- |
| check-index | If true, check the index and read pack headers if index information is missing. | false | | RUSTIC_CHECK_INDEX | --check-index |
| dry-run | If true, performs a dry run without making any changes. | false | | RUSTIC_DRY_RUN | --dry-run, -n |
| group-by | Group snapshots by any combination of host,label,paths,tags e.g. for "latest" | "host,label,paths" | | RUSTIC_GROUP_BY | --group-by, -g |
| log-level | Logging level. Possible values: "off", "error", "warn", "info", "debug", "trace". | "info" | | RUSTIC_LOG_LEVEL | --log-level |
| log-level-logfile | Logging level for log file. Possible values: "off", "error", "warn", "info", "debug", "trace". | "info" | | RUSTIC_LOG_LEVEL_LOGFILE | --log-level-logfile |
| log-level-dryrun | Logging level in dry-run mode. Possible values: "off", "error", "warn", "info", "debug", "trace". | "info" | | RUSTIC_LOG_LEVEL_DRYRUN | --log-level-dryrun |
| log-file | Path to the log file. | No log file | "/log/rustic.log" | RUSTIC_LOG_FILE | --log-file |
| no-progress | If true, disables progress indicators. | false | | RUSTIC_NO_PROGRESS | --no-progress |
| progress-interval | The interval at which progress indicators are shown. | "100ms" | "1m" | RUSTIC_PROGRESS_INTERVAL | --progress-interval |
| use-profiles | Array of profiles to use. Allows to recursively use other profiles. | Empty array | ["2nd", "3rd"] | RUSTIC_USE_PROFILE | --use-profile, -P |
| prometheus | URL of a Prometheus Pushgateway to push metrics to. | Not set | "http://gateway/" | RUSTIC_PROMETHEUS | --prometheus |
| prometheus-user | Username to authenticate to the Prometheus Pushgateway | Not set | "myuser" | RUSTIC_PROMETHEUS_USER | --prometheus-user |
| prometheus-pass | Password to authenticate to the Prometheus Pushgateway | Not set | "secret" | RUSTIC_PROMETHEUS_PASS | --prometheus-pass |
| opentelemetry | OpenTelemetry metrics endpoint (HTTP Protobuf) | Not set | "http://otel/v1/metrics" | RUSTIC_OTEL, OTEL_EXPORTER_OTLP_METRICS_ENDPOINT | --opentelemetry |

### Global Hooks `[global.hooks]`

Expand Down Expand Up @@ -219,7 +221,6 @@ can be overwritten in the source-specific configuration, see below.
| no-scan | Don't scan the backup source for its size (disables ETA). | false | | --no-scan |
| one-file-system | If true, only backs up files from the same filesystem as the source. | false | | --one-file-system |
| parent | Parent snapshot ID for the backup. | Not set | | --parent |
| quiet | Don't output backup summary. | false | | --quiet |
| skip-if-unchanged | Skip saving of the snapshot if it is identical to the parent. | false | | --skip-identical-parent |
| stdin-filename | File name to be used when reading from stdin. | Not set | | --stdin-filename |
| tags | Array of tags for the backup. | [] | | --tag |
Expand Down
3 changes: 2 additions & 1 deletion config/full.toml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@
[global]
use-profiles = []
log-level = "info" # any of "off", "error", "warn", "info", "debug", "trace"; default: "info"
log-level-logfile = "info" # any of "off", "error", "warn", "info", "debug", "trace"; default: "info"
log-level-dryrun = "info" # any of "off", "error", "warn", "info", "debug", "trace"; default: "info"
log-file = "/path/to/rustic.log" # Default: not set
no-progress = false
progress-interval = "100ms"
Expand Down Expand Up @@ -138,7 +140,6 @@ exclude-larger-than = "100MB" # Default: not set
json = false
init = false
no-scan = false
quiet = false
skip-if-unchanged = false
metrics-job = "my-backup-jobs" # Only used if global prometheus or opentelemetry option is set; default: not set

Expand Down
18 changes: 15 additions & 3 deletions src/commands.rs
Original file line number Diff line number Diff line change
Expand Up @@ -266,11 +266,23 @@ impl Configurable<RusticConfig> for EntryPoint {
}

// start logger
let level_filter = match &config.global.log_level {
let log_level = if config.global.dry_run {
&config.global.log_level_dryrun
} else {
&config.global.log_level
};

let level_filter = match log_level {
Some(level) => LevelFilter::from_str(level)
.map_err(|e| FrameworkErrorKind::ConfigError.context(e))?,
None => LevelFilter::Info,
};
let level_filter_logfile = match &config.global.log_level_logfile {
Some(level) => LevelFilter::from_str(level)
.map_err(|e| FrameworkErrorKind::ConfigError.context(e))?,
None => LevelFilter::Info,
};

let term_config = simplelog::ConfigBuilder::new()
.set_time_level(LevelFilter::Off)
.build();
Expand Down Expand Up @@ -298,14 +310,14 @@ impl Configurable<RusticConfig> for EntryPoint {
.context(e)
})?;
let term_logger = TermLogger::new(
level_filter.min(LevelFilter::Warn),
level_filter,
term_config,
TerminalMode::Stderr,
ColorChoice::Auto,
);
CombinedLogger::init(vec![
term_logger,
WriteLogger::new(level_filter, file_config, file),
WriteLogger::new(level_filter_logfile, file_config, file),
])
.map_err(|e| FrameworkErrorKind::ConfigError.context(e))?;
info!("rustic {}", version());
Expand Down
7 changes: 1 addition & 6 deletions src/commands/backup.rs
Original file line number Diff line number Diff line change
Expand Up @@ -93,11 +93,6 @@ pub struct BackupCmd {
#[merge(strategy=conflate::bool::overwrite_false)]
long: bool,

/// Don't show any output
#[clap(long, conflicts_with_all = ["json", "long"])]
#[merge(strategy=conflate::bool::overwrite_false)]
quiet: bool,

/// Initialize repository, if it doesn't exist yet
#[clap(long)]
#[merge(strategy=conflate::bool::overwrite_false)]
Expand Down Expand Up @@ -385,7 +380,7 @@ impl BackupCmd {
fill_table(&snap, add_entry);

println!("{table}");
} else if !self.quiet {
} else {
let summary = snap.summary.as_ref().unwrap();
info!(
"Files: {} new, {} changed, {} unchanged",
Expand Down
6 changes: 1 addition & 5 deletions src/commands/forget.rs
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,6 @@ pub(super) struct ForgetCmd {
#[clap(long)]
json: bool,

/// Don't show any output
#[clap(long, conflicts_with = "json")]
quiet: bool,

/// Forget options
#[clap(flatten)]
config: ForgetOptions,
Expand Down Expand Up @@ -147,7 +143,7 @@ impl ForgetCmd {
if self.json {
let mut stdout = std::io::stdout();
serde_json::to_writer_pretty(&mut stdout, &groups)?;
} else if !self.quiet {
} else {
print_groups(&groups);
}

Expand Down
16 changes: 11 additions & 5 deletions src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -186,11 +186,17 @@ pub struct GlobalOptions {
#[merge(strategy=conflate::option::overwrite_none)]
pub log_level: Option<String>,

/// Write log messages to the given file instead of printing them.
///
/// # Note
///
/// Warnings and errors are still additionally printed unless they are ignored by `--log-level`
/// Use this log level for the log file [default: info]
#[clap(long, global = true, env = "RUSTIC_LOG_LEVEL_LOGFILE")]
#[merge(strategy=conflate::option::overwrite_none)]
pub log_level_logfile: Option<String>,

/// Use this log level in dry-run mode [default: info]
#[clap(long, global = true, env = "RUSTIC_LOG_LEVEL_DRYRUN")]
#[merge(strategy=conflate::option::overwrite_none)]
pub log_level_dryrun: Option<String>,

/// Write log messages to the given file (using log-level-logfile)
#[clap(long, global = true, env = "RUSTIC_LOG_FILE", value_name = "LOGFILE", value_hint = ValueHint::FilePath)]
#[merge(strategy=conflate::option::overwrite_none)]
pub log_file: Option<PathBuf>,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,6 @@ ignore-devid = false
no-scan = false
json = false
long = false
quiet = false
init = false
skip-if-unchanged = false
force = false
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ RusticConfig {
dry_run: false,
check_index: false,
log_level: None,
log_level_logfile: None,
log_level_dryrun: None,
log_file: None,
progress_options: ProgressOptions {
no_progress: false,
Expand Down Expand Up @@ -84,7 +86,6 @@ RusticConfig {
no_scan: false,
json: false,
long: false,
quiet: false,
init: false,
parent_opts: ParentOptions {
group_by: None,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,6 @@ ignore-devid = false
no-scan = false
json = false
long = false
quiet = false
init = false
skip-if-unchanged = false
force = false
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ RusticConfig {
dry_run: false,
check_index: false,
log_level: None,
log_level_logfile: None,
log_level_dryrun: None,
log_file: None,
progress_options: ProgressOptions {
no_progress: false,
Expand Down Expand Up @@ -95,7 +97,6 @@ RusticConfig {
no_scan: false,
json: false,
long: false,
quiet: false,
init: false,
parent_opts: ParentOptions {
group_by: None,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,6 @@ ignore-devid = false
no-scan = false
json = false
long = false
quiet = false
init = false
skip-if-unchanged = false
force = false
Expand Down
1 change: 0 additions & 1 deletion tests/snapshots/show_config__show_config_passes.snap
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,6 @@ ignore-devid = false
no-scan = false
json = false
long = false
quiet = false
init = false
skip-if-unchanged = false
force = false
Expand Down
Loading