Backup all open databases

-- Daily backup archive - all open databases
-- Created by Christian Grunenberg on Mon Jun 22 2009.
-- Copyright (c) 2009-2022. All rights reserved.
-- addition for all open databases by coolgoose85
-- https://discourse.devontechnologies.com/t/backup-all-open-databases/50932
-- Modifications courtesy of chrillek's advice: https://discourse.devontechnologies.com/t/backup-all-open-databases/50932/12

tell application id "DNtp"
	
	set this_date to do shell script "date +%Y-%m-%d-%H-%M-%S"
	set {od, AppleScript's text item delimiters} to {AppleScript's text item delimiters, "/"}
	set all_databases to every database
	
	repeat with this_database in all_databases
		try
			set this_path to path of this_database
			set this_name to the last text item of this_path
			if this_name ends with ".dtBase2" then set this_name to (characters 1 thru -9 of this_name) as string
			set this_archive to "/Volumes/YourBackupDriveName/Backup/" & this_name & " " & this_date & ".dtBase2.zip" -- was ˜Backup before, which created a folder under documents.
			
			show progress indicator "Daily Backup Archive of " & this_archive steps 3
			
			with timeout of 3600 seconds
				step progress indicator "Verifying database " & this_name & "..."
				if (verify database this_database) is not 0 then error "Database " & this_name & " is damaged."
				
				step progress indicator "Optimizing database " & this_name & "..."
				if not (optimize database this_database) then error "Optimization of database  " & this_name & "failed."
				
				step progress indicator "Zipping database " & this_name & "..."
				if not (compress database this_database to this_archive) then error "Backup  of database " & this_name & "failed."
			end timeout
			
			hide progress indicator
		on error error_message number error_number
			hide progress indicator
			if the error_number is not -128 then log message "DEVONthink:" & error_message
		end try
	end repeat
	
	set AppleScript's text item delimiters to od
end tell

Thanks for all of the tips.
I think I got everything but please if anybody sees a comment I missed or something I did wrong, correct it or let me know and I’ll correct it. I put the web links in the comments so that if anybody copies the script, they know where they got it and where they can go back to reference it.

I also changed the thisDatabase to this_database to stick with snake case convention.
And I changed the : to - in the time generation.

I did go through privacy parameters, but I think I’ve granted all the access that DEVONthink 3 requests in System Parameters, but I still have the error in my script. It’s an error that acts like a warning because the name is generated just fine. So perhaps I will see if there is a list of Privacy Parameters and make a visual guide to the System Parameters window. Wish all developers would make these parameter windows expandable and searchable with filters. Seems more logical to me if I could just type DEVONthink and then be shown all the settings related and check the boxes…