controller/cloudnativepg/
scheduledbackups.rs

1// WARNING: generated by kopium - manual changes will be overwritten
2// kopium command: kopium -D Default scheduledbackups.postgresql.cnpg.io -A
3// kopium version: 0.16.5
4
5use kube::CustomResource;
6use schemars::JsonSchema;
7use serde::{Deserialize, Serialize};
8
9/// Specification of the desired behavior of the ScheduledBackup. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#spec-and-status
10#[derive(CustomResource, Serialize, Deserialize, Clone, Debug, Default, JsonSchema)]
11#[kube(
12    group = "postgresql.cnpg.io",
13    version = "v1",
14    kind = "ScheduledBackup",
15    plural = "scheduledbackups"
16)]
17#[kube(namespaced)]
18#[kube(status = "ScheduledBackupStatus")]
19pub struct ScheduledBackupSpec {
20    /// Indicates which ownerReference should be put inside the created backup resources.<br /> - none: no owner reference for created backup objects (same behavior as before the field was introduced)<br /> - self: sets the Scheduled backup object as owner of the backup<br /> - cluster: set the cluster as owner of the backup<br />
21    #[serde(
22        default,
23        skip_serializing_if = "Option::is_none",
24        rename = "backupOwnerReference"
25    )]
26    pub backup_owner_reference: Option<ScheduledBackupBackupOwnerReference>,
27    /// The cluster to backup
28    pub cluster: ScheduledBackupCluster,
29    /// If the first backup has to be immediately start after creation or not
30    #[serde(default, skip_serializing_if = "Option::is_none")]
31    pub immediate: Option<bool>,
32    /// The backup method to be used, possible options are `barmanObjectStore` and `volumeSnapshot`. Defaults to: `barmanObjectStore`.
33    #[serde(default, skip_serializing_if = "Option::is_none")]
34    pub method: Option<ScheduledBackupMethod>,
35    /// Whether the default type of backup with volume snapshots is online/hot (`true`, default) or offline/cold (`false`) Overrides the default setting specified in the cluster field '.spec.backup.volumeSnapshot.online'
36    #[serde(default, skip_serializing_if = "Option::is_none")]
37    pub online: Option<bool>,
38    /// Configuration parameters to control the online/hot backup with volume snapshots Overrides the default settings specified in the cluster '.backup.volumeSnapshot.onlineConfiguration' stanza
39    #[serde(
40        default,
41        skip_serializing_if = "Option::is_none",
42        rename = "onlineConfiguration"
43    )]
44    pub online_configuration: Option<ScheduledBackupOnlineConfiguration>,
45    /// The schedule does not follow the same format used in Kubernetes CronJobs as it includes an additional seconds specifier, see https://pkg.go.dev/github.com/robfig/cron#hdr-CRON_Expression_Format
46    pub schedule: String,
47    /// If this backup is suspended or not
48    #[serde(default, skip_serializing_if = "Option::is_none")]
49    pub suspend: Option<bool>,
50    /// The policy to decide which instance should perform this backup. If empty, it defaults to `cluster.spec.backup.target`. Available options are empty string, `primary` and `prefer-standby`. `primary` to have backups run always on primary instances, `prefer-standby` to have backups run preferably on the most updated standby, if available.
51    #[serde(default, skip_serializing_if = "Option::is_none")]
52    pub target: Option<ScheduledBackupTarget>,
53}
54
55/// Specification of the desired behavior of the ScheduledBackup. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#spec-and-status
56#[derive(Serialize, Deserialize, Clone, Debug, JsonSchema)]
57pub enum ScheduledBackupBackupOwnerReference {
58    #[serde(rename = "none")]
59    None,
60    #[serde(rename = "self")]
61    r#_Self,
62    #[serde(rename = "cluster")]
63    Cluster,
64}
65
66/// The cluster to backup
67#[derive(Serialize, Deserialize, Clone, Debug, Default, JsonSchema)]
68pub struct ScheduledBackupCluster {
69    /// Name of the referent.
70    pub name: String,
71}
72
73/// Specification of the desired behavior of the ScheduledBackup. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#spec-and-status
74#[derive(Serialize, Deserialize, Clone, Debug, JsonSchema, PartialEq)]
75pub enum ScheduledBackupMethod {
76    #[serde(rename = "barmanObjectStore")]
77    BarmanObjectStore,
78    #[serde(rename = "volumeSnapshot")]
79    VolumeSnapshot,
80}
81
82/// Configuration parameters to control the online/hot backup with volume snapshots Overrides the default settings specified in the cluster '.backup.volumeSnapshot.onlineConfiguration' stanza
83#[derive(Serialize, Deserialize, Clone, Debug, Default, JsonSchema)]
84pub struct ScheduledBackupOnlineConfiguration {
85    /// Control whether the I/O workload for the backup initial checkpoint will be limited, according to the `checkpoint_completion_target` setting on the PostgreSQL server. If set to true, an immediate checkpoint will be used, meaning PostgreSQL will complete the checkpoint as soon as possible. `false` by default.
86    #[serde(
87        default,
88        skip_serializing_if = "Option::is_none",
89        rename = "immediateCheckpoint"
90    )]
91    pub immediate_checkpoint: Option<bool>,
92    /// If false, the function will return immediately after the backup is completed, without waiting for WAL to be archived. This behavior is only useful with backup software that independently monitors WAL archiving. Otherwise, WAL required to make the backup consistent might be missing and make the backup useless. By default, or when this parameter is true, pg_backup_stop will wait for WAL to be archived when archiving is enabled. On a standby, this means that it will wait only when archive_mode = always. If write activity on the primary is low, it may be useful to run pg_switch_wal on the primary in order to trigger an immediate segment switch.
93    #[serde(
94        default,
95        skip_serializing_if = "Option::is_none",
96        rename = "waitForArchive"
97    )]
98    pub wait_for_archive: Option<bool>,
99}
100
101/// Specification of the desired behavior of the ScheduledBackup. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#spec-and-status
102#[derive(Serialize, Deserialize, Clone, Debug, JsonSchema)]
103pub enum ScheduledBackupTarget {
104    #[serde(rename = "primary")]
105    Primary,
106    #[serde(rename = "prefer-standby")]
107    PreferStandby,
108}
109
110/// Most recently observed status of the ScheduledBackup. This data may not be up to date. Populated by the system. Read-only. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#spec-and-status
111#[derive(Serialize, Deserialize, Clone, Debug, Default, JsonSchema)]
112pub struct ScheduledBackupStatus {
113    /// The latest time the schedule
114    #[serde(
115        default,
116        skip_serializing_if = "Option::is_none",
117        rename = "lastCheckTime"
118    )]
119    pub last_check_time: Option<String>,
120    /// Information when was the last time that backup was successfully scheduled.
121    #[serde(
122        default,
123        skip_serializing_if = "Option::is_none",
124        rename = "lastScheduleTime"
125    )]
126    pub last_schedule_time: Option<String>,
127    /// Next time we will run a backup
128    #[serde(
129        default,
130        skip_serializing_if = "Option::is_none",
131        rename = "nextScheduleTime"
132    )]
133    pub next_schedule_time: Option<String>,
134}