Restore to Kubernetes Cluster Examples

CommunityEnterprise

To restore Kubernetes objects to a Kubernetes cluster, the administrator should execute the restore command and specify the where parameter as in this example:

* restore where=/

and then set any other required restore plugin parameters for the restore.

*restore jobid=1 where=/
Automatically selected Catalog: MyCatalog
Using Catalog "MyCatalog"
You have selected the following JobId: 1

Building directory tree for JobId(s) 1 ...  +++++++++++++++++++++++++++++++++++++++++++++++++
443 files inserted into the tree.

You are now entering file selection mode where you add (mark) and
remove (unmark) files to be restored. No files are initially added, unless
you used the "all" keyword on the command line.
Enter "done" to leave this mode.

cwd is: /
$ cd @kubernetes/namespaces/testing-ns-0010-1/configmaps
cwd is: /@kubernetes/namespaces/testing-ns-0010-1/configmaps/
$ ls
kube-root-ca.crt.yaml
test-n1-configmap-0010-1.yaml
$ mark *
2 files marked.
$ done
Bootstrap records written to /opt/bacula/working/bacula-devel-dir.restore.46.bsr
The Job will require the following (*=>InChanger):
Volume(s)                 Storage(s)                SD Device(s)
===========================================================================

    Vol-0001                  File1                     FileStorage1

Volumes marked with "*" are in the Autochanger.


2 files selected to be restored.

Automatically selected Client: bacula-devel-fd
Using Catalog "MyCatalog"
Run Restore job
JobName:         RestoreFiles
Bootstrap:       /home/fmgb/bee/projects/bacula-bee/regress/working/bacula-devel-dir.restore.46.bsr
Where:           /
Replace:         Always
FileSet:         Full Set
Backup Client:   bacula-devel-fd
Restore Client:  bacula-devel-fd
Storage:         File1
When:            2024-11-29 13:34:48
Catalog:         MyCatalog
Priority:        10
Plugin Options:  *None*
OK to run? (Yes/mod/no): mod
Parameters to modify:
    1: Level
    2: Storage
    3: Job
    4: FileSet
    5: Restore Client
    6: When
    7: Priority
    8: Bootstrap
    9: Where
    10: File Relocation
    11: Replace
    12: JobId
    13: Plugin Options
Select parameter to modify (1-13): 13
Automatically selected : kubernetes: debug=1 config='/opt/bacula/etc/k8s/config'  fdkeyfile=/opt/bacula/etc/k8s/snakeoil.key fdcertfile=/opt/bacula/etc/k8s/snakeoil.pem namespace=testing-ns-0010-1
Plugin Restore Options
Option                         Current Value        Default Value
config:                        *None*               (*None*)
host:                          *None*               (*None*)
token:                         *None*               (*None*)
verify_ssl:                    *None*               (True)
ssl_ca_cert:                   *None*               (*None*)
outputformat:                  *None*               (RAW)
fdaddress:                     *None*               (*FDAddress*)
fdport:                        *None*               (9104)
pluginhost:                    *None*               (*FDAddress*)
pluginport:                    *None*               (9104)
new_namespace:                 *None*               (*None*)
new_name:                      *None*               (*None*)
new_storageclass:              *None*               (*None*)
Use above plugin configuration? (Yes/mod/no): mod
You have the following choices:
    1: config (K8S config file)
    2: host (K8S API server URL/Host)
    3: token (K8S Bearertoken)
    4: verify_ssl (K8S API server cert verification)
    5: ssl_ca_cert (Custom CA Certs file to use)
    6: outputformat (Output format when saving to file (JSON, YAML))
    7: fdaddress (The address for listen to incoming backup pod data)
    8: fdport (The port for opening socket for listen)
    9: pluginhost (The endpoint address for backup pod to connect)
    10: pluginport (The endpoint port to connect)
    11: new_namespace (The namespace where the resources will be restored)
    12: new_name (The new name of restored resource)
    13: new_storageclass (The storageclass that will be applied in pvc restores)
Select parameter to modify (1-13): 1
Please enter a value for config: /root/.kube/config
Plugin Restore Options
Option                         Current Value        Default Value
config:                        /root/.kube/config   (*None*)
host:                          *None*               (*None*)
token:                         *None*               (*None*)
verify_ssl:                    *None*               (True)
ssl_ca_cert:                   *None*               (*None*)
outputformat:                  *None*               (RAW)
fdaddress:                     *None*               (*FDAddress*)
fdport:                        *None*               (9104)
pluginhost:                    *None*               (*FDAddress*)
pluginport:                    *None*               (9104)
new_namespace:                 *None*               (*None*)
new_name:                      *None*               (*None*)
new_storageclass:              *None*               (*None*)
Use above plugin configuration? (Yes/mod/no): yes
Run Restore job
JobName:         RestoreFiles
Bootstrap:       /home/fmgb/bee/projects/bacula-bee/regress/working/bacula-devel-dir.restore.46.bsr
Where:           /
Replace:         Always
FileSet:         Full Set
Backup Client:   bacula-devel-fd
Restore Client:  bacula-devel-fd
Storage:         File1
When:            2024-11-29 13:34:48
Catalog:         MyCatalog
Priority:        10
Plugin Options:  User specified
OK to run? (Yes/mod/no):
Job queued. JobId=1084

The plugin does not pause for Kubernetes objects to be ready and online like kubectl or the oc commands do.

Restore to Kubernetes Cluster Overwriting Values

To restore Kubernetes objects to a Kubernetes cluster overriding values such as namespace, name or even StorageClass (the Persistent Volume Claim only), the administrator should execute the restore command and modify the values in Plugin Options menu, as in this example:

* restore jobid=1 where=/
...
Select parameter to modify (1-13): 13
Automatically selected : kubernetes: debug=1 config='/opt/bacula/etc/k8s/config'
fdkeyfile=/opt/bacula/etc/k8s/snakeoil.key fdcertfile=/opt/bacula/etc/k8s/snakeoil.pem
namespace=testing-ns-0010-1
Plugin Restore Options
Option                         Current Value        Default Value
config:                        *None*               (*None*)
host:                          *None*               (*None*)
token:                         *None*               (*None*)
verify_ssl:                    *None*               (True)
ssl_ca_cert:                   *None*               (*None*)
outputformat:                  *None*               (RAW)
fdaddress:                     *None*               (*FDAddress*)
fdport:                        *None*               (9104)
pluginhost:                    *None*               (*FDAddress*)
pluginport:                    *None*               (9104)
new_namespace:                 *None*               (*None*)
new_name:                      *None*               (*None*)
new_storageclass:              *None*               (*None*)
debug:                         *None*               (*None*)
Use above plugin configuration? (Yes/mod/no):
...

Frequently Asked Questions

What happens if you try to perform a restore of a Kubernetes resource in another namespace that does not exist?

The plugin check if the target namespace exists or not. If it does not exist, the plugin creates a new one.

What happens if you try to restore several Kubernetes resource with a different name?

The plugin will restore the resources with the same name. If they are the same type, the restore fails.

What happens if you try to restore a :term:`Persistent Volume Claim` to a different StorageClass that does not exist?

The restore fails.

What happens if you try to restore a :term:`Persistent Volume Claim` to a different StorageClass with a different filesystem?

This is supported. The data of Persistent Volume Claim is restored normally.

Go back to: Restore Examples.