Skip to content

Commit 9db5936

Browse files
authored
Merge pull request #51834 from sbeskin-redhat/OADP_693_Document_restore_of_deploymentconfigs_using_restic_and_workaround_with_script
OADP 693: Document restore of deploymentconfigs using restic and worka…
2 parents aa3f21e + 3a0f8e4 commit 9db5936

File tree

2 files changed

+68
-58
lines changed

2 files changed

+68
-58
lines changed

modules/oadp-creating-restore-cr.adoc

Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,3 +55,71 @@ $ oc get restore -n openshift-adp <restore> -o jsonpath='{.status.phase}'
5555
$ oc get all -n <namespace> <1>
5656
----
5757
<1> Namespace that you backed up.
58+
59+
. If you use Restic to restore `DeploymentConfig` objects or if you use post-restore hooks, run the `dc-restic-post-restore.sh` cleanup script by entering the following command:
60+
+
61+
[source,terminal]
62+
----
63+
$ bash dc-restic-post-restore.sh <restore-name>
64+
----
65+
+
66+
[NOTE]
67+
====
68+
In the course of the restore process, the OADP Velero plug-ins scale down the `DeploymentConfig` objects and restore the pods as standalone pods to prevent the cluster from deleting the restored `DeploymentConfig` pods immediately on restore and to allow Restic and post-restore hooks to complete their actions on the restored pods. The cleanup script removes these disconnected pods and scale any `DeploymentConfig` objects back up to the appropriate number of replicas.
69+
====
70+
+
71+
.`dc-restic-post-restore.sh` cleanup script
72+
[%collapsible]
73+
====
74+
[source,bash]
75+
----
76+
#!/bin/bash
77+
set -e
78+
79+
# if sha256sum exists, use it to check the integrity of the file
80+
if command -v sha256sum >/dev/null 2>&1; then
81+
CHECKSUM_CMD="sha256sum"
82+
else
83+
CHECKSUM_CMD="shasum -a 256"
84+
fi
85+
86+
label_name () {
87+
if [ "${#1}" -le "63" ]; then
88+
echo $1
89+
return
90+
fi
91+
sha=$(echo -n $1|$CHECKSUM_CMD)
92+
echo "${1:0:57}${sha:0:6}"
93+
}
94+
95+
OADP_NAMESPACE=${OADP_NAMESPACE:=openshift-adp}
96+
97+
if [[ $# -ne 1 ]]; then
98+
echo "usage: ${BASH_SOURCE} restore-name"
99+
exit 1
100+
fi
101+
102+
echo using OADP Namespace $OADP_NAMESPACE
103+
echo restore: $1
104+
105+
label=$(label_name $1)
106+
echo label: $label
107+
108+
echo Deleting disconnected restore pods
109+
oc delete pods -l oadp.openshift.io/disconnected-from-dc=$label
110+
111+
for dc in $(oc get dc --all-namespaces -l oadp.openshift.io/replicas-modified=$label -o jsonpath='{range .items[*]}{.metadata.namespace}{","}{.metadata.name}{","}{.metadata.annotations.oadp\.openshift\.io/original-replicas}{","}{.metadata.annotations.oadp\.openshift\.io/original-paused}{"\n"}')
112+
do
113+
IFS=',' read -ra dc_arr <<< "$dc"
114+
if [ ${#dc_arr[0]} -gt 0 ]; then
115+
echo Found deployment ${dc_arr[0]}/${dc_arr[1]}, setting replicas: ${dc_arr[2]}, paused: ${dc_arr[3]}
116+
cat <<EOF | oc patch dc -n ${dc_arr[0]} ${dc_arr[1]} --patch-file /dev/stdin
117+
spec:
118+
replicas: ${dc_arr[2]}
119+
paused: ${dc_arr[3]}
120+
EOF
121+
fi
122+
done
123+
----
124+
125+
====

modules/oadp-restic-issues.adoc

Lines changed: 0 additions & 58 deletions
Original file line numberDiff line numberDiff line change
@@ -38,64 +38,6 @@ spec:
3838

3939
. Wait for the `Restic` pods to restart so that the changes are applied.
4040

41-
[id="restic-restore-deploymentconfig-issue_{context}"]
42-
== Restore CR of Restic backup is "PartiallyFailed", "Failed", or remains "InProgress"
43-
44-
The `Restore` CR of a Restic backup completes with a `PartiallyFailed` or `Failed` status or it remains `InProgress` and does not complete.
45-
46-
If the status is `PartiallyFailed` or `Failed`, the `Velero` pod log displays the error message, `level=error msg="unable to successfully complete restic restores of pod's volumes"`.
47-
48-
If the status is `InProgress`, the `Restore` CR logs are unavailable and no errors appear in the `Restic` pod logs.
49-
50-
.Cause
51-
52-
The `DeploymentConfig` object redeploys the `Restore` pod, causing the `Restore` CR to fail.
53-
54-
.Solution
55-
56-
. Create a `Restore` CR that excludes the `ReplicationController`, `DeploymentConfig`, and `TemplateInstances` resources:
57-
+
58-
[source,terminal]
59-
----
60-
$ velero restore create --from-backup=<backup> -n openshift-adp \ <1>
61-
--include-namespaces <namespace> \ <2>
62-
--exclude-resources replicationcontroller,deploymentconfig,templateinstances.template.openshift.io \
63-
--restore-volumes=true
64-
----
65-
<1> Specify the name of the `Backup` CR.
66-
<2> Specify the `include-namespaces` in the `Backup` CR.
67-
68-
. Verify that the status of the `Restore` CR is `Completed`:
69-
+
70-
[source,terminal]
71-
----
72-
$ oc get restore -n openshift-adp <restore> -o jsonpath='{.status.phase}'
73-
----
74-
75-
. Create a `Restore` CR that includes the `ReplicationController` and `DeploymentConfig` resources:
76-
+
77-
[source,terminal]
78-
----
79-
$ velero restore create --from-backup=<backup> -n openshift-adp \
80-
--include-namespaces <namespace> \
81-
--include-resources replicationcontroller,deploymentconfig \
82-
--restore-volumes=true
83-
----
84-
85-
. Verify that the status of the `Restore` CR is `Completed`:
86-
+
87-
[source,terminal]
88-
----
89-
$ oc get restore -n openshift-adp <restore> -o jsonpath='{.status.phase}'
90-
----
91-
92-
. Verify that the backup resources have been restored:
93-
+
94-
[source,terminal]
95-
----
96-
$ oc get all -n <namespace>
97-
----
98-
9941
[id="restic-backup-cannot-be-recreated-after-s3-bucket-emptied_{context}"]
10042
== Restic Backup CR cannot be recreated after bucket is emptied
10143

0 commit comments

Comments
 (0)