DB Backup v1.5.0.8 for KeePass 1.0.9 by Matyas Bene Contents 1. Preface 2. Installation 3. Configuration - Parameter descriptions - Command line parameters 4. Usage 5. Limitations ___________________________________________________________________________________ 1. Preface This plugin is based on the TestPlugin by Dominik Reichl. The main credit goes to him. I have just used the skelet and modified the body to do what I wanted from it. This plugin, as its name implies, backs up the database to predefined directories. ___________________________________________________________________________________ 2. Installation a) Simply copy the DB_Backup.dll to the directory of KeePass.exe. b) Start KeePass. c) Go to menu Extra/Plugin Manager d) Right click on DB_Backup.dll and select "Enable". Multiple languages - Additional step: If you would like DB_Backup to speak multiple languages (the same as KeePass), you should copy the appropriate language from the zip file (YOURLANGUAGE_DB_Backup.plng) also to the directory of KeePass.exe. If you can't find your desired language, I would like to encourage you to make a copy of English_DB_Backup.plng, rename it to YourDesiredLanguage_DB_Backup.plng and start translating the strings in it. After you finish, you can just put it into KeePass' directory. IMPORTANT: In order for the plugin to speak your language, KeePass has to be able to do it also. Therefore, In a successful setup, you'll see two two language files in KeePass' directory for the same language: YOURLANGUAGE.lng YOURLANGUAGE_DB_Backup.plng Happy translations. ___________________________________________________________________________________ 3. Configuration A GUI is available for the configuration. To reach the configuration dialog, please click on menus: Extras / DB Backup Plugin / Set Backup Destination There you'll be able to define up to 99 destinations. The procedure is that you write/paste/select the full path of the directory into the "Destination" field and hit "ADD". "Remove" deletes a destination from the list. A directory browser button has been added to ease this task. NOTE: Since version 1.0, Environmental variables in the destination are expanded to their respective values. !!! Thus if my username is "PlattFuss" then "D:\%USERNAME%\KeePassBackup" will be expanded to "D:\PlattFuss\KeePassBackup" ******************************************** All the configurations are stored in the KeePass.ini file (let it be wherever). Lets have a quick look on the keys used. The ONLY important parameter is being called "DB_Backup.Destination.1". This key should contain the path to the *directory* where you want to have your databases backed up. A trailing backslash is not needed, but will be handled if present. So the appropriate line in KeePass.ini will look like this: DB_Backup.Destination.1=C:\MyBackedUpDatabases or if your directory name contains spaces DB_Backup.Destination.1=C:\My Backed Up Databases Multiple destination in te ini file will look like this: DB_Backup.Destination.1=C:\My Backed Up Databases DB_Backup.Destination.2=D:\%USERNAME%\KeePassBackup DB_Backup.Destination.3=F:\USBBackup ... DB_Backup.Destination.45=Z:\%HOSTNAME%\DB Files and so on. The maximum number of destinations is 99. This is because of the limitation of the two digit number. If someone out there would want to have more, drop me a note and I will create a special edition of the plugin extra for him :-) Note that the number has to increase sequentially. If there will be a gap, the remaining destinations will be skipped. But you can forget this whole bullshit as a GUI is ready for this. ******************************************** NOTE: Starting with version 1.1 it is possible to define the parameters used by this plugin through the command line. Parameters entered through the command line override the settings in the ini file. The following table lists the parameters, their INI file key name, command line prefix and a short description: +-------------------------+---------------------+--------------------------------+ | .ini file key | CMD Line parameter | Description | +-------------------------+---------------------+--------------------------------+ | DB_Backup.Destination.N | -DB_Backup.dest: |Backup destination. N can be | | | |between 1 and 99. The cmd param | | | |can appear repeatedly. | +-------------------------+---------------------+--------------------------------+ | DB_Backup.ExtPrgPath | -db_backup.prog: | Program to start after backup | +-------------------------+---------------------+--------------------------------+ | DB_Backup.StartExtPrg | implicitly yes if |If 'True', the app. specified | | | db_backup.prog: |by ExtPrgPath will be executed | | | is set |Default: False | +-------------------------+---------------------+--------------------------------+ | DB_Backup.KeepXBackups | -db_backup.cnt: |Number of older backups to keep | | | |Default: 1 | +-------------------------+---------------------+--------------------------------+ | DB_Backup.ShowWindow | -db_backup.show: |If 'True' the window of the | | | |external program will be shown, | | | |otherwise the program will be | | | |started hidden, without a window| | | |Default: False | +-------------------------+---------------------+--------------------------------+ -DB_Backup.Dest:<destination> If the parameter value contains spaces, put the path in double quotes. You may define probably any number of such arguments, although I did not test more than two. It could happend the the length of the command line is somehow limited. Command line example: KeePass.exe -DB_Backup.Dest:"c:\Program Files\KeePass\" -DB_Backup.Dest:C:\Backup\%USERNAME%\ -db_backup.cnt:3 -db_backup.prog:"notepad.exe" -db_backup.show:1 IMPORTANT: The first parameter for the external program is always the full path of the backed up file. Thus in the above example, the program "notepad.exe" will be called several times and with the following arguments: notepad.exe c:\Program Files\KeePass\<BACKUP_FILE_NAME> notepad.exe C:\Backup\%USERNAME%\<BACKUP_FILE_NAME> ******************************************** Relative Paths: The plugins is able to handle relative paths (You will use something like: 'Backups' instead of a full path, like: 'M:\KeePassDB\Backups'), which comes handy if you want to store your database backups somewhere relative to the 'Current Working Directory'. This directory is usually the KeePass install dir, or the directory of the active database, or something totally different :) Since you are not able to forecast its actual value, two SEMI-environment variables have been introduced, which are working inside the plugin: %KEEPASSDIR% - Points always to the directory, from where KeePass was started. %DBDIR% - Points always to the directory of the actual database. Using this variables, you can set up relative paths like: %DBDIR%\Backups\SomeotherNestedDir\BackupSet1 %KEEPASSDIR%\OtherBackup\nesting2\BackupSet2 The advantages are hopefully clear for everyone. You don't have to investigate what is the actual "Current Working Directory" (this is really changing very often), you just use one of the above variables and the backup will be always created where you wanted it. No matter if your USB key is called E: or X: or T: on different system. You are free to use these variables in command line parameters, but you should keep in mind that %KEEPASSDIR% and %DBDIR% are SEMI-environmental variables, therefore echo %DBDIR%\Backups\SomeotherNestedDir\BackupSet1 will only write: \Backups\SomeotherNestedDir\BackupSet1 and sadly, this is, what KeePass would get. Therefore we have to write: echo %%DBDIR%%\Backups\SomeotherNestedDir\BackupSet1 which would result in: %DBDIR%\Backups\SomeotherNestedDir\BackupSet1 As you can see, unlike other environment variables (which are REAL and expandable by the shell itself), these have to be provided by DOUBLE PERCENT SIGNS (otherwise cmd.exe will expand it to nothing, as it is unaware of its value). A correct command-line for Keepass is hence: KeePass.exe -DB_Backup.dest:%APPDATA%\KeePass -DB_Backup.dest:%%DBDIR%%\Backups -db_backup.cnt:3 This is all from the configuration point of view. The rest can be handled from the menu ( enable / disable the automatic backups). ___________________________________________________________________________________ 4. Usage If the menu "Extras/DB Backup Plugin/Backups Enabled" is really enabled, the plugin will create a backup of your database whenever you call "Save Database" or "Save Database As.." either by clicking it on the toolbar, or by selecting this function through the menu. The backup files will be placed in the directory specified in KeePass.ini, in variable DB_Backup.Destination (see part 3. Configuration). The database files will be prefixed with: "Backup_of_", thus if the name of your database is "MyKeepassDB.kdb" then the backup will be called: "Backup_of_MyKeepassDB.kdb-0". If the number of backups to keep is set higher than 1, the previous file with index 0 will be renamed to Bac...
andrejf