An Application That Backs Up Files To Cloud Storage Using Akka.NET
This application backs up zipped folders from a PC to a cloud storage location such as OneDrive and also backs up a log of operations. I created a version of this using conventional .NET code and then, as a learning exercise, I re-implemented it using Akka.NET.
I identify two types of folders - Regular folders and Visual Studio Project folders.
For the former I zip and then encrypt them before backing up (encryption technique omitted).
For the latter I create a zip with the bin and obj folders omitted and then back them up.
The input is from a text file, SourceFolderPaths.txt, that contains a list of fully qualified paths to folders that require backing up.
- Akka.NET - A toolkit and runtime for building highly concurrent, distributed, and fault tolerant event-driven applications on .NET & Mono, based on the Actor Model of concurrency.
- NLog - A free logging platform for .NET, Silverlight and Windows Phone with rich log routing and management capabilities.
- ZipDiff - A utility for comparing the contents of 2 different zip files.
- System.IO.Abstractions - A library for testing System.IO.
- CloudBackupActor - Manages cloud backup from start to finish. Creates the other actors. Receives StartMessage, IncrementFolderCountMessage and StopMessage. Sends ZipMessage and BackupLogFilesMessage.
- ZipActor - Manages zip operations on folders. Receives ZipMessage. Sends BackupMessage, IncrementFolderCountMessage, FolderChangesMessage and "no changes" message.
- BackupActor - Backs up zip archive and log files to cloud storage. Receives BackupMessage and BackupLogFilesMessage. Sends IncrementFolderCountMessage and StopMessage.
- BackupStatisticsActor - Logs statistics showing changes to folders. Receives FolderChangesMessage and "no changes" message.
- StartMessage - Instruction to start actor processing.
- StartedMessage - Indicates actor processing has started.
- ZipMessage - Instruction to perform a zip operation.
- IncrementFolderCountMessage - Instruction to increment the folder count after processing a folder with a specific kind of zip operation.
- FolderCountIncrementedMessage - Indicates folder count has incremented, i.e., a folder has been processed.
- FolderChangesMessage - Represents changes to files in a folder.
- BackupMessage - Instruction for backing up a zip archive to cloud storage.
- BackupLogFilesMessage - Instruction for backing up log files to cloud storage.
- StopMessage - Instruction to stop actor processing.
-
Actor routing using a RoundRobinPool strategy.
-
Actor supervision using a OneForOne strategy.
-
Predicate message filters (receiving a message from an actor and handling it differently based on a condition).
-
Actor logging.
- Invalid input folder path(s) - action: skip error and resume processing next folder.
- Locked Word document (i.e., Word is open on a document so zip operation fails for that folder) - action: skip error and resume processing next folder.
- Invalid backup folder path - action: stop and shut down cleanly, as nothing can be backed up.
- Empty source folders file - action: stop and shut down cleanly since there's nothing to do.
See also What is an Actor? and Akka.NET cheat sheet.