Backup Specific database

I would like to backup a specific database. The Daily backup archive lets you do the current database, “set this_database to current database”. Does anyone know how to change it to backup a specific database?

Why don’t you just select the desired database and create the archive?

1 Like

It is a work computer and the person who uses it does not come into the office. They can’t run it. I have tried many times to show them. I can have the script run at a certain time. I just need the specific database name to do it.

This is the way I handled it:

I added a Reminder to the database I want to save (zipped) weekly and have it execute this script:

on performReminder(theRecord)
	
	tell application id "DNtp"
		try
			if not (exists current database) then error "No database is open."
			set this_database to database "Your Database"
			
			set this_date to do shell script "date +%Y-%m-%d"
			
			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/" & this_name & " " & this_date & ".dtBase2.zip"
			set AppleScript's text item delimiters to od
			
			show progress indicator this_name & " weekly ZIP backup" steps 3
			
			with timeout of 1200 seconds
				step progress indicator "Verifying..."
				if (verify database this_database) is not 0 then error "Database is damaged."
				
				step progress indicator "Optimizing..."
				if not (optimize database this_database) then error "Optimization of database failed."
				
				step progress indicator "Zipping..."
				if not (compress database this_database to this_archive) then error "Backup failed."
			end timeout
			
			hide progress indicator
		on error error_message number error_number
			hide progress indicator
			if the error_number is not -128 then display alert "DEVONthink" message error_message as warning
		end try
	end tell
	
end performReminder

Admittedly, I had this script copied & pasted together more or less hastily. But it works!

2 Likes

Thank you. This is what I am looking for.