Este conteúdo não está disponível no idioma selecionado.
Chapter 4. Creating an environment-wide backup
Creating an environment-wide backup involves copying important data to assist with restoration in the case of crashing instances, or corrupt data. After backups have been created, they can be restored onto a newly installed version of the relevant component.
In OpenShift Container Platform, you can back up, saving state to separate storage, at the cluster level. The full state of an environment backup includes:
- Cluster data files
- etcd data on each master
- API objects
- Registry storage
- Volume storage
Perform a back up on a regular basis to prevent data loss.
The following process describes a generic way of backing up applications and the OpenShift Container Platform cluster. It cannot take into account custom requirements. Use these steps as a foundation for a full backup and restoration procedure for your cluster. You must take all necessary precautions to prevent data loss.
Backup and restore is not guaranteed. You are responsible for backing up your own data.
4.1. Creating a master host backup Copiar o linkLink copiado para a área de transferência!
Perform this backup process before any change to the OpenShift Container Platform infrastructure, such as a system update, upgrade, or any other significant modification. Back up data regularly to ensure that recent data is available if a failure occurs.
OpenShift Container Platform files
The master instances run important services, such as the API, controllers. The /etc/origin/master
directory stores many important files:
- The configuration, the API, controllers, services, and more
- Certificates generated by the installation
- All cloud provider-related configuration
-
Keys and other authentication files, such as
htpasswd
if you use htpasswd - And more
You can customize OpenShift Container Platform services, such as increasing the log level or using proxies. The configuration files are stored in the /etc/sysconfig
directory.
Because the masters are also nodes, back up the entire /etc/origin
directory.
Procedure
You must perform the following steps on each master node.
- Create a backup of the pod definitions, located here.
Create a backup of the master host configuration files:
MYBACKUPDIR=/backup/$(hostname)/$(date +%Y%m%d) sudo mkdir -p ${MYBACKUPDIR}/etc/sysconfig sudo cp -aR /etc/origin ${MYBACKUPDIR}/etc sudo cp -aR /etc/sysconfig/ ${MYBACKUPDIR}/etc/sysconfig/
$ MYBACKUPDIR=/backup/$(hostname)/$(date +%Y%m%d) $ sudo mkdir -p ${MYBACKUPDIR}/etc/sysconfig $ sudo cp -aR /etc/origin ${MYBACKUPDIR}/etc $ sudo cp -aR /etc/sysconfig/ ${MYBACKUPDIR}/etc/sysconfig/
Copy to Clipboard Copied! Toggle word wrap Toggle overflow NoteThe master configuration file is/etc/origin/master/master-config.yaml.
WarningThe
/etc/origin/master/ca.serial.txt
file is generated on only the first master listed in the Ansible host inventory. If you deprecate the first master host, copy the/etc/origin/master/ca.serial.txt
file to the rest of master hosts before the process.ImportantIn OpenShift Container Platform 3.11 clusters running multiple masters, one of the master nodes includes additional CA certificates in
/etc/origin/master
,/etc/etcd/ca
and/etc/etcd/generated_certs
. These are required for application node and etcd node scale-up operations and would need to be restored on another master node should the originating master become permanently unavailable. These directories are included by default within the backup procedures documented here.Other important files that need to be considered when planning a backup include:
Expand File
Description
/etc/cni/*
Container Network Interface configuration (if used)
/etc/sysconfig/iptables
Where the
iptables
rules are stored/etc/sysconfig/docker-storage-setup
The input file for
container-storage-setup
command/etc/sysconfig/docker
The
docker
configuration file/etc/sysconfig/docker-network
docker
networking configuration (i.e. MTU)/etc/sysconfig/docker-storage
docker
storage configuration (generated bycontainer-storage-setup
)/etc/dnsmasq.conf
Main configuration file for
dnsmasq
/etc/dnsmasq.d/*
Different
dnsmasq
configuration files/etc/sysconfig/flanneld
flannel
configuration file (if used)/etc/pki/ca-trust/source/anchors/
Certificates added to the system (i.e. for external registries)
Create a backup of those files:
Copy to Clipboard Copied! Toggle word wrap Toggle overflow If a package is accidentally removed or you need to resore a file that is included in an
rpm
package, having a list ofrhel
packages installed on the system can be useful.NoteIf you use Red Hat Satellite features, such as content views or the facts store, provide a proper mechanism to reinstall the missing packages and a historical data of packages installed in the systems.
To create a list of the current
rhel
packages installed in the system:MYBACKUPDIR=/backup/$(hostname)/$(date +%Y%m%d) sudo mkdir -p ${MYBACKUPDIR} rpm -qa | sort | sudo tee $MYBACKUPDIR/packages.txt
$ MYBACKUPDIR=/backup/$(hostname)/$(date +%Y%m%d) $ sudo mkdir -p ${MYBACKUPDIR} $ rpm -qa | sort | sudo tee $MYBACKUPDIR/packages.txt
Copy to Clipboard Copied! Toggle word wrap Toggle overflow If you used the previous steps, the following files are present in the backup directory:
Copy to Clipboard Copied! Toggle word wrap Toggle overflow If needed, you can compress the files to save space:
MYBACKUPDIR=/backup/$(hostname)/$(date +%Y%m%d) sudo tar -zcvf /backup/$(hostname)-$(date +%Y%m%d).tar.gz $MYBACKUPDIR sudo rm -Rf ${MYBACKUPDIR}
$ MYBACKUPDIR=/backup/$(hostname)/$(date +%Y%m%d) $ sudo tar -zcvf /backup/$(hostname)-$(date +%Y%m%d).tar.gz $MYBACKUPDIR $ sudo rm -Rf ${MYBACKUPDIR}
Copy to Clipboard Copied! Toggle word wrap Toggle overflow
To create any of these files from scratch, the openshift-ansible-contrib
repository contains the backup_master_node.sh
script, which performs the previous steps. The script creates a directory on the host where you run the script and copies all the files previously mentioned.
The openshift-ansible-contrib
script is not supported by Red Hat, but the reference architecture team performs testing to ensure the code operates as defined and is secure.
You can run the script on every master host with:
mkdir ~/git cd ~/git git clone https://github.com/openshift/openshift-ansible-contrib.git cd openshift-ansible-contrib/reference-architecture/day2ops/scripts ./backup_master_node.sh -h
$ mkdir ~/git
$ cd ~/git
$ git clone https://github.com/openshift/openshift-ansible-contrib.git
$ cd openshift-ansible-contrib/reference-architecture/day2ops/scripts
$ ./backup_master_node.sh -h
4.2. Creating a node host backup Copiar o linkLink copiado para a área de transferência!
Creating a backup of a node host is a different use case from backing up a master host. Because master hosts contain many important files, creating a backup is highly recommended. However, the nature of nodes is that anything special is replicated over the nodes in case of failover, and they typically do not contain data that is necessary to run an environment. If a backup of a node contains something necessary to run an environment, then a creating a backup is recommended.
The backup process is to be performed before any change to the infrastructure, such as a system update, upgrade, or any other significant modification. Backups should be performed on a regular basis to ensure the most recent data is available if a failure occurs.
OpenShift Container Platform files
Node instances run applications in the form of pods, which are based on containers. The /etc/origin/
and /etc/origin/node
directories house important files, such as:
- The configuration of the node services
- Certificates generated by the installation
- Cloud provider-related configuration
-
Keys and other authentication files, such as the
dnsmasq
configuration
The OpenShift Container Platform services can be customized to increase the log level, use proxies, and more, and the configuration files are stored in the /etc/sysconfig
directory.
Procedure
Create a backup of the node configuration files:
MYBACKUPDIR=/backup/$(hostname)/$(date +%Y%m%d) sudo mkdir -p ${MYBACKUPDIR}/etc/sysconfig sudo cp -aR /etc/origin ${MYBACKUPDIR}/etc sudo cp -aR /etc/sysconfig/atomic-openshift-node ${MYBACKUPDIR}/etc/sysconfig/
$ MYBACKUPDIR=/backup/$(hostname)/$(date +%Y%m%d) $ sudo mkdir -p ${MYBACKUPDIR}/etc/sysconfig $ sudo cp -aR /etc/origin ${MYBACKUPDIR}/etc $ sudo cp -aR /etc/sysconfig/atomic-openshift-node ${MYBACKUPDIR}/etc/sysconfig/
Copy to Clipboard Copied! Toggle word wrap Toggle overflow OpenShift Container Platform uses specific files that must be taken into account when planning the backup policy, including:
Expand File
Description
/etc/cni/*
Container Network Interface configuration (if used)
/etc/sysconfig/iptables
Where the
iptables
rules are stored/etc/sysconfig/docker-storage-setup
The input file for
container-storage-setup
command/etc/sysconfig/docker
The
docker
configuration file/etc/sysconfig/docker-network
docker
networking configuration (i.e. MTU)/etc/sysconfig/docker-storage
docker
storage configuration (generated bycontainer-storage-setup
)/etc/dnsmasq.conf
Main configuration file for
dnsmasq
/etc/dnsmasq.d/*
Different
dnsmasq
configuration files/etc/sysconfig/flanneld
flannel
configuration file (if used)/etc/pki/ca-trust/source/anchors/
Certificates added to the system (i.e. for external registries)
To create those files:
Copy to Clipboard Copied! Toggle word wrap Toggle overflow If a package is accidentally removed, or a file included in an
rpm
package should be restored, having a list ofrhel
packages installed on the system can be useful.NoteIf using Red Hat Satellite features, such as content views or the facts store, provide a proper mechanism to reinstall the missing packages and a historical data of packages installed in the systems.
To create a list of the current
rhel
packages installed in the system:MYBACKUPDIR=/backup/$(hostname)/$(date +%Y%m%d) sudo mkdir -p ${MYBACKUPDIR} rpm -qa | sort | sudo tee $MYBACKUPDIR/packages.txt
$ MYBACKUPDIR=/backup/$(hostname)/$(date +%Y%m%d) $ sudo mkdir -p ${MYBACKUPDIR} $ rpm -qa | sort | sudo tee $MYBACKUPDIR/packages.txt
Copy to Clipboard Copied! Toggle word wrap Toggle overflow The following files should now be present in the backup directory:
Copy to Clipboard Copied! Toggle word wrap Toggle overflow If needed, the files can be compressed to save space:
MYBACKUPDIR=/backup/$(hostname)/$(date +%Y%m%d) sudo tar -zcvf /backup/$(hostname)-$(date +%Y%m%d).tar.gz $MYBACKUPDIR sudo rm -Rf ${MYBACKUPDIR}
$ MYBACKUPDIR=/backup/$(hostname)/$(date +%Y%m%d) $ sudo tar -zcvf /backup/$(hostname)-$(date +%Y%m%d).tar.gz $MYBACKUPDIR $ sudo rm -Rf ${MYBACKUPDIR}
Copy to Clipboard Copied! Toggle word wrap Toggle overflow
To create any of these files from scratch, the openshift-ansible-contrib
repository contains the backup_master_node.sh
script, which performs the previous steps. The script creates a directory on the host running the script and copies all the files previously mentioned.
The openshift-ansible-contrib
script is not supported by Red Hat, but the reference architecture team performs testing to ensure the code operates as defined and is secure.
The script can be executed on every master host with:
mkdir ~/git cd ~/git git clone https://github.com/openshift/openshift-ansible-contrib.git cd openshift-ansible-contrib/reference-architecture/day2ops/scripts ./backup_master_node.sh -h
$ mkdir ~/git
$ cd ~/git
$ git clone https://github.com/openshift/openshift-ansible-contrib.git
$ cd openshift-ansible-contrib/reference-architecture/day2ops/scripts
$ ./backup_master_node.sh -h
4.3. Backing up registry certificates Copiar o linkLink copiado para a área de transferência!
If you use an external secured registry, you must save all the registry certificates. The registry is secured by default.
You must perform the following steps on each cluster node.
Procedure
Back up the registry certificates:
cd /etc/docker/certs.d/ tar cf /tmp/docker-registry-certs-$(hostname).tar *
# cd /etc/docker/certs.d/ # tar cf /tmp/docker-registry-certs-$(hostname).tar *
Copy to Clipboard Copied! Toggle word wrap Toggle overflow - Move the backup to an external location.
When working with one or more external secured registry, any host that pulls or pushes images must trust the registry certificates to run pods.
4.4. Backing up other installation files Copiar o linkLink copiado para a área de transferência!
Back up the files that you used to install OpenShift Container Platform.
Procedure
Because the restoration procedure involves a complete reinstallation, save all the files used in the initial installation. These files might include:
- Ansible playbooks and inventory files from the cluster installation
- /etc/yum.repos.d/ose.repo from the disconnected installation method
- Backup the procedures for post-installation steps. Some installations might involve steps that are not included in the installer. These steps might include changes to the services outside of the control of OpenShift Container Platform or the installation of extra services like monitoring agents. Additional configuration that is not yet supported by the advanced installer might also be affected, such as using multiple authentication providers.
4.5. Backing up application data Copiar o linkLink copiado para a área de transferência!
In many cases, you can back up application data by using the oc rsync
command, assuming rsync
is installed within the container image. The Red Hat rhel7 base image contains rsync
. Therefore, all images that are based on rhel7 contain it as well. See Troubleshooting and Debugging CLI Operations - rsync.
This is a generic backup of application data and does not take into account application-specific backup procedures, for example, special export and import procedures for database systems.
Other means of backup might exist depending on the type of the persistent volume you use, for example, Cinder, NFS, or Gluster.
The paths to back up are also application specific. You can determine what path to back up by looking at the mountPath
for volumes in the deploymentconfig
.
You can perform this type of application data backup only while the application pod is running.
Procedure
Example of backing up a Jenkins deployment’s application data
Get the application data
mountPath
from thedeploymentconfig
:oc get dc/jenkins -o jsonpath='{ .spec.template.spec.containers[?(@.name=="jenkins")].volumeMounts[?(@.name=="jenkins-data")].mountPath }'
$ oc get dc/jenkins -o jsonpath='{ .spec.template.spec.containers[?(@.name=="jenkins")].volumeMounts[?(@.name=="jenkins-data")].mountPath }' /var/lib/jenkins
Copy to Clipboard Copied! Toggle word wrap Toggle overflow Get the name of the pod that is currently running:
oc get pod --selector=deploymentconfig=jenkins -o jsonpath='{ .metadata.name }'
$ oc get pod --selector=deploymentconfig=jenkins -o jsonpath='{ .metadata.name }' jenkins-1-37nux
Copy to Clipboard Copied! Toggle word wrap Toggle overflow Use the
oc rsync
command to copy application data:oc rsync jenkins-1-37nux:/var/lib/jenkins /tmp/jenkins-backup/
$ oc rsync jenkins-1-37nux:/var/lib/jenkins /tmp/jenkins-backup/
Copy to Clipboard Copied! Toggle word wrap Toggle overflow
4.6. etcd backup Copiar o linkLink copiado para a área de transferência!
etcd is the key value store for all object definitions, as well as the persistent master state. Other components watch for changes, then bring themselves into the desired state.
OpenShift Container Platform versions prior to 3.5 use etcd version 2 (v2), while 3.5 and later use version 3 (v3). The data model between the two versions of etcd is different. etcd v3 can use both the v2 and v3 data models, whereas etcd v2 can only use the v2 data model. In an etcd v3 server, the v2 and v3 data stores exist in parallel and are independent.
For both v2 and v3 operations, you can use the ETCDCTL_API
environment variable to use the correct API:
See Migrating etcd Data (v2 to v3) section in the OpenShift Container Platform 3.7 documentation for information about how to migrate to v3.
In OpenShift Container Platform version 3.10 and later, you can either install etcd on separate hosts or run it as a static pod on your master hosts. If you do not specify separate etcd hosts, etcd runs as a static pod on master hosts. Because of this difference, the backup process is different if you use static pods.
The etcd backup process is composed of two different procedures:
- Configuration backup: Including the required etcd configuration and certificates
- Data backup: Including both v2 and v3 data model.
You can perform the data backup process on any host that has connectivity to the etcd cluster, where the proper certificates are provided, and where the etcdctl
tool is installed.
The backup files must be copied to an external system, ideally outside the OpenShift Container Platform environment, and then encrypted.
Note that the etcd backup still has all the references to current storage volumes. When you restore etcd, OpenShift Container Platform starts launching the previous pods on nodes and reattaching the same storage. This process is no different than the process of when you remove a node from the cluster and add a new one back in its place. Anything attached to that node is reattached to the pods on whatever nodes they are rescheduled to.
4.6.1. Backing up etcd Copiar o linkLink copiado para a área de transferência!
When you back up etcd, you must back up both the etcd configuration files and the etcd data.
4.6.1.1. Backing up etcd configuration files Copiar o linkLink copiado para a área de transferência!
The etcd configuration files to be preserved are all stored in the /etc/etcd
directory of the instances where etcd is running. This includes the etcd configuration file (/etc/etcd/etcd.conf
) and the required certificates for cluster communication. All those files are generated at installation time by the Ansible installer.
Procedure
For each etcd member of the cluster, back up the etcd configuration.
ssh master-0 mkdir -p /backup/etcd-config-$(date +%Y%m%d)/ cp -R /etc/etcd/ /backup/etcd-config-$(date +%Y%m%d)/
$ ssh master-0
# mkdir -p /backup/etcd-config-$(date +%Y%m%d)/
# cp -R /etc/etcd/ /backup/etcd-config-$(date +%Y%m%d)/
- 1
- Replace
master-0
with the name of your etcd member.
The certificates and configuration files on each etcd cluster member are unique.
4.6.1.2. Backing up etcd data Copiar o linkLink copiado para a área de transferência!
Prerequisites
The OpenShift Container Platform installer creates aliases to avoid typing all the flags named etcdctl2
for etcd v2 tasks and etcdctl3
for etcd v3 tasks.
However, the etcdctl3
alias does not provide the full endpoint list to the etcdctl
command, so you must specify the --endpoints
option and list all the endpoints.
Before backing up etcd:
-
etcdctl
binaries must be available or, in containerized installations, therhel7/etcd
container must be available. - Ensure that the OpenShift Container Platform API service is running.
- Ensure connectivity with the etcd cluster (port 2379/tcp).
- Ensure the proper certificates to connect to the etcd cluster.
Ensure that the etcd cluster is working by checking its health:
Check the health of the endpoints:
etcdctl3 --cert="/etc/etcd/peer.crt" \ --key=/etc/etcd/peer.key \ --cacert="/etc/etcd/ca.crt" \ --endpoints="https://master-0.example.com:2379,https://master-1.example.com:2379,https://master-2.example.com:2379" \ endpoint health
# etcdctl3 --cert="/etc/etcd/peer.crt" \ --key=/etc/etcd/peer.key \ --cacert="/etc/etcd/ca.crt" \ --endpoints="https://master-0.example.com:2379,https://master-1.example.com:2379,https://master-2.example.com:2379" \
1 endpoint health
Copy to Clipboard Copied! Toggle word wrap Toggle overflow - 1
- Replace these values with your cluster’s endpoints.
Example Output
https://master-0.example.com:2379 is healthy: successfully committed proposal: took = 5.011358ms https://master-1.example.com:2379 is healthy: successfully committed proposal: took = 1.305173ms https://master-2.example.com:2379 is healthy: successfully committed proposal: took = 1.388772ms
https://master-0.example.com:2379 is healthy: successfully committed proposal: took = 5.011358ms https://master-1.example.com:2379 is healthy: successfully committed proposal: took = 1.305173ms https://master-2.example.com:2379 is healthy: successfully committed proposal: took = 1.388772ms
Copy to Clipboard Copied! Toggle word wrap Toggle overflow Check the member list.
etcdctl3 member list
# etcdctl3 member list
Copy to Clipboard Copied! Toggle word wrap Toggle overflow Example Output
2a371dd20f21ca8d, started, master-1.example.com, https://192.168.55.12:2380, https://192.168.55.12:2379 40bef1f6c79b3163, started, master-0.example.com, https://192.168.55.8:2380, https://192.168.55.8:2379 95dc17ffcce8ee29, started, master-2.example.com, https://192.168.55.13:2380, https://192.168.55.13:2379
2a371dd20f21ca8d, started, master-1.example.com, https://192.168.55.12:2380, https://192.168.55.12:2379 40bef1f6c79b3163, started, master-0.example.com, https://192.168.55.8:2380, https://192.168.55.8:2379 95dc17ffcce8ee29, started, master-2.example.com, https://192.168.55.13:2380, https://192.168.55.13:2379
Copy to Clipboard Copied! Toggle word wrap Toggle overflow
Procedure
While the etcdctl backup
command is used to perform the backup, etcd v3 has no concept of a backup. Instead, you either take a snapshot from a live member with the etcdctl snapshot save
command or copy the member/snap/db
file from an etcd data directory.
The etcdctl backup
command rewrites some of the metadata contained in the backup, specifically, the node ID and cluster ID, which means that in the backup, the node loses its former identity. To recreate a cluster from the backup, you create a new, single-node cluster, then add the rest of the nodes to the cluster. The metadata is rewritten to prevent the new node from joining an existing cluster.
Back up the etcd data:
Clusters upgraded from previous versions of OpenShift Container Platform might contain v2 data stores. Back up all etcd data stores.
Obtain the etcd endpoint IP address from the static pod manifest:
export ETCD_POD_MANIFEST="/etc/origin/node/pods/etcd.yaml"
$ export ETCD_POD_MANIFEST="/etc/origin/node/pods/etcd.yaml"
Copy to Clipboard Copied! Toggle word wrap Toggle overflow export ETCD_EP=$(grep https ${ETCD_POD_MANIFEST} | cut -d '/' -f3)
$ export ETCD_EP=$(grep https ${ETCD_POD_MANIFEST} | cut -d '/' -f3)
Copy to Clipboard Copied! Toggle word wrap Toggle overflow Log in as an administrator:
oc login -u system:admin
$ oc login -u system:admin
Copy to Clipboard Copied! Toggle word wrap Toggle overflow Obtain the etcd pod name:
export ETCD_POD=$(oc get pods -n kube-system | grep -o -m 1 '^master-etcd\S*')
$ export ETCD_POD=$(oc get pods -n kube-system | grep -o -m 1 '^master-etcd\S*')
Copy to Clipboard Copied! Toggle word wrap Toggle overflow Change to the
kube-system
project:oc project kube-system
$ oc project kube-system
Copy to Clipboard Copied! Toggle word wrap Toggle overflow Take a snapshot of the etcd data in the pod and store it locally:
Copy to Clipboard Copied! Toggle word wrap Toggle overflow - 1
- You must write the snapshot to a directory under
/var/lib/etcd/
.
4.7. Backing up a project Copiar o linkLink copiado para a área de transferência!
Creating a backup of all relevant data involves exporting all important information, then restoring into a new project.
Because the oc get all
command returns only certain project resources, you must separately back up other resources, including PVCs and Secrets, as shown in the following steps.
Procedure
List the project data to back up:
oc get all
$ oc get all
Copy to Clipboard Copied! Toggle word wrap Toggle overflow Example Output
Copy to Clipboard Copied! Toggle word wrap Toggle overflow Export the project objects to a
project.yaml
file.oc get -o yaml --export all > project.yaml
$ oc get -o yaml --export all > project.yaml
Copy to Clipboard Copied! Toggle word wrap Toggle overflow Export other objects in your project, such as role bindings, secrets, service accounts, and persistent volume claims.
You can export all namespaced objects in your project using the following command:
for object in $(oc api-resources --namespaced=true -o name) do oc get -o yaml --export $object > $object.yaml done
$ for object in $(oc api-resources --namespaced=true -o name) do oc get -o yaml --export $object > $object.yaml done
Copy to Clipboard Copied! Toggle word wrap Toggle overflow Note that some resources cannot be exported, and a
MethodNotAllowed
error is displayed.Some exported objects can rely on specific metadata or references to unique IDs in the project. This is a limitation on the usability of the recreated objects.
When using
imagestreams
, theimage
parameter of adeploymentconfig
can point to a specificsha
checksum of an image in the internal registry that would not exist in a restored environment. For instance, running the sample "ruby-ex" asoc new-app centos/ruby-22-centos7~https://github.com/sclorg/ruby-ex.git
creates animagestream
ruby-ex
using the internal registry to host the image:oc get dc ruby-ex -o jsonpath="{.spec.template.spec.containers[].image}"
$ oc get dc ruby-ex -o jsonpath="{.spec.template.spec.containers[].image}" 10.111.255.221:5000/myproject/ruby-ex@sha256:880c720b23c8d15a53b01db52f7abdcbb2280e03f686a5c8edfef1a2a7b21cee
Copy to Clipboard Copied! Toggle word wrap Toggle overflow If importing the
deploymentconfig
as it is exported withoc get --export
it fails if the image does not exist.
4.8. Backing up persistent volume claims Copiar o linkLink copiado para a área de transferência!
You can synchronize persistent data from inside of a container to a server.
Depending on the provider that is hosting the OpenShift Container Platform environment, the ability to launch third party snapshot services for backup and restore purposes also exists. As OpenShift Container Platform does not have the ability to launch these services, this guide does not describe these steps.
Consult any product documentation for the correct backup procedures of specific applications. For example, copying the mysql data directory itself does not create a usable backup. Instead, run the specific backup procedures of the associated application and then synchronize any data. This includes using snapshot solutions provided by the OpenShift Container Platform hosting platform.
Procedure
View the project and pods:
oc get pods
$ oc get pods NAME READY STATUS RESTARTS AGE demo-1-build 0/1 Completed 0 2h demo-2-fxx6d 1/1 Running 0 1h
Copy to Clipboard Copied! Toggle word wrap Toggle overflow Describe the desired pod to find the volumes that are currently used by a persistent volume:
Copy to Clipboard Copied! Toggle word wrap Toggle overflow This output shows that the persistent data is in the
/opt/app-root/src/uploaded
directory.Copy the data locally:
Copy to Clipboard Copied! Toggle word wrap Toggle overflow The
ocp_sop.txt
file is downloaded to the local system to be backed up by backup software or another backup mechanism.NoteYou can also use the previous steps if a pod starts without needing to use a
pvc
, but you later decide that apvc
is necessary. You can preserve the data and then use the restorate process to populate the new storage.