Logbook Backup Cleaner

Logbook Backup Cleaner is a utility application to remove old HRD Logbook backup files.

HRDLogbook is a full featured logbook application for amateur radio operators. One of its' many features is to automatically create backup files in a specified folder. This feature works well, but over time the backup files accumulate. How quickly they accumulate depends on how frequently you set the application to create backups. This application will assist in controlling the accumulation of those backup files.

Logbook Backup Cleaner screen shot

I saw a Facebook post by Robin Moseley in the "Ham Radio Deluxe - Fan Page" group regarding using a batch file to clean up outdated HRD Logbook backup files. His script should work well for many users. However, I saw an opportunity to add some features to this batch file, and customize it for my specific usage. Unfortunately, my batch file programming skills (and Windows batch file capabilities) are limited. I considered using PowerShell and creating a new version of Robin's batch file since PowerShell is more than capable of handling the additions I had envisioned. However, not everybody has (or wants to install) PowerShell on their system, which limits the audience for this utility. So I chose to create a compiled executable using C# and also release the source code as an open source project on Github. The Github project is located at https://github.com/sdcohe/LogbookBackupCleaner/

The backup settings I use in HRD Logbook are Backup file/Save file in folder to save XML backups to a folder. In my case I chose to use a Dropbox folder, but Dropbox is not required. The other setting I use is the Add to archive setting which saves compressed backups to a single zip file. I tailored Logbook Backup Cleaner to these two options. I originally hadn't considered the Archives/Compress to folder option, but I have added the option for that scenario as well. If you specify the --folders option, the program will look for both xml and xip backup files in those folders whose name that matches the pattern "databasename backup data time". If you speciy the --zipfiles option, the program will treat the specified zip files as archives that contain xml backup files that follow the same naming convention as specified in the folders option.

Here are the command line options for LogbookBackupCleaner

Description:
  Clean up HRD Logbook backup files

Usage:
  LogbookBackupCleaner [options]

Options:
  -f, --folders <folders>                               A list of backup folders containing XML or ZIP backup files
  -z, --zipfiles <zipfiles>                             A list of zip archives each containing multiple XML backups
  -a, --age <age>                                       Age in days. Backups older than this will be purged
  -c, --count <count>                                   Count of files to retain. This option ensures that there will
                                                        always be some backups not purged regardless of their age.
  -q, --quiet                                           Don't display prompts to the console [default: False]
  -d, --debug <Debug|Information|None|Verbose|Warning>  Turn on debug logging. Order of severity is None, Warning,
                                                        Information, Debug, Verbose. [default: None]
  -t, --test                                            Test changes but don't actually delete any files [default:
                                                        False]
  --version                                             Show version information
  -?, -h, --help                                        Show help and usage information

                            

Some example usages are:

LogbookBackupCleaner -f c:\BackupFolder -a 10
This example will process all of the XML backup files in the folder c:\BackupFolder. Any backups older than 10 days will be deleted.

LogbookBackupCleaner -f c:\BackupFolder -c 3
This example will process all of the XML backup files in the folder c:\BackupFolder. All but the 3 most recent backup files will be deleted.

LogbookBackupCleaner -f c:\BackupFolder -a 10 -c 3
This example will process all of the XML backup files in the folder c:\BackupFolder. Any backups older than 10 days will be deleted. However, at least 3 backup files will be left, even if they exceed the 10 day age limit. This will prevent potentially deleting all the backups in that folder.

LogbookBackupCleaner -z c:\BackupArchive.zip -a 10 -c 3
This example will process all of the XML backup files in the zip archive c:\BackupArchive.zip. Any backups older than 10 days will be deleted. However, at least 3 backup files will be left, even if they exceed the 10 day age limit. This will prevent potentially deleting all the backups in that folder.

These are the command line options:

  • The folders option specifies the folder(s) containing xml backup files. You may specify more than one folder using -f folder1 folder2 folder3...
  • The zipfiles option specifies the zip file(s) containing xml backup files. You may specify more than one zip file using -f file1.zip file2.zip file3.zip...
  • The age option specifies the age in days of files you wish to retain. Any file older than the specified number of days is deleted. This option can be used in conjunction with the count option to make sure some files will be retained regardless of their age.
  • The count option specifies how many files will be kept. It will keep the most recent files. This option can also be used in conjunction with the age option. If there are fewer than count files in the folder or archive, then no files will be deleted.
  • The quiet option causes all routine prompts and messages coming from the program to be suppressed. Error messages will still be displayed.
  • The debug option is for use in debugging the program if things go wrong. Hopefully it won't be needed very often.
  • The test option prevents the program from actually deleting any files. This is useful for debugging or if you just want to see what the program will do without actually deleting any files.
  • The version option displays the version number of this program.
  • The help option displays the description, usage, and options information shown above.

Release History

Version Date Comments
1.0.0.0 28-Jan-2024 Initial release
1.0.1.0 29-Jan-2024 Added processing for zip archives
1.0.2.0 30-Jan-2024 Added processing for zip backup files

If you want to encourage me to continue developing software you can