Skip to content

Commit ee8f462

Browse files
committed
added all files for migration doc to migration examples dir
1 parent 3187bac commit ee8f462

File tree

10 files changed

+111
-0
lines changed

10 files changed

+111
-0
lines changed
File renamed without changes.
File renamed without changes.
File renamed without changes.
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
# Restore Master from Backup
2+
This script is designed to perform a restoration of a Master instance in CloudBees Core modern.
3+
It follows the process outlined in documentation: https://docs.cloudbees.com/docs/admin-resources/latest/backup-restore/restoring-manually
4+
5+
6+
## Pre-Requistes
7+
- By default the ownership ID of the jenkins user inside of the cjoc container is 1000. This script assumes this remains the same.
8+
- This script assumes backups are saved in tar.gz format.
9+
- The local environment which this script is executed in must have aws and kubectl commands available and authorized.
10+
- AWS access from the local command line must have access to download from the associated/configured S3 bucket containing the backup file.
11+
- The rescue container must have the tar command tool installed.
12+
- The rescue container must have privileges to change ownership and permissions of files in the /tmp directory.
13+
- The rescue container must be able to mount the team master persistent volume.
14+
15+
## Run
16+
Configure the config file and run this script using `bash masterRestore.sh`.
17+
Alternatively run the script using the parameters `bash masterRestore.sh $namespace $masterStatefulsetName $s3Bucket $backupFilePath $rescueContainerImage`.
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
#!/bin/bash
2+
3+
#VARIABLES
4+
5+
# Kubernetes namespace for Master
6+
namespace=cloudbees-core
7+
8+
#Name of the Master statefulset
9+
masterStatefulsetName=master123
10+
11+
#Container with version if required, to use for the rescue pod
12+
rescueContainerImage=youImage
13+
14+
#Download the backup artifact
15+
s3Bucket=core-backups
16+
backupFilePath=master/backup.tar.gz
Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
1+
#!/bin/bash
2+
set -e
3+
4+
namespace=$1 #Kubernetes namespace where master is deployed.
5+
masterStatefulsetName=$2 #The statefulset name of the master deployment.
6+
s3Bucket=$3 #S3 bucketname containing backups.
7+
backupFilePath=$4 #Path of the tar.qz file within the S3 bucket.
8+
rescueContainerImage=$5 #Container with version if required, to use for the rescue pod.
9+
10+
if [ -z $namespace ] || [ -z $masterStatefulsetName ] || [ -z $s3Bucket ] || [ -z $backupFilePath ] || [ -z $rescueContainerImage ]
11+
then
12+
echo "Execution parameters missing. Loading variables from config file."
13+
source config
14+
fi
15+
16+
echo "Scale down Master pods to 0 replicas"
17+
kubectl --namespace=$namespace scale statefulset/$masterStatefulsetName --replicas=0
18+
19+
#Launch rescue pod attaching the pvc
20+
persistentVolumeClaim=$(kubectl -n $namespace get statefulset $masterStatefulsetName -o jsonpath="{.spec.volumeClaimTemplates[0].metadata.name}")-${masterStatefulsetName}-0
21+
echo "Launching rescue-pod with pvc $persistentVolumeClaim attached"
22+
23+
cat <<EOF | kubectl --namespace=$namespace create -f -
24+
25+
kind: Pod
26+
apiVersion: v1
27+
metadata:
28+
name: rescue-pod
29+
spec:
30+
securityContext:
31+
runAsUser: 1000
32+
runAsGroup: 1000
33+
fsGroup: 1000
34+
volumes:
35+
- name: rescue-storage
36+
persistentVolumeClaim:
37+
claimName: $persistentVolumeClaim
38+
containers:
39+
- name: rescue-container
40+
image: $rescueContainerImage
41+
command: ['sh', '-c', 'echo The app is running! && sleep 100000' ]
42+
volumeMounts:
43+
- mountPath: "/tmp/jenkins-home"
44+
name: rescue-storage
45+
EOF
46+
47+
echo "Downloading the backup file from S3 into local /tmp directory"
48+
aws s3 cp s3://${s3Bucket}/${backupFilePath} /tmp/backup.tar.gz
49+
50+
echo "Waiting for the rescue-pod to enter Ready state"
51+
kubectl wait --namespace=$namespace --for=condition=Ready --timeout=600s pod/rescue-pod
52+
53+
echo "Moving the backup file into the rescue-pod"
54+
kubectl cp --namespace=$namespace /tmp/backup.tar.gz rescue-pod:/tmp/
55+
56+
echo "Empty /tmp/jenkins-home of all files and folders on pvc $persistentVolumeClaim"
57+
kubectl exec --namespace=$namespace rescue-pod -- find /tmp/jenkins-home -type f -name "*.*" -delete || echo "Files deleted in jenkins-home"
58+
kubectl exec --namespace=$namespace rescue-pod -- find /tmp/jenkins-home -type f -name "*" -delete || echo "Files deleted in jenkins-home"
59+
kubectl exec --namespace=$namespace rescue-pod -- find /tmp/jenkins-home/ -mindepth 1 -type d -name "*" -exec rm -rf {} \; || echo "Folders deleted in jenkins-home"
60+
61+
echo "Uncompress the backup file into /tmp/jenkins-home"
62+
kubectl exec --namespace=$namespace rescue-pod -- tar -xzf /tmp/backup.tar.gz --directory /tmp/jenkins-home
63+
64+
echo "Update ownership permissions recursively"
65+
kubectl exec --namespace=$namespace rescue-pod -- chown -R 1000:1000 /tmp/jenkins-home
66+
67+
echo "Deleting the rescue-pod"
68+
kubectl --namespace=$namespace delete pod rescue-pod
69+
70+
echo "Scale up pods to 1 replica"
71+
kubectl --namespace=$namespace scale statefulset/$masterStatefulsetName --replicas=1
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
monitoring/,caches/,operations-center-cloud*,operations-center-client*,plugins/operations-center-analytics-config*,plugins/operations-center-analytics-config/,plugins/operations-center-analytics-reporter*,plugins/operations-center-analytics-reporter/,plugins/palace-cloud*,plugins/palace-cloud/,plugins/tiger-tenant*,plugins/tiger-tenant/
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
{"version":"1","data":[{"id":"kubernetes","name":"Kubernetes plugin","version":"1.23.1"},{"id":"scm-api","name":"SCM API Plugin","version":"2.6.3"},{"id":"nectar-license","name":"CloudBees Jenkins Enterprise License Entitlement Check","version":"8.25"},{"id":"workflow-basic-steps","name":"Pipeline: Basic Steps","version":"2.19"},{"id":"pipeline-milestone-step","name":"Pipeline: Milestone Step","version":"1.3.1"},{"id":"structs","name":"Structs Plugin","version":"1.20"},{"id":"git-server","name":"GIT server Plugin","version":"1.9"},{"id":"cloudbees-license","name":"CloudBees License Manager","version":"9.36"},{"id":"aws-java-sdk","name":"Amazon Web Services SDK","version":"1.11.700"},{"id":"kube-agent-management","name":"Kube Agent Management plugin","version":"1.1.25"},{"id":"mailer","name":"Mailer Plugin","version":"1.30"},{"id":"plain-credentials","name":"Plain Credentials Plugin","version":"1.5"},{"id":"cloudbees-monitoring","name":"CloudBees Monitoring Plugin","version":"2.8"},{"id":"pipeline-graph-analysis","name":"Pipeline Graph Analysis Plugin","version":"1.10"},{"id":"support-core","name":"Support Core Plugin","version":"2.67"},{"id":"command-launcher","name":"Command Agent Launcher Plugin","version":"1.4"},{"id":"github","name":"GitHub plugin","version":"1.29.4"},{"id":"operations-center-client","name":"Operations Center Client Plugin","version":"2.204.0.6"},{"id":"cloudbees-folder","name":"Folders Plugin","version":"6.9"},{"id":"ace-editor","name":"JavaScript GUI Lib: ACE Editor bundle plugin","version":"1.1"},{"id":"pipeline-stage-step","name":"Pipeline: Stage Step","version":"2.3"},{"id":"workflow-aggregator","name":"Pipeline","version":"2.5"},{"id":"pipeline-model-extensions","name":"Pipeline: Declarative Extension Points API","version":"1.5.0"},{"id":"display-url-api","name":"Display URL API","version":"2.3.1"},{"id":"operations-center-agent","name":"Operations Center Agent","version":"2.204.0.5"},{"id":"pipeline-model-api","name":"Pipeline: Model API","version":"1.5.0"},{"id":"workflow-multibranch","name":"Pipeline: Multibranch","version":"2.21"},{"id":"pipeline-rest-api","name":"Pipeline: REST API Plugin","version":"2.12"},{"id":"github-api","name":"GitHub API Plugin","version":"1.106"},{"id":"operations-center-cloud","name":"Operations Center Cloud","version":"2.204.0.5"},{"id":"handlebars","name":"JavaScript GUI Lib: Handlebars bundle plugin","version":"1.1.1"},{"id":"pipeline-model-definition","name":"Pipeline: Declarative","version":"1.5.0"},{"id":"email-ext","name":"Email Extension Plugin","version":"2.68"},{"id":"cloudbees-blueocean-default-theme","name":"CloudBees Blue Ocean Default Theme","version":"0.5"},{"id":"authentication-tokens","name":"Authentication Tokens API Plugin","version":"1.3"},{"id":"ssh-credentials","name":"SSH Credentials Plugin","version":"1.18.1"},{"id":"form-element-path","name":"Form element path plugin","version":"1.8"},{"id":"operations-center-context","name":"Operations Center Context","version":"2.204.0.5"},{"id":"cloudbees-folders-plus","name":"CloudBees Folders Plus Plugin","version":"3.9"},{"id":"variant","name":"Variant Plugin","version":"1.3"},{"id":"workflow-cps-checkpoint","name":"CloudBees Pipeline: Groovy Checkpoint Plugin","version":"2.8"},{"id":"jdk-tool","name":"Oracle Java SE Development Kit Installer Plugin","version":"1.4"},{"id":"docker-commons","name":"Docker Commons Plugin","version":"1.16"},{"id":"infradna-backup","name":"CloudBees Backup Plugin","version":"3.38.17"},{"id":"jaxb","name":"JAXB plugin","version":"2.3.0.1"},{"id":"cloudbees-workflow-template","name":"CloudBees Pipeline: Templates Plugin","version":"3.3"},{"id":"matrix-project","name":"Matrix Project Plugin","version":"1.14"},{"id":"workflow-cps","name":"Pipeline: Groovy","version":"2.79"},{"id":"workflow-scm-step","name":"Pipeline: SCM Step","version":"2.9"},{"id":"apache-httpcomponents-client-4-api","name":"Apache HttpComponents Client 4.x API Plugin","version":"4.5.10-2.0"},{"id":"junit","name":"JUnit Plugin","version":"1.28"},{"id":"pipeline-stage-view","name":"Pipeline: Stage View Plugin","version":"2.12"},{"id":"cloudbees-analytics","name":"CloudBees Analytics Plugin","version":"1.9"},{"id":"nectar-rbac","name":"CloudBees Role-Based Access Control Plugin","version":"5.30"},{"id":"aws-credentials","name":"CloudBees AWS Credentials Plugin","version":"1.28"},{"id":"pipeline-input-step","name":"Pipeline: Input Step","version":"2.11"},{"id":"metrics","name":"Metrics Plugin","version":"4.0.2.6"},{"id":"workflow-step-api","name":"Pipeline: Step API","version":"2.22"},{"id":"pipeline-build-step","name":"Pipeline: Build Step","version":"2.11"},{"id":"durable-task","name":"Durable Task Plugin","version":"1.33"},{"id":"cloudbees-ssh-slaves","name":"CloudBees SSH Build Agents Plugin","version":"2.5"},{"id":"git-client","name":"Git client plugin","version":"3.0.0"},{"id":"kubernetes-credentials","name":"Kubernetes Credentials Plugin","version":"0.6.0"},{"id":"cloudbees-uc-data-api","name":"CloudBees Update Center Data API","version":"4.42"},{"id":"ldap","name":"LDAP Plugin","version":"1.21"},{"id":"unique-id","name":"Unique ID Library Plugin","version":"2.2.0"},{"id":"cloudbees-jsync-archiver","name":"CloudBees Fast Archiving Plugin","version":"5.11"},{"id":"wikitext","name":"CloudBees WikiText Security Plugin","version":"3.9"},{"id":"workflow-support","name":"Pipeline: Supporting APIs","version":"3.4"},{"id":"bouncycastle-api","name":"bouncycastle API Plugin","version":"2.18"},{"id":"mapdb-api","name":"MapDB API Plugin","version":"1.0.9.0"},{"id":"cloudbees-view-creation-filter","name":"CloudBees View Creation Filter Plugin","version":"1.6"},{"id":"jackson2-api","name":"Jackson 2 API Plugin","version":"2.10.2"},{"id":"git","name":"Git plugin","version":"4.0.1"},{"id":"workflow-job","name":"Pipeline: Job","version":"2.36"},{"id":"node-iterator-api","name":"Node Iterator API Plugin","version":"1.5.0"},{"id":"token-macro","name":"Token Macro Plugin","version":"2.10"},{"id":"workflow-api","name":"Pipeline: API","version":"2.39"},{"id":"momentjs","name":"JavaScript GUI Lib: Moment.js bundle plugin","version":"1.1.1"},{"id":"cloudbees-assurance","name":"Beekeeper Upgrade Assistant Plugin","version":"2.138.0.11"},{"id":"gradle","name":"Gradle Plugin","version":"1.36"},{"id":"trilead-api","name":"Trilead API Plugin","version":"1.0.5"},{"id":"script-security","name":"Script Security Plugin","version":"1.71"},{"id":"credentials-binding","name":"Credentials Binding Plugin","version":"1.20"},{"id":"cloudbees-template","name":"CloudBees Template Plugin","version":"4.43"},{"id":"jquery-detached","name":"JavaScript GUI Lib: jQuery bundles (jQuery and jQuery UI) plugin","version":"1.2.1"},{"id":"pipeline-stage-tags-metadata","name":"Pipeline: Stage Tags Metadata","version":"1.5.0"},{"id":"cloudbees-nodes-plus","name":"CloudBees Nodes Plus Plugin","version":"1.19"},{"id":"credentials","name":"Credentials Plugin","version":"2.3.0"},{"id":"cloudbees-administrative-monitors","name":"CloudBees Administrative Monitors Plugin","version":"1.0.1"},{"id":"async-http-client","name":"Async Http Client","version":"1.7.24.3"},{"id":"google-oauth-plugin","name":"Google OAuth Credentials plugin","version":"1.0.0"},{"id":"jsch","name":"JSch dependency plugin","version":"0.1.55.1"},{"id":"kubernetes-client-api","name":"Kubernetes Client API Plugin","version":"4.6.4-2"},{"id":"pipeline-model-declarative-agent","name":"Pipeline: Declarative Agent API","version":"1.1.1"},{"id":"branch-api","name":"Branch API Plugin","version":"2.5.5"},{"id":"workflow-durable-task-step","name":"Pipeline: Nodes and Processes","version":"2.35"},{"id":"oauth-credentials","name":"OAuth Credentials plugin","version":"0.4"},{"id":"cloudbees-support","name":"CloudBees Support Plugin","version":"3.22"},{"id":"cloudbees-workflow-ui","name":"CloudBees Pipeline Stage View Extensions","version":"2.3"},{"id":"workflow-cps-global-lib","name":"Pipeline: Shared Groovy Libraries","version":"2.15"},{"id":"docker-workflow","name":"Docker Pipeline","version":"1.21"},{"id":"cloudbees-groovy-view","name":"CloudBees Groovy View Plugin","version":"1.9"},{"id":"github-branch-source","name":"GitHub Branch Source Plugin","version":"2.6.0"},{"id":"blueocean-commons","name":"Common API for Blue Ocean","version":"1.21.0"},{"id":"notification-api","name":"Notification API","version":"1.2"},{"id":"pipeline-event-step","name":"Pipeline Event Step","version":"1.7"},{"id":"saml","name":"SAML Plugin","version":"1.1.4"},{"id":"operations-center-notification","name":"Operations Center Notification","version":"1.0"},{"id":"cloudbees-jenkins-advisor","name":"Health Advisor by CloudBees","version":"3.0.1"},{"id":"mercurial","name":"Mercurial plugin","version":"2.8"},{"id":"handy-uri-templates-2-api","name":"Handy Uri Templates 2.x API Plugin","version":"2.1.8-1.0"},{"id":"cloudbees-bitbucket-branch-source","name":"Bitbucket Branch Source Plugin","version":"2.5.0"},{"id":"scalable-amazon-ecs","name":"Amazon EC2 Container Service plugin with autoscaling capabilities","version":"1.0"},{"id":"ec2","name":"Amazon EC2 plugin","version":"1.49.1"}]}
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Create a file named quiet-start.groovy and place it in the $JENKINS_HOME/init.groovy.d/ directory. You may have to create this directory if it does not already exist.
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
import jenkins.model.Jenkins
2+
3+
// Go into quiet mode
4+
Jenkins.instance.doQuietDown()

0 commit comments

Comments
 (0)