2020-10-15 10:49:15 +00:00
|
|
|
//! See the different modules for documentation on their usage.
|
|
|
|
//!
|
|
|
|
//! The [backup](backup/index.html) module contains some detailed information
|
|
|
|
//! on the inner workings of the backup server regarding data storage.
|
|
|
|
|
2021-09-29 12:01:38 +00:00
|
|
|
use std::path::PathBuf;
|
|
|
|
|
2021-10-13 08:24:39 +00:00
|
|
|
use once_cell::sync::OnceCell;
|
|
|
|
use anyhow::{format_err, Error};
|
|
|
|
|
2021-10-06 05:06:17 +00:00
|
|
|
use proxmox::tools::fs::CreateOptions;
|
|
|
|
|
2021-09-29 12:01:38 +00:00
|
|
|
use pbs_buildcfg::configdir;
|
|
|
|
use pbs_tools::cert::CertInfo;
|
2021-10-06 05:06:17 +00:00
|
|
|
use proxmox_rrd::RRDCache;
|
2021-09-29 12:01:38 +00:00
|
|
|
|
2019-01-24 13:59:40 +00:00
|
|
|
#[macro_use]
|
2019-01-05 15:53:28 +00:00
|
|
|
pub mod tools;
|
|
|
|
|
2019-01-14 11:26:04 +00:00
|
|
|
#[macro_use]
|
2019-04-06 07:17:25 +00:00
|
|
|
pub mod server;
|
2018-11-15 09:14:08 +00:00
|
|
|
|
2019-06-05 06:41:20 +00:00
|
|
|
#[macro_use]
|
2018-12-31 15:08:04 +00:00
|
|
|
pub mod backup;
|
2018-12-07 09:51:53 +00:00
|
|
|
|
2019-02-16 11:19:13 +00:00
|
|
|
pub mod config;
|
2018-12-08 12:58:45 +00:00
|
|
|
|
2019-01-22 11:10:38 +00:00
|
|
|
pub mod api2;
|
2019-01-16 09:15:39 +00:00
|
|
|
|
2019-01-29 15:55:49 +00:00
|
|
|
pub mod auth_helpers;
|
2020-04-08 09:57:14 +00:00
|
|
|
|
|
|
|
pub mod auth;
|
2020-05-23 07:29:33 +00:00
|
|
|
|
2020-12-05 09:45:08 +00:00
|
|
|
pub mod tape;
|
2021-05-03 09:39:52 +00:00
|
|
|
|
|
|
|
pub mod acme;
|
2021-09-29 09:05:26 +00:00
|
|
|
|
|
|
|
pub mod client_helpers;
|
2021-09-29 12:01:38 +00:00
|
|
|
|
|
|
|
/// Get the server's certificate info (from `proxy.pem`).
|
|
|
|
pub fn cert_info() -> Result<CertInfo, anyhow::Error> {
|
|
|
|
CertInfo::from_path(PathBuf::from(configdir!("/proxy.pem")))
|
|
|
|
}
|
2021-10-06 05:06:17 +00:00
|
|
|
|
2021-10-13 08:24:39 +00:00
|
|
|
pub static RRD_CACHE: OnceCell<RRDCache> = OnceCell::new();
|
|
|
|
|
|
|
|
/// Get the RRD cache instance
|
|
|
|
pub fn get_rrd_cache() -> Result<&'static RRDCache, Error> {
|
|
|
|
RRD_CACHE.get().ok_or_else(|| format_err!("RRD cache not initialized!"))
|
|
|
|
}
|
|
|
|
|
|
|
|
/// Initialize the RRD cache instance
|
|
|
|
///
|
|
|
|
/// Note: Only a single process must do this (proxmox-backup-proxy)
|
|
|
|
pub fn initialize_rrd_cache() -> Result<&'static RRDCache, Error> {
|
|
|
|
|
|
|
|
let backup_user = pbs_config::backup_user()?;
|
|
|
|
|
|
|
|
let file_options = CreateOptions::new()
|
|
|
|
.owner(backup_user.uid)
|
|
|
|
.group(backup_user.gid);
|
|
|
|
|
|
|
|
let dir_options = CreateOptions::new()
|
|
|
|
.owner(backup_user.uid)
|
|
|
|
.group(backup_user.gid);
|
|
|
|
|
|
|
|
let apply_interval = 30.0*60.0; // 30 minutes
|
|
|
|
|
|
|
|
let cache = RRDCache::new(
|
|
|
|
"/var/lib/proxmox-backup/rrdb",
|
|
|
|
Some(file_options),
|
|
|
|
Some(dir_options),
|
|
|
|
apply_interval,
|
|
|
|
)?;
|
|
|
|
|
|
|
|
RRD_CACHE.set(cache)
|
|
|
|
.map_err(|_| format_err!("RRD cache already initialized!"))?;
|
|
|
|
|
|
|
|
Ok(RRD_CACHE.get().unwrap())
|
2021-10-06 05:06:17 +00:00
|
|
|
}
|