From ed0de24e6bc2cac4c20051070710557055b463d0 Mon Sep 17 00:00:00 2001 From: David Walter Seikel Date: Sun, 27 Nov 2016 23:58:40 +1000 Subject: Various little backup system fixes. --- scripts/backup-sims.sh | 5 +++-- scripts/gitAR.sh | 19 ++++++++++++------- scripts/start-sim | 9 +++++---- 3 files changed, 20 insertions(+), 13 deletions(-) diff --git a/scripts/backup-sims.sh b/scripts/backup-sims.sh index a449e41..b14acca 100755 --- a/scripts/backup-sims.sh +++ b/scripts/backup-sims.sh @@ -3,17 +3,18 @@ source common.sh getPrgDir -for i in $(seq 99) +for i in $(seq -w 1 99) do j=$(num2name ${i}) if [ -e "${PRGDIR}/../config/${j}" ] then - cd ${PRGDIR}/../config/$j + pushd ${PRGDIR}/../config/${j} >/dev/null # Find out the size of the last backup, base our later sleep on that, but do it now before backup-sim packs it away. sizeSleep=`sleepPerSize o "$(getSimName ${i})"` ./backup-sim # Sleep for a while, so that there is plenty of time to do the backup, # and we are not keeping the computer very busy if there are lots of sims. sleep ${sizeSleep} + popd > /dev/null fi done diff --git a/scripts/gitAR.sh b/scripts/gitAR.sh index 25cab48..bbcc761 100755 --- a/scripts/gitAR.sh +++ b/scripts/gitAR.sh @@ -51,18 +51,25 @@ cat >.gitattributes <<- zzzzEOFzzzz *.r32 -delta -diff -text *.tga -delta -diff -text zzzzEOFzzzz -git add .gitattributes &>>../log # Coz git insists. git config user.email "opensim@$(hostname -A | cut -d ' ' -f 1)" git config user.name "opensim" +# Git is such a pedantic bitch, let's just fucking ignore any errors it gives due to lack of anything to do. +# Even worse the OpenSim devs breaking logout tracking gives git plenty of nothing to do. lol + # Looping through them in case there's a bunch of I/OARs from previous versions of this script. -find ../.. -maxdepth 1 -type f -name ${name}-*.${type}ar | sort | while read file; do +# Ignore files of zero size that OpenSim might create. +find ../.. -maxdepth 1 -type f -name "${name}-*.${type}ar" -size '+0c' | sort | while read file; do # Deal with deletions in the inventory / sim, easy method, which becomes a nop for files that stay in the git add below. - git rm -fr * &>>../log && \ - nice -n 19 tar -xzf "${file}" || echo "ERROR - Could not unpack ${file} !" >>../errors + git rm -fr * &>>../log #|| echo "ERROR - Could not clean git for ${file} !" >>../errors + if [ ! -f ../errors ]; then + nice -n 19 tar -xzf "${file}" || echo "ERROR - Could not unpack ${file} !" >>../errors + fi if [ ! -f ../errors ]; then - git add * &>>../log && git add */\* &>>../log + git add * &>>../log + git add */\* &>>../log #|| echo "ERROR - Could not add ${file} to git!" >>../errors + git add .gitattributes &>>../log # Magic needed to figure out if there's anything to commit. # After all the pain to get this to work, there's an ever changing timestamp in archive.xml that screws it up. # Like this system didn't have enough timestamps in it already. lol @@ -99,5 +106,3 @@ if [ -f ${PRGDIR}/../../backups/temp_backup${type}_${name}/errors ]; then else rm -fr ${PRGDIR}/../../backups/temp_backup${type}_${name} fi - -echo -n ${name} diff --git a/scripts/start-sim b/scripts/start-sim index 72bb9ba..6c87e09 100755 --- a/scripts/start-sim +++ b/scripts/start-sim @@ -101,7 +101,8 @@ case $(basename $0) in ;; "backup-inventory") - user=$($SUDO ${PRGDIR}/gitAR.sh i "${inventory}") + $SUDO ${PRGDIR}/gitAR.sh i "${inventory}" + user=$(sanitize "${inventory}") # Add the full date and time to create the IAR file name. cmd="save iar -c ${inventory} / password ${PRGDIR}/../../backups/${user}-${date}.iar" # Do it in the highest numbered window. @@ -110,13 +111,13 @@ case $(basename $0) in ;; "backup-sim") - sim=$($SUDO ${PRGDIR}/gitAR.sh o "${title}") + $SUDO ${PRGDIR}/gitAR.sh o "${title}" + sim=$(sanitize "${title}") # Add the full date and time to create the OAR file name. cmd="save oar --all ${PRGDIR}/../../backups/${sim}-${date}.oar" if [ -e /var/run/opensim/${tgt}.pid ]; then ${tmux_send}:"[${title}]" "${cmd}" Enter - # Wait a bit, then generate the map tiles, coz the good generator leaks memory badly if you leave it turned on. - sleep 30 + # Generate the map tiles, coz the good generator leaks memory badly if you leave it turned on. ${tmux_send}:"[${title}]" "generate map" Enter ${tmux_send}:"[${title}]" "force gc" Enter else -- cgit v1.1