comparison scripts/remote-backup-all.sh @ 322:4285b8a2762e

making changes to remote backup scripts to account for IRN - tweaks
author aldrich@ssdt-ohio.org
date Thu, 31 Oct 2019 16:15:12 +0100
parents 58c49a386a11
children
comparison
equal deleted inserted replaced
321:2cb1093f9aef 322:4285b8a2762e
71 if [[ $( grep --count "CREATE TABLE" ${backupFile1} ) -lt 200 || $( grep --count "PostgreSQL database dump complete" ${backupFile1} ) -eq 0 ]]; then 71 if [[ $( grep --count "CREATE TABLE" ${backupFile1} ) -lt 200 || $( grep --count "PostgreSQL database dump complete" ${backupFile1} ) -eq 0 ]]; then
72 echo "ERROR: backup verification FAILED" 72 echo "ERROR: backup verification FAILED"
73 echo "ERROR: $(tail ${backupFile1})" 73 echo "ERROR: $(tail ${backupFile1})"
74 echo "Error: empty database" 74 echo "Error: empty database"
75 #else We still gzip the backup file 75 #else We still gzip the backup file
76 fi
76 gzip ${backupFile1} 77 gzip ${backupFile1}
77 78
78 echo "completed backup of $container1 for $project to ${backupFile1}" 79 echo "completed backup of $container1 for $project to ${backupFile1}"
79 80
80 fi
81 81
82 82
83 ##### 83 #####
84 #uspsdb is being used 84 #uspsdb
85 85
86 echo "starting backup of $container2 for $project" 86 echo "starting backup of $container2 for $project"
87 docker-compose exec -T $container2 sh -c "gosu postgres pg_dump -Cc --if-exists --dbname=$container2 ; (exit $?) " > ${backupFile2} 87 docker-compose exec -T $container2 sh -c "gosu postgres pg_dump -Cc --if-exists --dbname=$container2 ; (exit $?) " > ${backupFile2}
88 88
89 if [[ $( grep --count "CREATE TABLE" ${backupFile2} ) -lt 200 || $( grep --count "PostgreSQL database dump complete" ${backupFile2} ) -eq 0 ]]; then 89 if [[ $( grep --count "CREATE TABLE" ${backupFile2} ) -lt 200 || $( grep --count "PostgreSQL database dump complete" ${backupFile2} ) -eq 0 ]]; then
90 echo "ERROR: backup verification FAILED" 90 echo "ERROR: backup verification FAILED"
91 echo "ERROR: $(tail ${backupFile2})" 91 echo "ERROR: $(tail ${backupFile2})"
92 echo "Error: empty database" 92 echo "Error: empty database"
93 #else We still gzip the backup file 93 #else We still gzip the backup file
94 fi
94 gzip ${backupFile2} 95 gzip ${backupFile2}
95 96
96 echo "completed backup of $container2 for $project to ${backupFile2}" 97 echo "completed backup of $container2 for $project to ${backupFile2}"
97 98
98 fi 99
99 100
100 ####### 101 #######
101 102
102 #backup of all files in current directory 103 #backup of all files in current directory
103 echo "starting backup of current directory for $project" 104 echo "starting backup of current directory for $project"
110 #Create remote directory before scp 111 #Create remote directory before scp
111 host=`echo $userName@$remoteTarget | sed -e 's/:.*//'` 112 host=`echo $userName@$remoteTarget | sed -e 's/:.*//'`
112 113
113 target=`echo $remoteTarget | sed -e 's/.*://'` 114 target=`echo $remoteTarget | sed -e 's/.*://'`
114 115
116
115 ssh $host mkdir -p $target/$project 117 ssh $host mkdir -p $target/$project
116 118
117 119 #SCP files
118 #Create remote directory
119 # 120 #
120 scp ${backupFile1}.gz ${backupFile2}.gz ${backupFile3} $userName@$remoteTarget/$project 121 scp ${backupFile1}.gz ${backupFile2}.gz ${backupFile3} $userName@$remoteTarget/$project
121 122
122 echo " " 123 echo " "
123 124