Hi everyone,
Before the update to the new DT, I could use the script “Export all Databases” without a problem. (I inserted a proper path as well.)
Now, after the DT update, the script disappeared, so I copied the one from DT3 into the DT.
But now, it seems that it doesn’t work anymore. There is no error; it just gets stuck in the “compress” process.
What can I do?
How large are your databases and what kind of databases (encrypted or not) do you use?
2 Databases:
- Encrypted, 2,5 GB
- Encrypted 100 MB
If I’m not mistaken, it gets stuck compressing the first one.
The source of the used script would be useful.
And what “proper path” did you use?
Here is the code from the script and the path.
-- Backup All Databases
-- Created by BLUEFROG/Jim Neumann on Weekday Month Day Year
-- Copyright 2023 DEVONtechnologies, LLC. All rights reserved.
(* Verifies, optimizes, and compresses all open databases as a backup.
Errors logged but proceed gracefully. I included an optional alert sound as we do have blind users too.
*)
use framework "Foundation"
use scripting additions
property theSound : a reference to current application's NSSound
property allowSound : true
property failureSound : "Ping"
property succeedSound : "Glass"
property backupDest : "~/Library/CloudStorage/OneDrive-Persönlich/Sonstiges/Backup/DEVONthink/"
global doBackups
on run
tell doBackups to run
end run
on performReminder()
tell doBackups to run
end performReminder
script doBackups
tell application id "DNtp"
activate
set od to AppleScript's text item delimiters
set allDBs to databases
set failureCount to 0
-- Using pure AS methods for date construction as an aid to users
set {year:y, month:m, day:d} to (current date)
set {m, d} to {my zeropad(m as integer), my zeropad(d)}
set AppleScript's text item delimiters to "-"
set currentDate to {y, m, d} as string -- Using ISO 8601 date
repeat with theDatabase in allDBs
(* If someone renames the database in the Finder, the displayed name will be different in Database Properties, so use the filename at the end of the database's path. *)
set dbPath to path of theDatabase
set AppleScript's text item delimiters to "/"
set dbNameWithExt to last text item of dbPath
set AppleScript's text item delimiters to "."
set dbName to (text items 1 thru -2 of dbNameWithExt) as string
set AppleScript's text item delimiters to od
set savePath to (backupDest & dbName & " " & currentDate & ".dtBase2.zip" as string)
-- Backup processes ---------------------------
show progress indicator (localized string ("Creating backup for: ")) & dbName steps 3
delay 1
with timeout of 3600 seconds
step progress indicator (localized string ("Verifying…"))
delay 1
if (verify database theDatabase) is not 0 then
set failureCount to my reportError(dbName, localized string ("Database is damaged."), failureCount)
else
step progress indicator (localized string ("Optimizing…"))
delay 1
if not (optimize database theDatabase) then
set failureCount to my reportError(dbName, localized string ("Optimization failed."), failureCount)
else
step progress indicator (localized string ("Compressing…"))
if not (compress database theDatabase to savePath) then
set failureCount to my reportError(dbName, localized string ("Backup failed."), failureCount)
end if
end if
end if
end timeout
delay 1
hide progress indicator
end repeat
log message (localized string ("Database backups done.")) info ((((count allDBs) - failureCount) as string) & (localized string (" succeeded. ")) & failureCount & (localized string (" failed.") as string))
if allowSound then (theSound's soundNamed:succeedSound)'s play()
end tell
end script
on zeropad(theNum)
return characters -1 thru -2 of ("0" & theNum) as string
end zeropad
on reportError(dbName, msg, failureCount)
if allowSound then (theSound's soundNamed:failureSound)'s play()
tell application id "DNtp" to log message dbName info msg
return (failureCount + 1)
end reportError```
The compress database
command throws an error in case of encrypted databases due to a wrong path extension. Version 4 retains the format of encrypted & audit-proof databases now, also when using FIle > Export > Database Archive…
Let me see if I understand it: Because it is an encrypted database, it won’t be possible to compress it anymore - independently via script or app.
So, what could I do instead?
The script you’re referring to is intended for unattended backups.
While the new compress database
supports encrypted and audit-proof databases, they both require providing the encryption key. This means you:
- Will be interrupted and required to provide the encryption key for each database of those types
- Need to store the encryption key in plain text directly in the script, an option most people would discourage as very insecure.
- Also, and importantly, adding an encryption key in the script is NOT validating against an existing key. It is setting the encryption key for the compressed copy of the database so a different key could easily be set. This means you could decompress and open the archived copy and have to enter a different encryption key to access it.
Thanks for your clarification. I guess that means:
- In contrast to using this script in DT3 with encrypted DB, it’s not possible anymore in DT4.
- Performing an automatic verification, compression, and export of all (including encrypted) DB is not possible.
- I have to do those steps manually.
Is this correct?
It’s still possible but either a revised script has to specify the password or ask the user to enter one. See for example ~/Library/Application Scripts/com.devon-technologies.think/Scripts/Menu/Export/Daily Backup Archives.scpt
.
But in the end an unencrypted export of an encrypted database like in version 3.x doesn’t really make sense (unless you take care of the exported archive on your own and ensure that it’s stored in a secure location).
As Criss mentioned, yes it’s possible with a modified script. But it would not be ideal with more than one database if any are encrypted.
Maybe not ideal but at least better than the unencrypted export by v3.