Skip to content

Instantly share code, notes, and snippets.

@inthecloud247
Forked from bryantrobbins/Jenkins Slave Dockerfile
Last active August 29, 2015 14:09
Show Gist options
  • Save inthecloud247/aa368e2f3e0d3da46454 to your computer and use it in GitHub Desktop.
Save inthecloud247/aa368e2f3e0d3da46454 to your computer and use it in GitHub Desktop.
#/bin/bash
archive=$1
if [ -z "$archive" ]; then
echo "No archive provided."
echo "Usage: $0 archive.tar"
exit
fi
if [ -e "$archive" ]; then
echo "File $archive already exists. Please choose another name"
exit
fi
local=`pwd`
echo "Backing up to $archive"
echo "Exporting data current rdata container"
docker rm backup
docker run --name backup --volumes-from rdata -v $local:/backup busybox tar cvf /backup/$archive var/jenkins_home nexus
docker rm backup
#/bin/bash
archive=$1
if [ -z "$archive" ]; then
echo "No archive provided."
echo "Usage: $0 archive.tar"
exit
fi
echo "Loading from $archive"
# Clean up any old stuff here
docker rm rdata
# Start new data container
echo "Starting new rdata container"
docker run -d --name rdata -v /var/jenkins_home -v /nexus busybox true
# Copy in files from old data container
echo "Restoring old files into new rdata"
docker rm restore
docker run --name restore --volumes-from rdata -v $(pwd):/backup busybox tar xvf /backup/$archive
docker rm restore
#/bin/bash
now=`date +%s`
arch="backup.$now.tar"
./backup.sh $arch
./load.sh $arch
rm $arch
./start.sh
#/bin/bash
archive=$1
if [ -z "$archive" ]; then
echo "No archive provided."
echo "Usage: $0 archive.tar"
exit
fi
echo "Restoring from $archive"
./load.sh $archive
./start.sh
#/bin/bash
# Start nexus
docker stop nexus
docker rm nexus
docker run -d --name nexus --volumes-from rdata -p 8081:8081 conceptnotfound/sonatype-nexus
# Start jenkins
docker stop jenkins
docker rm jenkins
docker run -d --name jenkins --volumes-from rdata --link nexus:nexus -p 8080:8080 -u root jenkins
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment