Here is how I do it … all in addition to routine backups with TimeMachine, rsync copies of this backups folder and others to an attached USB drive which itself is included in the BackBlaze backup.
I have this Apple script, based on (I think) from a Script provided by DEVONthink.
use AppleScript version "2.4" -- Yosemite (10.10) or later
use scripting additions
tell application "DEVONthink 3"
set theDatabases to every database
show progress indicator "Running Backup" steps (count of theDatabases)
repeat with thisDatabase in theDatabases
set this_database to thisDatabase
step progress indicator (name of this_database as string)
set this_date to do shell script "date +%Y-%m-%d-%H-%M-%S"
set this_path to path of this_database
set {od, AppleScript's text item delimiters} to {AppleScript's text item delimiters, "/"}
set this_name to the last text item of this_path
set AppleScript's text item delimiters to ""
if this_name ends with ".dtBase2" then set this_name to (characters 1 thru -9 of this_name) as string
set this_archive to "~/Backups/DEVONthink_Backups/" & this_name & " " & this_date & ".dtBase2.zip"
set AppleScript's text item delimiters to od
with timeout of 1200 seconds
set thisMsg to "Verified: " & the name of thisDatabase & " with result "
set thisResultV to verify database this_database
set thisLog to log message (thisMsg & thisResultV & " errors and/or missing files")
if thisResultV = 0 then
set thisMsg to "Optimized: " & the name of thisDatabase & " with result "
set thisResultO to optimize database this_database
if not thisResultO then
set thisLog to log message (thisMsg & " Optimization of database failed.")
else
set thisLog to log message (thisMsg & " Optimization of database success.")
end if
if thisResultO then
set thisMsg to "Zipped: " & the name of thisDatabase & " with result "
set thisResultC to (compress database this_database to this_archive)
if not thisResultC then
set thisLog to log message (thisMsg & " zipped of database failed.")
else
set thisLog to log message (thisMsg & " zipped of database success.")
end if
end if
end if
end timeout
end repeat
hide progress indicator
display notification "DT backup finished."
end tell
This Apple script called by a bash command file i keep in ~\cmd folder. I have this command so that on a whim, I can just issue the command to take a backup then and there.
/usr/bin/osascript "/Users/rmschne/Library/Mobile Documents/com~apple~ScriptEditor2/Documents/DEVONthink Backup.scpt"
This command file is scheduled in crontab (standard and essential part of MacOS available to users also) to run three times a week at night when the machine is turned on and all my active databases are open in DEVONthink. I use “lingon x” for easy manipulation of cron’s crontab file. Or see crontab’s man file for details on how to schedule something.
The only manual intervention (I have a reminder in Things) to go clear out the excessive older backups from the files in ~\backups\devonthink_backups" folder. I haven’t yet figured out how to delete all but the last two files of a particular set. Will in due course.
An improvement might be to look for all DEVONthink databases, open, and then backup, but I figure if not open, then not important.
The benefit of these zip files in ~\backups on local disk is that they are backed up by the backup regime I mention at the top. Perhaps over the top, but there you go.
I’m sure the Apple script gurus here can improve this!
edit: Caveat emptor
and just thought of a way to schedule deletion of unwanted zip files. will do that tomorrow when fresh.