Created
December 14, 2020 09:36
-
-
Save kwonghung-YIP/d6efcc2b0e70ce7dfce593223c5e3899 to your computer and use it in GitHub Desktop.
[docker-CLI] backup the jenkins_home volume for Jenkins service in docker swarm
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
#!/bin/bash | |
bkupdir="<your backup folder>/bkup_`date +%Y%m%d_%H%M%S`" | |
log="$bkupdir/backup.log" | |
mkdir -p $bkupdir | |
echo "backup folder : $bkupdir" | |
echo "Start time : `date`" >> $log | |
echo "backup folder : $bkupdir" >> $log | |
ctrId=`docker ps -q --filter "label=com.docker.swarm.service.name=<your jenkins service name>" --filter "status=running"` | |
docker run --rm -it \ | |
--volumes-from $ctrId \ | |
-v $bkupdir:/bkup \ | |
ubuntu \ | |
tar -cf /bkup/jenkins_home.tar -C /var/jenkins_home secrets | |
echo "End date : `date`" >> $log |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment