Examples

This section provides examples of TrilioVault Custom Resources.

End-to-end examples are also available in the Getting Started Section

Backup Target

The Backup Target CRD specifies the backup storage media. TrilioVault supports either AWS S3 compatible object storage or NFS. A user can configure multiple backup targets and choose the target when an Application CR is created. All backups that are created for that Application will be saved on the backup target specified in Application CR spec. Once a backup target is chosen for an Application, it cannot be changed.

Example 1 - S3 Target: AWS

Sample YAML file for AWS based S3 bucket

apiVersion: triliovault.trilio.io/v1
kind: Target
metadata:
name: demo-s3-target
spec:
type: ObjectStore
vendor: AWS
objectStoreCredentials:
url: "https://s3.amazonaws.com"
accessKey: "AaBbCcDdEeFf"
secretKey: "BogusKeyEntry"
bucketName: "S3_Bucket_US_East"
region: "us-east-1"

Example 2 - S3 Target: Non-AWS

Sample YAML file for non AWS S3 compatible bucket. The only difference between this spec and AWS S3 spec is the explicit specification on URL.

apiVersion: triliovault.trilio.io/v1
kind: Target
metadata:
name: sample-target
spec:
type: ObjectStore
vendor: Ceph
objectStoreCredentials:
url: "http://bucket.s3.dualstack.region.acme.com/key"
accessKey: "XXXXXXXXXXXXXXXXXXXX"
secretKey: "YYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYY"
bucketName: "datahub-dev"
region: "us-west-1"

Example 3 - NFS Target Example

Sample YAML for NFS share.

apiVersion: triliovault.trilio.io/v1
kind: Target
metadata:
name: sample-target
spec:
type: NFS
vendor: Other
nfsCredentials:
nfsExport: 192.168.1.1:/src/nfs/kubedata
nfsOptions: nfsvers=4
thresholdCapacity: 1000Gi

Additional values for the nfsOptions field can be found here

Retention Policy

The retention policy CRD enables users to define the number of backups to retain and the cadence to delete backups as per compliance requirements. The retention policy CRD provides a simple YAML specification to define the number of backups to retain in terms of days, weeks, months, years, latest etc.

Retention Polices are referenced within a BackupPlan and can be added to any of the example YAML files provided below

The current version only supports a policy of type as "Retention".

Example - Retention Policy

apiVersion: triliovault.trilio.io/v1
kind: Policy
metadata:
name: sample-policy
spec:
type: Retention
default: false
retentionConfig:
latest: 2
weekly: 1
dayOfWeek: Wednesday
monthly: 1
dateOfMonth: 15
monthOfYear: March
yearly: 1

Hooks

Hooks enable injecting commands into pods/containers before and after a backup via pre/post commands. Hooks enable taking application consistent backups and extending backup workflows.

Hooks for MySQL

apiVersion: triliovault.trilio.io/v1
kind: Hook
metadata:
name: mysql-hook
spec:
pre:
execAction:
command:
- "bash"
- "-c"
- "mysql --user=root --password=$MYSQL_ROOT_PASSWORD -Bse 'FLUSH TABLES WITH READ LOCK;system ${WAIT_CMD};'"
ignoreFailure: false
maxRetryCount: 1
timeoutSeconds: 10
post:
execAction:
command:
- "bash"
- "-c"
- "mysql --user=root --password=$MYSQL_ROOT_PASSWORD -Bse 'FLUSH LOGS; UNLOCK TABLES;'"
ignoreFailure: false
maxRetryCount: 1
timeoutSeconds: 10

BackupPlan for MySQL Hooks

apiVersion: triliovault.trilio.io/v1
kind: BackupPlan
metadata:
name: mysql-backupplan
spec:
backupNamespace: default
backupConfig:
target:
name: sample-target
retentionPolicy:
name: sample-policy
hookConfig:
mode: Sequential
hooks:
- hook:
name: mysql-hook
podSelector:
labels:
- matchLabels:
app: mysql-qa
regex: mysql-qa*
containerRegex: mysql-qa*

Hooks for Cassandra

apiVersion: triliovault.trilio.io/v1
kind: Hook
metadata:
name: cassandra-hook
spec:
pre:
execAction:
command:
- "bash"
- "-c"
- "nodetool flush -- demodb;"
ignoreFailure: false
maxRetryCount: 1
timeoutSeconds: 10
post:
execAction:
command:
- "bash"
- "-c"
- "nodetool verify -- demodb;"
ignoreFailure: false
maxRetryCount: 1
timeoutSeconds: 10

BackupPlan for Cassandra Hooks

apiVersion: triliovault.trilio.io/v1
kind: BackupPlan
metadata:
name: cassandra-backupplan
spec:
backupNamespace: default
backupConfig:
target:
name: sample-target
retentionPolicy:
name: sample-policy
hookConfig:
mode: Sequential
hooks:
- hook:
name: cassandra-hook
podSelector:
labels:
- matchLabels:
app: my-release-cassandra
regex: my-release-cassandra*
containerRegex: my-release-cassandra*

Hooks for MongoDB

apiVersion: triliovault.trilio.io/v1
kind: Hook
metadata:
name: mongo-hook
spec:
pre:
execAction:
command:
- "/bin/bash"
- "-c"
- "/opt/bitnami/mongodb/bin/mongo --eval 'printjson(db.fsyncLock())' --host 'mongotest-mongodb' --authenticationDatabase admin -u root -p $MONGODB_ROOT_PASSWORD"
ignoreFailure: false
maxRetryCount: 2
timeoutSeconds: 10
post:
execAction:
command:
- "/bin/bash"
- "-c"
- "/opt/bitnami/mongodb/bin/mongo --eval 'printjson(db.fsyncUnlock())' --host 'mongotest-mongodb' --authenticationDatabase admin -u root -p $MONGODB_ROOT_PASSWORD"
ignoreFailure: false
maxRetryCount: 2
timeoutSeconds: 10

BackupPlan for MongoDB

apiVersion: triliovault.trilio.io/v1
kind: BackupPlan
metadata:
name: mongo-backupplan
spec:
backupNamespace: default
backupConfig:
target:
name: sample-target
retentionPolicy:
name: sample-policy
hookConfig:
mode: Sequential
hooks:
- hook:
name: mongo-hook
podSelector:
regex: mongotest-mongodb*
containerRegex: mongodb*

Hooks for MariaDB

apiVersion: triliovault.trilio.io/v1
kind: Hook
metadata:
name: mariadb-hook
spec:
pre:
execAction:
command:
- "bash"
- "-c"
- "mysql --user=root --password=$MARIADB_ROOT_PASSWORD -Bse 'FLUSH TABLES WITH READ LOCK;system ${WAIT_CMD};'"
ignoreFailure: false
maxRetryCount: 1
timeoutSeconds: 10
post:
execAction:
command:
- "bash"
- "-c"
- "mysql --user=root --password=$MARIADB_ROOT_PASSWORD -Bse 'FLUSH LOGS; UNLOCK TABLES;'"
ignoreFailure: false
maxRetryCount: 1
timeoutSeconds: 10

BackupPlan for MariaDB Hooks

apiVersion: triliovault.trilio.io/v1
kind: BackupPlan
metadata:
name: mariadb-backupplan
spec:
backupNamespace: default
backupConfig:
target:
name: sample-target
retentionPolicy:
name: sample-policy
hookConfig:
mode: Sequential
hooks:
- hook:
name: mariadb-hook
podSelector:
labels:
- matchLabels:
app.kubernetes.io/name: mariadb
regex: mariadb*
containerRegex: mariadb*

Hooks for Redis

apiVersion: triliovault.trilio.io/v1
kind: Hook
metadata:
name: redis-hook
spec:
pre:
execAction:
command:
- "bash"
- "-c"
- "echo 'SAVE' | redis-cli -h my-release-redis-master -a $REDIS_PASSWORD --no-auth-warning"
ignoreFailure: false
maxRetryCount: 1
timeoutSeconds: 10
post:
execAction:
command:
- "bash"
- "-c"
- "echo 'post hook action completed'"
ignoreFailure: false
maxRetryCount: 1
timeoutSeconds: 10

BackupPlan for Redis Hooks

apiVersion: triliovault.trilio.io/v1
kind: BackupPlan
metadata:
name: redis-backupplan
spec:
backupNamespace: default
backupConfig:
target:
name: sample-target
retentionPolicy:
name: sample-policy
hookConfig:
mode: Sequential
hooks:
- hook:
name: redis-hook
podSelector:
labels:
- matchLabels:
app: redis
role: master
regex: my-release-redis-master*

Hooks for PostgreSQL

apiVersion: triliovault.trilio.io/v1
kind: Hook
metadata:
name: postgres-hook
spec:
pre:
execAction:
command:
- "PGPASSWORD=$POSTGRES_PASSWORD; psql -U '$POSTGRES_USER' -c 'CHECKPOINT';"
ignoreFailure: false
maxRetryCount: 1
timeoutSeconds: 10
post:
execAction:
command:
- "bash"
- "-c"
- "echo 'post hook action completed'"
Ignore Failure: false
Max Retry Count: 1
Timeout Seconds: 10

BackupPlan for PostgreSQL

apiVersion: triliovault.trilio.io/v1
kind: BackupPlan
metadata:
name: postgres-backupplan
spec:
backupNamespace: default
backupConfig:
target:
name: sample-target
retentionPolicy:
name: sample-policy
hookConfig:
mode: Sequential
hooks:
- hook:
name: postgres-hook
podSelector:
labels:
- matchLabels:
app.kubernetes.io/name: postgresql
regex: postgres-postgresql*
containerRegex: postgres-postgresql*

Hooks for InfluxDB

apiVersion: triliovault.trilio.io/v1
kind: Hook
metadata:
name: influxdb-hook
spec:
pre:
execAction:
command:
- "bash"
- "-c"
- "bkpfile=/tmp/snap`date +%Y%m%dT%H%M`; influxd backup $bkpfile"
ignoreFailure: false
maxRetryCount: 1
timeoutSeconds: 10
post:
execAction:
command:
- "bash"
- "-c"
- "echo 'post hook action completed'"
ignoreFailure: false
maxRetryCount: 1
timeoutSeconds: 10

BackupPlan for InfluxDB

apiVersion: triliovault.trilio.io/v1
kind: BackupPlan
metadata:
name: influxdb-backupplan
spec:
backupNamespace: default
backupConfig:
target:
name: sample-target
retentionPolicy:
name: sample-policy
backupPlanComponents:
custom:
- matchLabels:
app: influxdb
hookConfig:
mode: Sequential
hooks:
- hook:
name: influxdb-hook
podSelector:
labels:
- matchLabels:
app: influxdb
regex: influxdb*

Hooks for Elasticsearch

apiVersion: triliovault.trilio.io/v1
kind: Hook
metadata:
name: es-hook
spec:
pre:
execAction:
command:
- "bash"
- "-c"
- "curl -XPOST 'http://localhost:9200/test/_flush?pretty=true'; curl -H'Content-Type: application/json' -XPUT localhost:9200/test/_settings?pretty -d'{\"index\": {\"blocks.read_only\": true} }'"
ignoreFailure: false
maxRetryCount: 1
timeoutSeconds: 10
post:
execAction:
command:
- "bash"
- "-c"
- "curl -H'Content-Type: application/json' -XPUT localhost:9200/test/_settings?pretty -d'{\"index\": {\"blocks.read_only\": false} }'"
ignoreFailure: false
maxRetryCount: 1
timeoutSeconds: 10

BackupPlan for Elasticsearch

apiVersion: triliovault.trilio.io/v1
kind: BackupPlan
metadata:
name: es-backupplan
spec:
backupNamespace: default
backupConfig:
target:
name: sample-target
retentionPolicy:
name: sample-policy
hookConfig:
mode: Sequential
hooks:
- hook:
name: es-hook
podSelector:
labels:
- matchLabels:
app: master
app.kubernetes.io/name: elasticsearch
regex: my-release-elasticsearch-master*
containerRegex: elasticsearch*

Hooks for Kafka

apiVersion: triliovault.trilio.io/v1
kind: Hook
metadata:
name: kafka-hook
spec:
pre:
execAction:
command:
- "bash"
- "-c"
- "/opt/bitnami/kafka/bin/kafka-server-stop.sh -daemon /opt/bitnami/kafka/config/server.properties"
ignoreFailure: false
maxRetryCount: 1
timeoutSeconds: 10
post:
execAction:
command:
- "bash"
- "-c"
- "/opt/bitnami/kafka/bin/kafka-server-start.sh -daemon /opt/bitnami/kafka/config/server.properties"
ignoreFailure: false
maxRetryCount: 1
timeoutSeconds: 10

BackupPlan for Kafka

apiVersion: triliovault.trilio.io/v1
kind: BackupPlan
metadata:
name: kafka-backupplan
spec:
backupNamespace: default
backupConfig:
target:
name: sample-target
retentionPolicy:
name: sample-policy
hookConfig:
mode: Sequential
hooks:
- hook:
name: kafka-hook
podSelector:
labels:
- matchLabels:
app.kubernetes.io/name: kafka
regex: my-release-kafka*
containerRegex: kafka*

Hooks for CockroachDB

apiVersion: triliovault.trilio.io/v1
kind: Hook
metadata:
name: cockroachdb-hook
spec:
pre:
execAction:
command:
- "bash"
- "-c"
- "bkpfile=/tmp/snap`date +%Y%m%dT%H%M`.sql;cockroach dump --dump-all --insecure > $bkpfile"
ignoreFailure: false
maxRetryCount: 1
timeoutSeconds: 10
post:
execAction:
command:
- "bash"
- "-c"
- "echo 'post hook action completed'"
ignoreFailure: false
maxRetryCount: 1
timeoutSeconds: 10

BackupPlan for CockroachDB

apiVersion: triliovault.trilio.io/v1
kind: BackupPlan
metadata:
name: cockroach-helm-backup-plan
spec:
backupNamespace: default
backupConfig:
target:
name: sample-target
retentionPolicy:
name: sample-policy
hookConfig:
mode: Sequential
hooks:
- hook:
name: cockroachdb-hook
podSelector:
labels:
- matchLabels:
app.kubernetes.io/name: cockroachdb
app.kubernetes.io/component: cockroachdb
regex: my-release-cockroachdb-0*

BackupPlan

The BackupPlan CRD specifies the backup job. The specification includes the backup schedule, backup target and the resources to backup. TrilioVault supports three types of resources to backup and an BackupPlan CR may include combination of these resources.

This BackupPlan CR defines a set of resources to backup.Resources can be defined in the form of Helm release, Operators or just bare k8s api resources.

In this release, TrilioVault supports backup of the following:

  1. Helm releases

  2. Operator-based application instances

  3. Label-based selection of resources

  4. Namespaces

Type: Custom Label - Example 1

The following sample BackupPlan CR specifies a Label-based selection of resources. In this example any resource has a label app with valuegcp-compute-persistent-disk-csi-driver will be backed up.

apiVersion: triliovault.trilio.io/v1
kind: BackupPlan
metadata:
name: sample-application
spec:
backupConfig:
target:
name: sample-target
schedulePolicy:
fullBackupCron:
schedule: "* 0 1 * *"
incrementalCron:
schedule: "* 0 * * *"
backupNamespace: triliovault-integration
backupPlanComponents:
custom:
- matchLabels:
app: gcp-compute-persistent-disk-csi-driver

Type: Custom Label - Example 2 - Multiple Labels

The example below explains how a backupPlan CR can be used to protect data using multiple labels.

apiVersion: triliovault.trilio.io/v1
kind: BackupPlan
metadata:
name: sample-application
spec:
backupNamespace: triliovault-integration
backupConfig:
target:
name: sample-target
backupPlanComponents:
custom:
- matchLabels:
app: frontend
- matchLabels:
app: backend

Type: Helm - Example 1 - Single Helm Release

The following sample BackupPlan CR that specifies Helm release based resources to backup. TrilioVault automatically discovers the resources that belong to the release and backups the helm chart as whole. The release that this example backups is mysql-releasename.

apiVersion: triliovault.trilio.io/v1
kind: BackupPlan
metadata:
name: sample-application
spec:
backupConfig:
target:
name: sample-target
schedulePolicy:
fullBackupCron:
schedule: "* 0 1 * *"
incrementalCron:
schedule: "* 0 * * *"
backupNamespace: triliovault-integration
backupPlanComponents:
helmReleases:
- mysql-releasename

Type: Helm - Example 2 - Multiple Helm Releases

apiVersion: triliovault.trilio.io/v1
kind: BackupPlan
metadata:
name: sample-application
spec:
backupNamespace: triliovault-integration
backupConfig:
target:
name: sample-target
backupPlanComponents:
helmReleases:
- sample-release
- sample-release1

Type Operator - Example 1

Another type of resource that TrilioVault supports is an Operator-based applications and the following YAML snippet describes the BackupPlan CR that includes the operator based application.

Example 1a

apiVersion: triliovault.trilio.io/v1
kind: BackupPlan
metadata:
name: sample-application
spec:
backupNamespace: triliovault-integration
backupConfig:
target:
name: sample-target
backupPlanComponents:
operators:
- operatorId: sample-mysqlcluster
customResources:
- groupVersionKind:
group: "mysql.presslabs.org"
version: "v1alpha1"
kind: "MysqlCluster"
objects:
- sample-mysqlcluster
- groupVersionKind:
group: "mysql.presslabs.org"
version: "v1alpha1"
kind: "MysqlBackup"
operatorResourceSelector:
- matchLabels:
app: mysql-operator
release: sample-release
applicationResourceSelector:
- matchLabels:
app.kubernetes.io/managed-by: mysql.presslabs.org
app.kubernetes.io/name: mysql

Example 1b

apiVersion: triliovault.trilio.io/v1
kind: BackupPlan
metadata:
name: sample-application
spec:
backupNamespace: triliovault-integration
backupConfig:
target:
name: sample-target
backupPlanComponents:
operators:
- operatorId: etcd-cluster
customResources:
- groupVersionKind:
group: "etcd.database.coreos.com"
version: "v1beta2"
kind: "EtcdCluster"
objects:
- etcd-cluster
operatorResourceSelector: # sa, clusterrole, clusterrolebinding, deployment
- matchLabels:
app: etcd-operator
release: sample-release
applicationResourceSelector: # svc: etcd-cluster, etcd-cluster-client
- matchLabels:
app: etcd
etcd_cluster: etcd-cluster

Type Operator - Example 2 - Multiple Operators

The YAML definition below provides an example of how multiple helm apps can be protected through the BackupPlan CR.

apiVersion: triliovault.trilio.io/v1
kind: BackupPlan
metadata:
name: sample-application
spec:
backupNamespace: triliovault-integration
backupConfig:
target:
name: sample-target
backupPlanComponents:
operators:
- operatorId: sample-mysqlcluster
customResources:
- groupVersionKind:
group: "mysql.presslabs.org"
version: "v1alpha1"
kind: "MysqlCluster"
objects:
- sample-mysqlcluster
- groupVersionKind:
group: "mysql.presslabs.org"
version: "v1alpha1"
kind: "MysqlBackup"
operatorResourceSelector:
- matchLabels:
app: mysql-operator
release: sample-release
applicationResourceSelector:
- matchLabels:
app.kubernetes.io/managed-by: mysql.presslabs.org
app.kubernetes.io/name: mysql
- operatorId: sample-fluxcd-helm-release
customResources:
- groupVersionKind:
group: "helm.fluxcd.io"
kind: "HelmRelease"
version: "v1"
objects:
- redis
operatorResourceSelector:
- matchLabels:
app: helm-operator
release: helm-operator
applicationResourceSelector:
- matchLabels:
app: redis
release: redis

Type: Operator - Example 3 - Helm based operator

Operator based applications can also be protected by providing the helm release name for the Operator resources.

Example 3a

apiVersion: triliovault.trilio.io/v1
kind: BackupPlan
metadata:
name: sample-application
spec:
backupNamespace: triliovault-integration
backupConfig:
target:
name: sample-target
backupPlanComponents:
operators:
- operatorId: sample-mysqlcluster
customResources:
- groupVersionKind:
group: "mysql.presslabs.org"
version: "v1alpha1"
kind: "MysqlCluster"
objects:
- sample-mysqlcluster
- groupVersionKind:
group: "mysql.presslabs.org"
version: "v1alpha1"
kind: "MysqlBackup"
helmRelease: sample-release
applicationResourceSelector:
- matchLabels:
app.kubernetes.io/managed-by: mysql.presslabs.org
app.kubernetes.io/name: mysql

Example 3b

apiVersion: triliovault.trilio.io/v1
kind: BackupPlan
metadata:
name: sample-application
spec:
backupNamespace: triliovault-integration
backupConfig:
target:
name: sample-target
backupPlanComponents:
operators:
- operatorId: sample-fluxcd-helm-release
customResources:
- groupVersionKind:
group: "helm.fluxcd.io"
kind: "HelmRelease"
version: "v1"
objects:
- redis
helmRelease: helm-operator
applicationResourceSelector:
- matchLabels:
app: redis
release: redis

Type: Operator - Example 4 - Helm based Operator without Operator Custom Resources

Operator Example where the Operator resources are defined via the helm release. No Operator custom resources are being backed up in this example.

Example 4a

apiVersion: triliovault.trilio.io/v1
kind: BackupPlan
metadata:
name: sample-application
spec:
backupNamespace: triliovault-integration
backupConfig:
target:
name: sample-target
backupPlanComponents:
operators:
- operatorId: sample-mysqlcluster
helmRelease: sample-release
applicationResourceSelector:
- matchLabels:
app.kubernetes.io/managed-by: mysql.presslabs.org
app.kubernetes.io/name: mysql

Example 4b

apiVersion: triliovault.trilio.io/v1
kind: BackupPlan
metadata:
name: sample-application
spec:
backupNamespace: triliovault-integration
backupConfig:
target:
name: sample-target
backupPlanComponents:
operators:
- operatorId: sample-fluxcd-helm-release
helmRelease: helm-operator
applicationResourceSelector:
- matchLabels:
app: redis
release: redis

Type: All - Example with all 3 Application Types -1

The BackupPlan CRD is an extremely flexible CRD within which multiple application components can be specified.

apiVersion: triliovault.trilio.io/v1
kind: BackupPlan
metadata:
name: sample-application
spec:
backupNamespace: triliovault-integration
backupConfig:
target:
name: sample-target
backupPlanComponents:
custom:
- matchLabels:
triliobackupall: all
helmReleases:
- sample-release
operators:
- operatorId: sample-mysqlcluster
customResources:
- groupVersionKind:
group: "mysql.presslabs.org"
version: "v1alpha1"
kind: "MysqlCluster"
objects:
- sample-mysqlcluster
- groupVersionKind:
group: "mysql.presslabs.org"
version: "v1alpha1"
kind: "MysqlBackup"
operatorResourceSelector:
- matchLabels:
app: mysql-operator
release: sample-release
applicationResourceSelector:
- matchLabels:
app.kubernetes.io/managed-by: mysql.presslabs.org
app.kubernetes.io/name: mysql

Type: Namespace - Example 1

For namespace level backup, BackupPlan components are optional

apiVersion: triliovault.trilio.io/v1
kind: BackupPlan
metadata:
name: ns-backupplan-1
spec:
backupNamespace: wordpress
backupConfig:
target:
name: demo-s3-target

Backup

The Backup CRD takes a backup of the resources specified in the BackupPlan spec. It takes either a Full backup or Incremental Backup. The first backup of the Application will always be a Full backup even if the user specifies their backup type as Incremental.

Incremental backup includes all the YAML files and delta changes to PV data. Incremental backups are not complete by themselves and relies on all the previous incremental backup and the full backup.

Example 1 - Full Backup

The following sample Backup YAML for Full backup

apiVersion: triliovault.trilio.io/v1
kind: Backup
metadata:
name: sample-backup
spec:
type: Full
backupPlan:
name: sample-application

Example 2 - Incremental Backup

Sample Backup YAML for incremental backup

apiVersion: triliovault.trilio.io/v1
kind: Backup
metadata:
name: sample-backup
spec:
type: Incremental
backupPlan:
name: sample-application

The scheduleType field is to specify if the backup should follow the backup schedule provided in the backupPlan or if it should be a one-time backup only.

Restore

The Restore CRD specifies the backup that resources need to be restored from. Resources can be restored to the same namespace or a different namespace. If a backup target with existing backups are created to a different cluster, those backups can be restored to the cluster. A migration or disaster recovery use case can be implemented using this functionality.

Example 1 - Restore from a specific backup

Sample YAML file to restore from a specific backup. The backup is identified by name sample-backup.

apiVersion: triliovault.trilio.io/v1
kind: Restore
metadata:
name: sample-restore
spec:
source:
type: Backup
backup:
name: sample-backup
restoreNamespace: triliovault-restorens

Example 2 - Restore last successful backup

Sample YAML that restores latest backup of a BackupPlan.

apiVersion: triliovault.trilio.io/v1
kind: Restore
metadata:
name: sample-restore
spec:
source:
type: BackupPlan
backupPlan:
name: sample-application
restoreNamespace: triliovault-restorens

Example 3 - Skip Restore

Trilio provides the capability to Skip the restoration of objects if they already exist in the namespace. This is achieved by using the skipIfAlreadyExists field within the Restore custom resource

apiVersion: triliovault.trilio.io/v1
kind: Restore
metadata:
name: sample-restore
spec:
source:
type: Backup
backup:
name: sample-backup
skipIfAlreadyExists: true
restoreNamespace: restore-namespace

Example 4 - Patch Restore

Trilio provides the capability to Patch resources if they already existing in the namespace during the restore

apiVersion: triliovault.trilio.io/v1
kind: Restore
metadata:
name: sample-restore
spec:
source:
type: Backup
backup:
name: sample-backup
patchIfAlreadyExists: true
restoreNamespace: restore-namespace

Example 5 -Restore From Specific Location - Migration Scenario

apiVersion: triliovault.trilio.io/v1
kind: Restore
metadata:
name: sample-restore
spec:
source:
type: Location
location: e90ce943-a0ce-11ea-93b2-42010a8e0038/66777359-a0d1-11ea-93b2-42010a8e0038
target:
name: sample-target
restoreNamespace: restore-namespace

Example 6 - Restore with Transformations (StorageClass)

apiVersion: triliovault.trilio.io/v1
kind: Restore
metadata:
name: sample-restore
spec:
source:
type: Backup
backup:
name: sample-backup
restoreNamespace: RESTORE_NAMESPACE
transformComponents:
helm:
- release: mysql
transformName: t1
set:
- key: persistence.storageClass
value: insert.storage.class.here
custom:
- transformName: t3
resources:
groupVersionKind:
group: ""
version: v1
kind: PersistentVolumeClaim
objects:
- insert-pvc1-to-be-replaced
- insert-pvc2-to-be-replaced
jsonPatches:
- op: replace
path: "/spec/storageClassName"
value: insert.updated.storage.class.here

Example 7 - Restore with Transformations (NodePort)

apiVersion: triliovault.trilio.io/v1
kind: Restore
metadata:
name: sample-restore
spec:
source:
type: Backup
backup:
name: sample-backup
transformComponents:
custom:
- transformName: t1
resources:
groupVersionKind:
group: ""
version: v1
kind: Service
objects:
- insert-svc-name-to-be-updated
jsonPatches:
- op: replace
path: "/spec/ports/0/nodePort"
value: 31366

Example 8 - Restore from BackupPlan

Restore from BackupPlan enables users to restore the last successful backup based on a BackupPlan by providing only the name of the BackupPlan.

apiVersion: triliovault.trilio.io/v1
kind: Restore
metadata:
name: sample-restore
spec:
source:
type: BackupPlan
backupPlan:
name: sample-backupplan-helm3
restoreNamespace: restore-ns