]> git.proxmox.com Git - proxmox-backup.git/blob - src/tape/mod.rs
tape: add media pool handling
[proxmox-backup.git] / src / tape / mod.rs
1 use anyhow::{format_err, Error};
2
3 use proxmox::tools::fs::{
4 create_path,
5 CreateOptions,
6 };
7
8 pub mod file_formats;
9
10 mod tape_write;
11 pub use tape_write::*;
12
13 mod tape_read;
14 pub use tape_read::*;
15
16 mod helpers;
17 pub use helpers::*;
18
19 mod inventory;
20 pub use inventory::*;
21
22 mod changer;
23 pub use changer::*;
24
25 mod drive;
26 pub use drive::*;
27
28 mod media_state_database;
29 pub use media_state_database::*;
30
31 mod online_status_map;
32 pub use online_status_map::*;
33
34 mod media_pool;
35 pub use media_pool::*;
36
37 /// Directory path where we store all tape status information
38 pub const TAPE_STATUS_DIR: &str = "/var/lib/proxmox-backup/tape";
39
40 /// We limit chunk archive size, so that we can faster restore a
41 /// specific chunk (The catalog only store file numbers, so we
42 /// need to read the whole archive to restore a single chunk)
43 pub const MAX_CHUNK_ARCHIVE_SIZE: usize = 4*1024*1024*1024; // 4GB for now
44
45 /// To improve performance, we need to avoid tape drive buffer flush.
46 pub const COMMIT_BLOCK_SIZE: usize = 128*1024*1024*1024; // 128 GiB
47
48
49 /// Create tape status dir with correct permission
50 pub fn create_tape_status_dir() -> Result<(), Error> {
51 let backup_user = crate::backup::backup_user()?;
52 let mode = nix::sys::stat::Mode::from_bits_truncate(0o0640);
53 let opts = CreateOptions::new()
54 .perm(mode)
55 .owner(backup_user.uid)
56 .group(backup_user.gid);
57
58 create_path(TAPE_STATUS_DIR, None, Some(opts))
59 .map_err(|err: Error| format_err!("unable to create tape status dir - {}", err))?;
60
61 Ok(())
62 }