summaryrefslogtreecommitdiff
path: root/bin/workstation-duplicity
diff options
context:
space:
mode:
authorSean Whitton <spwhitton@spwhitton.name>2019-08-13 14:11:11 +0100
committerSean Whitton <spwhitton@spwhitton.name>2019-08-13 14:11:11 +0100
commit259cd091ea424fe53bbee8c0253bc1e6a824db20 (patch)
tree5ff2a0b0c52fac8e0c3dca7eddcaab36f8ab369c /bin/workstation-duplicity
parent65a6d6d3fb51f00581ec8d64231af2b6c207b139 (diff)
downloaddotfiles-259cd091ea424fe53bbee8c0253bc1e6a824db20.tar.gz
workstation-duplicity: changes so I can run script outside of cron
Diffstat (limited to 'bin/workstation-duplicity')
-rwxr-xr-xbin/workstation-duplicity47
1 files changed, 25 insertions, 22 deletions
diff --git a/bin/workstation-duplicity b/bin/workstation-duplicity
index 14bb22fc..0656e0d5 100755
--- a/bin/workstation-duplicity
+++ b/bin/workstation-duplicity
@@ -18,26 +18,29 @@ if ! [ -e "$HOME/.duply/$DUPLY_PROFILE/conf" ]; then
exit 1
fi
-# check when we last ran; don't run if it was less than four hours ago
-if [ -e "$FLAG_FILE" ] \
- && [ -n "$(find $FLAG_FILE -newermt '4 hours ago')" ]; then
- echo "flag file too new; not backing up"
- exit 0
-fi
-
-# don't bother if we're not online
-if offline; then
- echo "not online; not backing up"
- exit 0
-fi
-
-# don't try to backup immediately; we might not be online for long
-sleep 600
-
-# confirm we're still online
-if offline; then
- echo "not online; not backing up"
- exit 0
+# fewer checks if we're running at a terminal (this is a bashism)
+if ! [ -t 1 ];
+ # check when we last ran; don't run if it was less than four hours ago
+ if [ -e "$FLAG_FILE" ] \
+ && [ -n "$(find $FLAG_FILE -newermt '4 hours ago')" ]; then
+ echo "flag file too new; not backing up"
+ exit 0
+ fi
+
+ # don't bother if we're not online
+ if offline; then
+ echo "not online; not backing up"
+ exit 0
+ fi
+
+ # don't try to backup immediately; we might not be online for long
+ sleep 600
+
+ # confirm we're still online
+ if offline; then
+ echo "not online; not backing up"
+ exit 0
+ fi
fi
if [ -e "$FLAG_FILE" ]; then
@@ -52,6 +55,6 @@ else
duply $DUPLY_PROFILE full
fi
-# if it was successful, update flag file so we don't do this again for
-# four hours
+# if it was successful, update flag file so cronjob doesn't do this
+# again for four hours
touch $FLAG_FILE