-
Enhancement
-
Resolution: Unresolved
-
Major
-
None
-
None
Currently the backup and restore documentation only covers the backup of the databases. However when using the Operator capabilities to provision 3scale Customers may need to export all the objects from time to time or before some activity in the cluster (for example, an upgrade).
The request is to document a command that allows users to export all 3scale related CR as a backup in case there is any issue.
Example of command to copy the objects ONLY from the current namespace:
dir="$(mktemp -d)";pushd "${dir}" >/dev/null;echo "Dumping 3scale CRs:";for type in $(oc get crd -o NAME | egrep "(capabilities|apimanager|apicast)" | cut -d'/' -f2- | cut -d'.' -f1); do for name in $(oc get "${type}" -o custom-columns=POD:.metadata.name --no-headers); do echo -n "${type}/${name}: "; oc get "${type}/${name}" -o yaml > "${type}-${name}.yaml"; echo "OK"; done; done;echo;echo -n "Generating configuration file: ";tar cfJ 3scale-yamls.tar.xz *.yaml;echo "3scale-yamls.tar.xz";mv 3scale-yamls.tar.xz /tmp;rm -f *.yaml;popd >/dev/null;rmdir "${dir}";echo;echo "Done. Configuration file available at /tmp/3scale-yamls.tar.xz"
Example of command to copy the objects from the entire cluster:
dir="$(mktemp -d)"; pushd "${dir}" >/dev/null; mkdir "3scale-cr-yamls"; echo "Dumping 3scale CRs:"; for type in $(oc get crd -o name -A | grep ".3scale.net$" | cut -d'/' -f2 | cut -d'.' -f1); do for name in $(oc get "${type}" -A -o go-template='{{range .items}}{{.metadata.namespace}},{{.metadata.name}}{{"\n"}}{{end}}'); do echo "${name%,*}: ${type}/${name#*,}"; if [ ! -d "3scale-cr-yamls/${name%,*}" ]; then mkdir "3scale-cr-yamls/${name%,*}"; fi; oc get "${type}/${name#*,}" -n "${name%,*}" -o yaml > "3scale-cr-yamls/${name%,*}/${type}-${name#*,}.yaml"; done; done; echo; echo -n "Generating configuration file: "; tar cfJ 3scale-cr-yamls.tar.xz 3scale-cr-yamls; echo "3scale-cr-yamls.tar.xz"; popd >/dev/null; mv "${dir}/3scale-cr-yamls.tar.xz" .; rm -rf "${dir}"; echo; echo "Done. Configuration file available at 3scale-cr-yamls.tar.xz"