# HG changeset patch # User aldrich@ssdt-ohio.org # Date 1573575360 0 # Node ID b35f4af06ed4a931b3418b9fe2adaa7dcb1672b5 # Parent 5d759b614c90a1c23672c36642ce4ef74a5ee85b# Parent b20d1d815ea26364dae6ffd68f42b0502230f0dd flow: Merged 'v2.6.0' to ('production'). diff -r 5d759b614c90 -r b35f4af06ed4 bamboo-agent/Dockerfile --- a/bamboo-agent/Dockerfile Wed May 01 15:33:00 2019 +0100 +++ b/bamboo-agent/Dockerfile Tue Nov 12 16:16:00 2019 +0000 @@ -3,6 +3,8 @@ RUN apt-get update RUN apt-get install -y ca-certificates +####NOTE we are no longer using the docker-bamboo agent images due to migration to mutli-agent servers. + # set up nsswitch.conf for Go's "netgo" implementation (which Docker explicitly uses) # - https://github.com/docker/docker-ce/blob/v17.09.0-ce/components/engine/hack/make.sh#L149 # - https://github.com/golang/go/blob/go1.9.1/src/net/conf.go#L194-L275 @@ -36,9 +38,15 @@ && apt-get install -y openjdk-8-jdk \ - && apt-get install -y zip + && apt-get install -y zip + + + +#RUN ln -fs /usr/share/zoneinfo/America/New_York /etc/localtime && \ +#dpkg-reconfigure -f noninteractive tzdata + -ENV ANT_VERSION 1.10.5 +ENV ANT_VERSION 1.10.6 RUN cd && \ curl -fL -o apache-ant-bin.tar.gz http://www.us.apache.org/dist//ant/binaries/apache-ant-${ANT_VERSION}-bin.tar.gz && \ tar -xzf apache-ant-bin.tar.gz && \ @@ -84,6 +92,11 @@ RUN chmod +x /usr/local/bin/docker-compose +RUN apt-get install tzdata + +RUN ln -fs /usr/share/zoneinfo/America/New_York /etc/localtime && \ +dpkg-reconfigure -f noninteractive tzdata + ENTRYPOINT ["docker-entrypoint.sh"] CMD java -jar /root/atlassian-bamboo-agent-installer-6.5.0.jar $BAMBOO_SERVER/agentServer/ diff -r 5d759b614c90 -r b35f4af06ed4 bamboo-agent/bamboo-capabilities.properties --- a/bamboo-agent/bamboo-capabilities.properties Wed May 01 15:33:00 2019 +0100 +++ b/bamboo-agent/bamboo-capabilities.properties Tue Nov 12 16:16:00 2019 +0000 @@ -1,2 +1,3 @@ docker.compose=true -agent.containerized=true \ No newline at end of file +agent.containerized=true +OS_MEMORY_GB=10 \ No newline at end of file diff -r 5d759b614c90 -r b35f4af06ed4 scripts/backup-container.sh --- a/scripts/backup-container.sh Wed May 01 15:33:00 2019 +0100 +++ b/scripts/backup-container.sh Tue Nov 12 16:16:00 2019 +0000 @@ -17,27 +17,48 @@ project=$(composeGetProject) -set -o pipefail -mkdir -p ./backup -backupFile=./backup/${project}-${container}.$(date +%Y-%m-%d-%H-%M-%S).backup - -echo "preparing to backup ${container} on current project at ${projectDir}:" -echo " " - - +#If the project is empty, we want to stop the process because this is being run from the wrong directory if [ "$project" == "" ]; then echo "no project available" exit 1 fi +set -o pipefail +mkdir -p ./backup +## +##This one puts a space before the IRN +IRN=$(docker-compose exec -T $container psql --username=postgres --dbname=$container -t -c 'select irn from organization') +##Trim function in postgres didn't work - so take out the extra space this way. +IRN=`echo $IRN | sed -e 's/^[[:space:]]*//'` + +## if database is empty, it will put IRN 000000 +if [ "$IRN" == "" ]; then + echo "no IRN set,using 000000" + IRN=000000 +fi + +backupFile=./backup/${IRN}${project}-${container}.$(date +%Y-%m-%d-%H-%M-%S).backup + +echo "Project is $project" +echo "Container is $container" +echo "IRN is $IRN" + +echo "backup file ${backupFile}" +echo "preparing to backup ${container} on current project at ${projectDir}:" +echo " " + + + echo "starting backup of $container for $project" docker-compose exec -T $container sh -c "gosu postgres pg_dump -Cc --if-exists --dbname=$container ; (exit $?) " > ${backupFile} if [[ $( grep --count "CREATE TABLE" ${backupFile} ) -lt 200 || $( grep --count "PostgreSQL database dump complete" ${backupFile} ) -eq 0 ]]; then echo "ERROR: backup verification FAILED" + echo "Error: empty database" echo "ERROR: $(tail ${backupFile})" - exit 1 + # We want the process to continue even if the db is blank + # exit 1 fi gzip ${backupFile} diff -r 5d759b614c90 -r b35f4af06ed4 scripts/remote-backup-all.sh --- a/scripts/remote-backup-all.sh Wed May 01 15:33:00 2019 +0100 +++ b/scripts/remote-backup-all.sh Tue Nov 12 16:16:00 2019 +0000 @@ -12,7 +12,6 @@ # This will backup both usasdb and uspsdb, # along with the top level contents of the project directory #Environment variables can be used for REMOTE_BACKUP_TARGET and REMOTE_USERNAME - remoteTarget=${1:-$REMOTE_BACKUP_TARGET} userName=${2:-$REMOTE_USERNAME} projectDir=${3:-$PWD} @@ -30,20 +29,40 @@ project=$(composeGetProject) -echo "project is $project" -echo "Containers are $container1 and $container2" -echo "Remote target is $remoteTarget" -echo "Username is $userName" +#If the project is empty, we want to stop the process because this is being run from the wrong directory if [ "$project" == "" ]; then echo "no project available" exit 1 fi +## first will try to get IRNfrom usasdb; if that is empty it will try to get it from uspsdb -backupFile1=./backup/${project}-${container1}.$(date +%Y-%m-%d-%H-%M-%S).backup -backupFile2=./backup/${project}-${container2}.$(date +%Y-%m-%d-%H-%M-%S).backup -backupFile3=./backup/${project}-directory.$(date +%Y-%m-%d-%H-%M-%S).directorycontents.tar.gz +IRN=$(docker-compose exec -T $container1 psql --username=postgres --dbname=$container1 -t -c 'select irn from organization') + +if [ "$IRN" == "" ]; then +IRN=$(docker-compose exec -T $container2 psql --username=postgres --dbname=$container2 -t -c 'select irn from organization') +fi + +##Trim function in postgres didn't work - so take out the extra space this way. +IRN=`echo $IRN | sed -e 's/^[[:space:]]*//'` + +## if both database are empty, it will put IRN 000000 +if [ "$IRN" == "" ]; then + echo "no IRN set, using 000000" + IRN=000000 +fi + +echo "project is $project" +echo "Containers are $container1 and $container2" +echo "Remote target is $remoteTarget" +echo "Username is $userName" +echo "IRN is $IRN" + + +backupFile1=./backup/${IRN}${project}-${container1}.$(date +%Y-%m-%d-%H-%M-%S).backup +backupFile2=./backup/${IRN}${project}-${container2}.$(date +%Y-%m-%d-%H-%M-%S).backup +backupFile3=./backup/${IRN}${project}-directory.$(date +%Y-%m-%d-%H-%M-%S).directorycontents.tar.gz #usasdb echo "starting backup of $container1 for $project" @@ -52,16 +71,17 @@ if [[ $( grep --count "CREATE TABLE" ${backupFile1} ) -lt 200 || $( grep --count "PostgreSQL database dump complete" ${backupFile1} ) -eq 0 ]]; then echo "ERROR: backup verification FAILED" echo "ERROR: $(tail ${backupFile1})" - else + echo "Error: empty database" + #else We still gzip the backup file + fi gzip ${backupFile1} echo "completed backup of $container1 for $project to ${backupFile1}" - fi ##### -#uspsdb is being used +#uspsdb echo "starting backup of $container2 for $project" docker-compose exec -T $container2 sh -c "gosu postgres pg_dump -Cc --if-exists --dbname=$container2 ; (exit $?) " > ${backupFile2} @@ -69,29 +89,39 @@ if [[ $( grep --count "CREATE TABLE" ${backupFile2} ) -lt 200 || $( grep --count "PostgreSQL database dump complete" ${backupFile2} ) -eq 0 ]]; then echo "ERROR: backup verification FAILED" echo "ERROR: $(tail ${backupFile2})" - else + echo "Error: empty database" + #else We still gzip the backup file + fi gzip ${backupFile2} echo "completed backup of $container2 for $project to ${backupFile2}" - fi + ####### #backup of all files in current directory echo "starting backup of current directory for $project" -tar -czf ${backupFile3} . --exclude=./backup +#tar -czf ${backupFile3} . --exclude=./backup +tar --exclude=./backup -czf ${backupFile3} . echo "completed backup of all files for $project to ${backupFile3}" +#Create remote directory before scp +host=`echo $userName@$remoteTarget | sed -e 's/:.*//'` +target=`echo $remoteTarget | sed -e 's/.*://'` + + +ssh $host mkdir -p $target/$project + +#SCP files # -# -scp ${backupFile1}.gz ${backupFile2}.gz ${backupFile3} $userName@$remoteTarget +scp ${backupFile1}.gz ${backupFile2}.gz ${backupFile3} $userName@$remoteTarget/$project echo " " -echo "completed sending ${backupFile1}.gz, ${backupFile2}.gz, and ${backupFile3} to ${remoteTarget} as user $userName" +echo "completed sending ${backupFile1}.gz, ${backupFile2}.gz, and ${backupFile3} to ${remoteTarget}/${project} as user $userName" diff -r 5d759b614c90 -r b35f4af06ed4 scripts/remote-backup.sh --- a/scripts/remote-backup.sh Wed May 01 15:33:00 2019 +0100 +++ b/scripts/remote-backup.sh Tue Nov 12 16:16:00 2019 +0000 @@ -27,27 +27,44 @@ project=$(composeGetProject) +#If the project is empty, we want to stop the process because this is being run from the wrong directory +if [ "$project" == "" ]; then + echo "no project available" + exit 1 +fi + + +IRN=$(docker-compose exec -T $container psql --username=postgres --dbname=$container -t -c 'select irn from organization') +##Trim function in postgres didn't work - so take out the extra space this way. +IRN=`echo $IRN | sed -e 's/^[[:space:]]*//'` + +## if database is empty, it will put IRN 000000 +if [ "$IRN" == "" ]; then + echo "no IRN set, using 000000" + IRN=000000 +fi + echo "Project is $project" echo "Container is $container" echo "Remote target is $remoteTarget" echo "Username is $userName" - -backupFile=./backup/${project}-${container}.$(date +%Y-%m-%d-%H-%M-%S).backup -backupFile2=./backup/${project}-${container}.$(date +%Y-%m-%d-%H-%M-%S).directorycontents.tar.gz +echo "IRN is $IRN" -if [ "$project" == "" ]; then - echo "no project available" - exit 1 -fi +backupFile=./backup/${IRN}${project}-${container}.$(date +%Y-%m-%d-%H-%M-%S).backup +backupFile2=./backup/${IRN}${project}-${container}.$(date +%Y-%m-%d-%H-%M-%S).directorycontents.tar.gz + + echo "starting backup of $container for $project" docker-compose exec -T $container sh -c "gosu postgres pg_dump -Cc --if-exists --dbname=$container ; (exit $?) " > ${backupFile} if [[ $( grep --count "CREATE TABLE" ${backupFile} ) -lt 200 || $( grep --count "PostgreSQL database dump complete" ${backupFile} ) -eq 0 ]]; then echo "ERROR: backup verification FAILED" + echo "Error: empty database" echo "ERROR: $(tail ${backupFile})" - exit 1 + # We want the process to continue even if the db is blank + # exit 1 fi gzip ${backupFile} @@ -55,17 +72,25 @@ echo "completed backup of $container for $project to ${backupFile}" #backup of all files in current directory -tar -czf ${backupFile2} . --exclude=./backup +#tar -czf ${backupFile2} . --exclude=./backup +tar --exclude=./backup -czf ${backupFile2} . echo "completed backup of all files for $project to ${backupFile2}" +#Create remote directory before scp +host=`echo $userName@$remoteTarget | sed -e 's/:.*//'` + +target=`echo $remoteTarget | sed -e 's/.*://'` + +ssh $host mkdir -p $target/$project + +#scp file # -# -scp ${backupFile}.gz ${backupFile2} $userName@$remoteTarget +scp ${backupFile}.gz ${backupFile2} $userName@$remoteTarget/$project echo " " -echo "completed sending ${backupFile}.gz and ${backupFile2} to ${remoteTarget} as user $userName" +echo "completed sending ${backupFile}.gz and ${backupFile2} to ${remoteTarget}/${project} as user $userName"