Skip to content

Instantly share code, notes, and snippets.

@oderwat
Last active August 23, 2017 21:34
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save oderwat/6b790effbf955300aaeaa76a462e6e2a to your computer and use it in GitHub Desktop.
Save oderwat/6b790effbf955300aaeaa76a462e6e2a to your computer and use it in GitHub Desktop.
Script for single archival of locations with SpiderOakONE which stops and starts the application as needed
#!/usr/bin/env osascript
#
# Script for easy archival of single targets while the
# SpiderOakONE Application is running.
#
# Written by H.Raaf (c) 2017 / MIT LICENSE
#
# https://gist.github.com/oderwat/6b790effbf955300aaeaa76a462e6e2a
#
# This script is meant to be saved to ~/bin or /usr/local/bin as spiderarc
# Don't forget to "chmod +x ~/bin/spiderarc"
#
# Usage is: spiderarc <path for archival>
on run arg
# should work out of the box
set appname to "SpiderOakONE"
set apppath to "/Applications/SpiderOakONE.app/Contents/MacOS/SpiderOakONE"
if (count of arg) is 0
log "no archival location given"
return
end if
set fileType to (do shell script "file -b -i \"" & arg & "\"")
if fileType is not in { "directory" , "regular file" } then
log "archival location is no file or directory"
return
end if
if application appname is running
set wasRunning to true
log "Stopping SpiderOakONE..."
tell application appname to quit
repeat until application appname is not running
delay 1
end repeat
log "done"
else
set wasRunning to false
end if
log "Starting archival..."
do shell script apppath & " --redirect=/dev/tty --verbose --backup=\"" & arg & "\""
if wasRunning then
log "Restarting SpiderOakONE..."
tell application appname to launch
repeat until application appname is running
delay 1
end repeat
log "done"
end if
end run
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment