add backup count configable
This commit is contained in:
11
src/main.rs
11
src/main.rs
@@ -104,12 +104,17 @@ pub fn process_config_item(options: &Options, config_item: &OSSBackupdConfigItem
|
||||
}
|
||||
|
||||
let oss_client = OSSClient::new(endpoint, access_key_id, access_key_secret);
|
||||
let default_limit = 10_usize; // TODO read from config!
|
||||
let mut backup_count = config_item.backup_count.unwrap_or(10u32) as usize;
|
||||
if backup_count < 1_usize {
|
||||
backup_count = 1_usize;
|
||||
} else if backup_count > 10000_usize {
|
||||
backup_count = 10000_usize;
|
||||
}
|
||||
let meta_file_name = &format!("{}/ossbackupd_meta_{}_{}.json", &oss_backupd_config.get_prefix(), &oss_backupd_config.get_host(), &config_item.get_file_name());
|
||||
let new_file = format!("{}/{}", path, config_item.make_oss_key(&oss_backupd_config, "gpg"));
|
||||
|
||||
if options.verbose {
|
||||
print_message(MessageType::DEBUG, &format!("Default limit: {}", default_limit));
|
||||
print_message(MessageType::DEBUG, &format!("Backup count: {}", backup_count));
|
||||
print_message(MessageType::DEBUG, &format!("Meta file name: {}", meta_file_name));
|
||||
print_message(MessageType::DEBUG, &format!("New backup file: {}", new_file));
|
||||
}
|
||||
@@ -179,7 +184,7 @@ pub fn process_config_item(options: &Options, config_item: &OSSBackupdConfigItem
|
||||
if options.verbose {
|
||||
print_message(MessageType::DEBUG, &format!("Processing meta file: {}", meta_file_name));
|
||||
}
|
||||
match process_oss_files(&options, &oss_client, bucket, path, meta_file_name, &new_file, default_limit) {
|
||||
match process_oss_files(&options, &oss_client, bucket, path, meta_file_name, &new_file, backup_count) {
|
||||
Err(e) => {
|
||||
print_message(MessageType::ERROR, &format!("Error: {}, at item index: {}", e, item_index));
|
||||
},
|
||||
|
||||
Reference in New Issue
Block a user