Last active
June 3, 2019 18:51
-
-
Save lloesche/09b70031f6f815c77fba1bba8efd42ff to your computer and use it in GitHub Desktop.
Backup/Restore DC/OS Services and Jobs from one cluster to another in a suspended state
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
CLUSTER_A=olddcos | |
CLUSTER_B=newdcos | |
# BACKUP SERVICES | |
dcos cluster attach $CLUSTER_A | |
curl -H "Authorization: token=$(dcos config show core.dcos_acs_token)" $(dcos config show core.dcos_url)/service/marathon/v2/apps | \ | |
jq '.[] | del(.[].version) | del(.[].uri) | del(.[].versionInfo) | del(.[].tasksStaged) | del(.[].tasksRunning) | del(.[].tasksHealthy) | del(.[].tasksUnhealthy) | del(.[].deployments)' > apps.json | |
for id in $(jq -r '.[] | "\(.id)"' apps.json); do cleanid="${id//\//_}"; jq ".[] | select(.id==\"$id\") | .instances=0" apps.json > service.${cleanid:1}.json; done | |
# BACKUP JOBS | |
dcos cluster attach $CLUSTER_A | |
dcos job list --json > jobs.json | |
for id in $(jq -r '.[] | "\(.id)"' jobs.json); do cleanid="${id//\//_}"; jq ".[] | select(.id==\"$id\") | del(.historySummary) | del(.activeRuns) | .schedules[].enabled=false" jobs.json > job.${cleanid}.json; done | |
# RESTORE SERVICES | |
dcos cluster attach $CLUSTER_B | |
ls -1 service.*.json | xargs -n 1 dcos marathon app add | |
# RESTORE JOBS | |
dcos cluster attach $CLUSTER_B | |
ls -1 job.*.json | xargs -n 1 dcos job add | |
# BACKUP AND RESTORE SECRETS | |
https://github.com/justinrlee/dcos-secrets-backup/ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment