]>
git.proxmox.com Git - proxmox-backup.git/blob - src/tape/mod.rs
5248d21b4676fbb5c03c017e07ce6c21d03f5532
1 //! Magnetic tape backup
3 use anyhow
::{format_err, Error}
;
5 use proxmox
::tools
::fs
::{
10 use pbs_buildcfg
::PROXMOX_BACKUP_RUN_DIR_M
;
18 pub use tape_write
::*;
32 mod linux_list_drives
;
33 pub use linux_list_drives
::*;
40 pub use media_pool
::*;
43 pub use media_catalog
::*;
46 pub use pool_writer
::*;
48 /// Directory path where we store all tape status information
49 pub const TAPE_STATUS_DIR
: &str = "/var/lib/proxmox-backup/tape";
51 /// Directory path where we store temporary drive state
52 pub const DRIVE_STATE_DIR
: &str = concat
!(PROXMOX_BACKUP_RUN_DIR_M
!(), "/drive-state");
54 /// Directory path where we store cached changer state
55 pub const CHANGER_STATE_DIR
: &str = concat
!(PROXMOX_BACKUP_RUN_DIR_M
!(), "/changer-state");
57 /// We limit chunk archive size, so that we can faster restore a
58 /// specific chunk (The catalog only store file numbers, so we
59 /// need to read the whole archive to restore a single chunk)
60 pub const MAX_CHUNK_ARCHIVE_SIZE
: usize = 4*1024*1024*1024; // 4GB for now
62 /// To improve performance, we need to avoid tape drive buffer flush.
63 pub const COMMIT_BLOCK_SIZE
: usize = 128*1024*1024*1024; // 128 GiB
66 /// Create tape status dir with correct permission
67 pub fn create_tape_status_dir() -> Result
<(), Error
> {
68 let backup_user
= crate::backup
::backup_user()?
;
69 let mode
= nix
::sys
::stat
::Mode
::from_bits_truncate(0o0750);
70 let options
= CreateOptions
::new()
72 .owner(backup_user
.uid
)
73 .group(backup_user
.gid
);
75 create_path(TAPE_STATUS_DIR
, None
, Some(options
))
76 .map_err(|err
: Error
| format_err
!("unable to create tape status dir - {}", err
))?
;
81 /// Create drive state dir with correct permission
82 pub fn create_drive_state_dir() -> Result
<(), Error
> {
83 let backup_user
= crate::backup
::backup_user()?
;
84 let mode
= nix
::sys
::stat
::Mode
::from_bits_truncate(0o0750);
85 let options
= CreateOptions
::new()
87 .owner(backup_user
.uid
)
88 .group(backup_user
.gid
);
90 create_path(DRIVE_STATE_DIR
, None
, Some(options
))
91 .map_err(|err
: Error
| format_err
!("unable to create drive state dir - {}", err
))?
;
96 /// Create changer state cache dir with correct permission
97 pub fn create_changer_state_dir() -> Result
<(), Error
> {
98 let backup_user
= crate::backup
::backup_user()?
;
99 let mode
= nix
::sys
::stat
::Mode
::from_bits_truncate(0o0750);
100 let options
= CreateOptions
::new()
102 .owner(backup_user
.uid
)
103 .group(backup_user
.gid
);
105 create_path(CHANGER_STATE_DIR
, None
, Some(options
))
106 .map_err(|err
: Error
| format_err
!("unable to create changer state dir - {}", err
))?
;