aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/scripts/backup-inventories.sh
diff options
context:
space:
mode:
authorDavid Walter Seikel2016-11-08 15:49:56 +1000
committerDavid Walter Seikel2016-11-08 15:49:56 +1000
commit96eda14b7a1caff77da000a9a957b20ab1a1bb6e (patch)
treeceb91518776a8b36af8f08c155074fb77f5a437a /scripts/backup-inventories.sh
parentReduce default logging level to INFO. (diff)
downloadopensim-SC_OLD-96eda14b7a1caff77da000a9a957b20ab1a1bb6e.zip
opensim-SC_OLD-96eda14b7a1caff77da000a9a957b20ab1a1bb6e.tar.gz
opensim-SC_OLD-96eda14b7a1caff77da000a9a957b20ab1a1bb6e.tar.bz2
opensim-SC_OLD-96eda14b7a1caff77da000a9a957b20ab1a1bb6e.tar.xz
Lots of hacking up the scripts to work with the new setup, and more.
Diffstat (limited to 'scripts/backup-inventories.sh')
-rwxr-xr-xscripts/backup-inventories.sh42
1 files changed, 42 insertions, 0 deletions
diff --git a/scripts/backup-inventories.sh b/scripts/backup-inventories.sh
new file mode 100755
index 0000000..642d71d
--- /dev/null
+++ b/scripts/backup-inventories.sh
@@ -0,0 +1,42 @@
1#!/bin/bash
2
3# Figure out where we are, most of this mess is to troll through soft links.
4PRG="$0"
5while [ -h "${PRG}" ] ; do
6 ls=$(ls -ld "${PRG}")
7 link=`expr "${ls}" : '.*-> \(.*\)$'`
8 if expr "${link}" : '.*/.*' > /dev/null; then
9 PRG="${link}"
10 else
11 PRG=$(dirname "${PRG}")/"${link}"
12 fi
13done
14PRGDIR=$(dirname "${PRG}")
15pushd ${PRGDIR} >/dev/null
16PRGDIR=$(pwd)
17popd >/dev/null
18
19# Get the database credentials.
20declare -A creds
21while read -d ';' p; do
22 k=$(echo ${p} | cut -d '=' -f 1)
23 v=$(echo ${p} | cut -d '=' -f 2)
24 creds[${k}]="${v}"
25done < <(grep ConnectionString ${PRGDIR}/../config/config.ini | cut -d '"' -f 2)
26# The above seems the best way to get bash to let the creds assignments survive outside the loop.
27
28# Only backup those that have not logged on since their last backup, but returning prims from sims will bypass this check.
29timestamp=$(ls -o --time-style="+%s" ${PRGDIR}/../backups/.keep | cut -d ' ' -f 5)
30touch ${PRGDIR}/../backups/.keep
31
32# Get the user names, and back 'em up.
33mysql --host="${creds[Data Source]}" "${creds[Database]}" --user="${creds[User ID]}" --password="${creds[Password]}" \
34 -e "select FirstName,LastName from UserAccounts,GridUser where UserAccounts.PrincipalID=GridUser.UserID and GridUser.Logout>${timestamp};" -ss | while read user; do
35 # Replace tab with space
36 user=${user// / }
37 ${PRGDIR}/backup-inventory "${user}"
38 # Sleep for a while, so that there is plenty of time to do the backup,
39 # and we are not keeping the computer very busy if there are lots of users.
40 # My big arsed 1 GB OAR takes about ten minutes to create, and maybe an hour to gitIOR!
41 sleep 200
42done