Click here to Skip to main content
65,938 articles
CodeProject is changing. Read more.
Articles / web / HTML

A Lightweight File Backup Manager

5.00/5 (8 votes)
24 Jan 2015CPOL6 min read 39.6K   2.4K  
A file backup manager with simple user interface and all the essential functionalities.

Introduction

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.

Background

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: Homepage

Image 1

Screenshot: Add Job Window-Folder Mode

Image 2

Screenshot: Add Job Window-File Mode

Image 3

Installation

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.

Application Features

I will also list some of the features included in the application.

  1. 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.
  2. 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.
  3. 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.
  4. 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.
  5. 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.
  6. 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:

  1. FileBase: Group of classes which performs the file system related operations of the application.
    CopyFolders/MoveFolders/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
  2. 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
  3. 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 Filewatcher.
    Class Files: FileWatcherManager.cs, ScheduledJobManager.cs
  4. Serialization: This class takes care of saving the application data into binary files.
    Class Files: FileWatcherManager.cs, Serializer.cs
  5. 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, LastRunStatus, UIDataBase.cs
  6. 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
  7. 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
  8. Jobcontroller: This is the module which is responsible for operations for each job.
    Class Files: JobController.cs
  9. 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
  10. UI - Dashboard: This is the startup and main user interface of the application.
    Class Files: DashBoard.cs

Future Expectations

  1. 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.
  2. Planning to convert it to WPF, but require lot more time on that....so I kept it for another day...
  3. Move the binary save files to XML to enable manual editing and better portability.

History

  • 22/Jan/2015: Original version. Please leave me comments on bugs. I will fix those as I get free time, based on criticality

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)