An opensource Fle Backup manager with simple user interface and with all the essential functionalities for a home or regular office user. It contains two modes, first for folders and a second one for files.
Well, saying about the birth of this application, for me it started as a project for personal use and then kept maintaining and enhancing for the last two years. I use this in my home desktop and laptop to sync important data to my network drive. I also use this with Google Drive to automatically backup important files and folders. Once application copies the files to my Google Drive folder, it will be uploaded into cloud. You have a laptop or desktop with SSD then configure this app since SSDs crash on you without any warnings. This will save you from losing all your loved files one day at no cost. And of course, I added some unique functionalities to this application. See it by yourself.
Using the Application
Screenshot: Add Job Window-Folder Mode
Screenshot: Add Job Window-File Mode
Method 1: Just copy the build folder to the location you want and run from there.
Method 2: Use the installer setup file from $\FileManagerToolSetup\FileManagerToolSetup\Express\DVD-5\DiskImages\DISK1".
Optional: Once installation is done, go to the install location and modify FileManagerLibrary.dll.config settings "
UserContext" to which section you want. Refer to comments in config file for more detail.
Windows service will install during first startup of the application, which require administrator privileges to run. Separate services can be installed based on configuration specifications.
Due to service control behavior of application, it is recommended to have administrator privileges for those who manage the application.
I will also list some of the features included in the application.
- Folder Mode - Select a folder to take backup of the whole folder to another location. You can exclude subfolders if you do not want to take backup.
- Files Mode - Select file(s) to be backed up to a common location. Schedules include monthly, weekly, daily, and also an instant one where the files are backed up as soon as they are updated.
- There is an option to include backup only from a certain period in past. For my case, I want to take backup of a folder but do not want to backup files that created today, since I might delete those and do not need them to be backed up.
- There are three operation modes. Say you can use delete mode to delete files which are older than a specific date or delete the files when it grows beyond a specific size.
- Cleanup Destination option in folders mode will copy the files from source but it will keep the files in backup location until the specified days. Default is 0 which will delete the files from destination if they are missing in destination. This is available only in copy mode.
- You can have multiple version of files in files mode.
About the Code
I haven't focused on any specific framework or patterns during design of this application. However, you will be able to find many patterns here since, while designing they snap into place automatically for those have the patterns in mind.
Also it might not be a good idea to list out each and every class and methods here since it will make a mess and do more harm than good. The project is big enough and complex to explain it fully in an article. I will explain the code in top level for your primary understanding. If you want to have a deep dive, you are welcome to download and explore. Takeout any code as you like.
File Manager modules can be grouped as below:
- FileBase: Group of classes which performs the file system related operations of the application.
Deletefolders: Copies/deletes/moves all the folders and its contents to destination folder. This method contains handling for exceptions and wait on separate thread in case or errors like file locked for some time.
Class Files: FileOperations.cs, FileSystemOperations.cs
- FileWatcher: This module is designed around
FileSystemWatcher class and watches files for modifications. It is written to scale up for huge amount of files in one batch job like watch for files in C:\windows\system32\.
Class Files: FileWatcher.cs, FileWatcherManager.cs
- JobManagers: There are two type of jobs in the application. Interval based make use of
Threading.Timer and File change events based which make use of
Class Files: FileWatcherManager.cs, ScheduledJobManager.cs
- Serialization: This class takes care of saving the application data into binary files.
Class Files: FileWatcherManager.cs, Serializer.cs
- UIData: These classes hold all the UI data for the application and also leaf level methods for serialization of data.
Class Files: BackupJobData.cs, FileJobSettings.cs, FolderJobSettings.cs,
- WindowsService: This section handles the Windows service related functionalities. That includes API calls for changing Windows Service mode, Start and stop a Windows service and install and uninstall Windows service.
Class Files: ServiceStartupTypeHelper.cs, WindowsServiceHelper.cs, WindowsServiceInstallHelper.cs
- Config: The backup can be performed from the application in two ways, from main Dashboard and Windows Service. To make best use to code and minimize maintenance, I had to move all the business logic to a single assembly and then consume the library from both. This added technical difficulties of getting the application configuration, since I need to keep separate copies of application configurations for Windows service and desktop module. The resolution was to create a custom configuration section, which proved to be a much better approach in maintenance perspective.
Important Class Files: AppSettings.cs, FileManagerLibraryUserSettings.cs
- Jobcontroller: This is the module which is responsible for operations for each job.
Class Files: JobController.cs
- UI - BackupSetManager: This UI module handles the adding and editing of jobs. There are two modes of jobs and each mode is having separate controllers which inherits from a base controller.
Class Files: BackupJobManagerControllerBase.cs, FileManagerController.cs, FolderManagerController.cs, BackupJobManagerView.cs
- UI - Dashboard: This is the startup and main user interface of the application.
Class Files: DashBoard.cs
- You might see a WCF version of this where I am planning to run the service on a remote machine. Think this might be handy in case of office environments.
- Planning to convert it to WPF, but require lot more time on that....so I kept it for another day...
- Move the binary save files to XML to enable manual editing and better portability.
- 22/Jan/2015: Original version. Please leave me comments on bugs. I will fix those as I get free time, based on criticality