]>
git.proxmox.com Git - proxmox-backup.git/blob - src/tape/mod.rs
ed03d8a72131cad2c929899f655e81af2e688049
1 //! Magnetic tape backup
3 use anyhow
::{format_err, Error}
;
5 use proxmox
::tools
::fs
::{
16 pub use tape_write
::*;
30 mod linux_list_drives
;
31 pub use linux_list_drives
::*;
38 pub use media_pool
::*;
41 pub use media_catalog
::*;
44 pub use pool_writer
::*;
46 /// Directory path where we store all tape status information
47 pub const TAPE_STATUS_DIR
: &str = "/var/lib/proxmox-backup/tape";
49 /// Directory path where we store temporary drive state
50 pub const DRIVE_STATE_DIR
: &str = concat
!(PROXMOX_BACKUP_RUN_DIR_M
!(), "/drive-state");
52 /// Directory path where we store cached changer state
53 pub const CHANGER_STATE_DIR
: &str = concat
!(PROXMOX_BACKUP_RUN_DIR_M
!(), "/changer-state");
55 /// We limit chunk archive size, so that we can faster restore a
56 /// specific chunk (The catalog only store file numbers, so we
57 /// need to read the whole archive to restore a single chunk)
58 pub const MAX_CHUNK_ARCHIVE_SIZE
: usize = 4*1024*1024*1024; // 4GB for now
60 /// To improve performance, we need to avoid tape drive buffer flush.
61 pub const COMMIT_BLOCK_SIZE
: usize = 128*1024*1024*1024; // 128 GiB
64 /// Create tape status dir with correct permission
65 pub fn create_tape_status_dir() -> Result
<(), Error
> {
66 let backup_user
= crate::backup
::backup_user()?
;
67 let mode
= nix
::sys
::stat
::Mode
::from_bits_truncate(0o0750);
68 let options
= CreateOptions
::new()
70 .owner(backup_user
.uid
)
71 .group(backup_user
.gid
);
73 create_path(TAPE_STATUS_DIR
, None
, Some(options
))
74 .map_err(|err
: Error
| format_err
!("unable to create tape status dir - {}", err
))?
;
79 /// Create drive state dir with correct permission
80 pub fn create_drive_state_dir() -> Result
<(), Error
> {
81 let backup_user
= crate::backup
::backup_user()?
;
82 let mode
= nix
::sys
::stat
::Mode
::from_bits_truncate(0o0750);
83 let options
= CreateOptions
::new()
85 .owner(backup_user
.uid
)
86 .group(backup_user
.gid
);
88 create_path(DRIVE_STATE_DIR
, None
, Some(options
))
89 .map_err(|err
: Error
| format_err
!("unable to create drive state dir - {}", err
))?
;
94 /// Create changer state cache dir with correct permission
95 pub fn create_changer_state_dir() -> Result
<(), Error
> {
96 let backup_user
= crate::backup
::backup_user()?
;
97 let mode
= nix
::sys
::stat
::Mode
::from_bits_truncate(0o0750);
98 let options
= CreateOptions
::new()
100 .owner(backup_user
.uid
)
101 .group(backup_user
.gid
);
103 create_path(CHANGER_STATE_DIR
, None
, Some(options
))
104 .map_err(|err
: Error
| format_err
!("unable to create changer state dir - {}", err
))?
;