Mercurial > public > ssdt-docker
diff scripts/remote-backup-all.sh @ 314:d78b45c28205
backup script adding IRN to name
author | aldrich@ssdt-ohio.org |
---|---|
date | Mon, 28 Oct 2019 19:43:53 +0100 |
parents | 4cc087cde1d0 |
children | 146c0c263cf9 |
line wrap: on
line diff
--- a/scripts/remote-backup-all.sh Thu Jun 27 19:21:53 2019 +0100 +++ b/scripts/remote-backup-all.sh Mon Oct 28 19:43:53 2019 +0100 @@ -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,31 @@ project=$(composeGetProject) -echo "project is $project" -echo "Containers are $container1 and $container2" -echo "Remote target is $remoteTarget" -echo "Username is $userName" - if [ "$project" == "" ]; then echo "no project available" exit 1 fi -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:]]*//'` + +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" @@ -81,7 +91,8 @@ #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} . --exclude=./backup echo "completed backup of all files for $project to ${backupFile3}"