tape: add media state database

This commit is contained in:
Dietmar Maurer
2020-12-09 10:16:01 +01:00
parent eaff09f483
commit cafd51bf42
8 changed files with 465 additions and 10 deletions

View File

@ -1,3 +1,10 @@
use anyhow::{format_err, Error};
use proxmox::tools::fs::{
create_path,
CreateOptions,
};
pub mod file_formats;
mod tape_write;
@ -18,8 +25,14 @@ pub use changer::*;
mod drive;
pub use drive::*;
/// Directory path where we stora all status information
pub const MEDIA_POOL_STATUS_DIR: &str = "/var/lib/proxmox-backup/mediapool";
mod media_state_database;
pub use media_state_database::*;
mod online_status_map;
pub use online_status_map::*;
/// Directory path where we store all tape status information
pub const TAPE_STATUS_DIR: &str = "/var/lib/proxmox-backup/tape";
/// We limit chunk archive size, so that we can faster restore a
/// specific chunk (The catalog only store file numbers, so we
@ -28,3 +41,19 @@ pub const MAX_CHUNK_ARCHIVE_SIZE: usize = 4*1024*1024*1024; // 4GB for now
/// To improve performance, we need to avoid tape drive buffer flush.
pub const COMMIT_BLOCK_SIZE: usize = 128*1024*1024*1024; // 128 GiB
/// Create tape status dir with correct permission
pub fn create_tape_status_dir() -> Result<(), Error> {
let backup_user = crate::backup::backup_user()?;
let mode = nix::sys::stat::Mode::from_bits_truncate(0o0640);
let opts = CreateOptions::new()
.perm(mode)
.owner(backup_user.uid)
.group(backup_user.gid);
create_path(TAPE_STATUS_DIR, None, Some(opts))
.map_err(|err: Error| format_err!("unable to create tape status dir - {}", err))?;
Ok(())
}