This documentation is for a release that is no longer maintained
See documentation for the latest supported version 3 or the latest supported version 4.Questo contenuto non è disponibile nella lingua selezionata.
Chapter 18. Backup and Restore
18.1. Overview Copia collegamentoCollegamento copiato negli appunti!
In OpenShift Enterprise, you can back up (saving state to separate storage) and restore (recreating state from separate storage) at the cluster level. There is also some preliminary support for per-project backup. The full state of a cluster installation includes:
- etcd data on each master
- API objects
- registry storage
- volume storage
This topic does not cover how to back up and restore persistent storage, as those topics are left to the underlying storage provider.
18.2. Prerequisites Copia collegamentoCollegamento copiato negli appunti!
Because the restore procedure involves a complete reinstallation, save all the files used in the initial installation. This may include:
- ~/.config/openshift/installer.cfg.yml (from the Quick Installation method)
- Ansible playbooks and inventory files (from the Advanced Installation method)
- /etc/yum.repos.d/ose.repo (from the Disconnected Installation method)
Install packages that provide various utility commands:
yum install etcd
# yum install etcd
Copy to Clipboard Copied! Toggle word wrap Toggle overflow
Note the location of the etcd data directory (or $ETCD_DATA_DIR
in the following sections), which depends on how etcd is deployed.
Deployment Type | Description | Data Directory |
---|---|---|
separate etcd | etcd runs as a separate service, either co-located on master nodes or on separate nodes. | /var/lib/etcd |
embedded etcd | etcd runs as part of the master service. | /var/lib/origin/openshift.local.etcd |
18.3. Cluster Backup Copia collegamentoCollegamento copiato negli appunti!
Save all the certificates and keys, on each master:
Copy to Clipboard Copied! Toggle word wrap Toggle overflow If etcd is running on more than one host, stop it on each host:
sudo systemctl stop etcd
# sudo systemctl stop etcd
Copy to Clipboard Copied! Toggle word wrap Toggle overflow Although this step is not strictly necessary, doing so ensures that the etcd data is fully synchronized.
Create an etcd backup:
etcdctl backup \ --data-dir $ETCD_DATA_DIR \ --backup-dir $ETCD_DATA_DIR.bak
# etcdctl backup \ --data-dir $ETCD_DATA_DIR \ --backup-dir $ETCD_DATA_DIR.bak
Copy to Clipboard Copied! Toggle word wrap Toggle overflow NoteIf etcd is running on more than one host, the various instances regularly synchronize their data, so creating a backup for one of them is sufficient.
Create a template for all cluster API objects:
oc export all \ --exact \ --all-namespaces \ --as-template=mycluster \ > mycluster.template.yaml
$ oc export all \ --exact \
1 --all-namespaces \ --as-template=mycluster \
2 > mycluster.template.yaml
Copy to Clipboard Copied! Toggle word wrap Toggle overflow The object types included in
oc export all
are:- BuildConfig
- Build
- DeploymentConfig
- ImageStream
- Pod
- ReplicationController
- Route
- Service
18.4. Cluster Restore Copia collegamentoCollegamento copiato negli appunti!
Reinstall OpenShift Enterprise.
This should be done in the same way that OpenShift Enterprise was previously installed.
Restore the certificates and keys, on each master:
cd /etc/origin/master tar xvf /tmp/certs-and-keys-$(hostname).tar
# cd /etc/origin/master # tar xvf /tmp/certs-and-keys-$(hostname).tar
Copy to Clipboard Copied! Toggle word wrap Toggle overflow Restore from the etcd backup:
mv $ETCD_DATA_DIR $ETCD_DATA_DIR.orig cp -Rp $ETCD_DATA_DIR.bak $ETCD_DATA_DIR chcon -R --reference $ETCD_DATA_DIR.orig $ETCD_DATA_DIR chown -R etcd:etcd $ETCD_DATA_DIR
# mv $ETCD_DATA_DIR $ETCD_DATA_DIR.orig # cp -Rp $ETCD_DATA_DIR.bak $ETCD_DATA_DIR # chcon -R --reference $ETCD_DATA_DIR.orig $ETCD_DATA_DIR # chown -R etcd:etcd $ETCD_DATA_DIR
Copy to Clipboard Copied! Toggle word wrap Toggle overflow Create the API objects for the cluster:
oc create -f mycluster.template.yaml
$ oc create -f mycluster.template.yaml
Copy to Clipboard Copied! Toggle word wrap Toggle overflow
18.5. Project Backup Copia collegamentoCollegamento copiato negli appunti!
A future release of OpenShift Enterprise will feature specific support for per-project back up and restore.
For now, to back up API objects at the project level, use oc export
for each object to be saved. For example, to save the deployment configuration frontend
in YAML format:
oc export dc frontend -o yaml > dc-frontend.yaml
$ oc export dc frontend -o yaml > dc-frontend.yaml
To back up all of the project (with the exception of cluster objects like namespaces and projects):
oc export all -o yaml > project.yaml
$ oc export all -o yaml > project.yaml