EasySave
CESI project · C#, .NET, Avalonia
A C# backup tool for a fictional software company, delivered one version at a time, with a desktop app, a terminal interface and file encryption.
For this CESI project, we played the development team at ProSoft, a software company made up for the occasion. ProSoft wanted a backup tool, and its requests came in versions. The first one had to be a plain console app. The second added a graphical interface, and the third brought parallel jobs, file encryption and sending logs to a server.
There were four of us. I set up the project structure and wrote both backup modes, full and differential. I also handled all of the logging, the priority files, the translation into five languages and continuous integration.
One version after another
The first version only had a console interface, and all the code lived in a single project. When the second version asked for a graphical interface, I moved the backup logic into its own project, EasySave.Core, and the console app became EasySave.CLI. The graphical interface plugged into the same core, so both interfaces run exactly the same backup code, and a fix in the core reaches both.
For the graphical interface, we went with Avalonia rather than WPF, because WPF only runs on Windows and we wanted the app to work on Linux and macOS too.
Logging
Every copied file, every encrypted file and every error produces a log line. We started with JSON, then ProSoft asked for XML as an option. So I put each format in its own class, and the logger uses whichever one matches the user’s setting. The logger is a separate library, EasyLog, which doesn’t depend on the rest of EasySave.
With the third version, logs also had to be sent to a central server. I wrote that server, EasyLog.Server, which receives logs over TCP and writes them to disk, and put it in a Docker container. Users can keep their logs locally, send them to the server, or both.
Since several backups now run at the same time, several threads write logs at once. I guarded the writes with a lock that lets many reads through in parallel but only one write, so two lines never get mixed up in the same file.
Priority files
In the third version, users can say which file extensions matter most to them, like .pdf or .docx. As long as a priority file is waiting to be copied, in any running backup, the other files wait. If a backup gets cut off after five minutes, the important documents are already copied.
There’s also a limit for large files. Above a configurable size, they go through one at a time, so a backup full of videos doesn’t hog the bandwidth while the others wait. And if a business application chosen by the user is open, every backup pauses and picks up again when it closes.
Encryption
Encryption is done by CryptoSoft, a small separate tool that EasySave runs for each file. I didn’t write it myself. The risk was that any program on the machine could call it to encrypt anything. To prevent that, EasySave signs the time of the call with an RSA key, and CryptoSoft rejects any call whose signature isn’t valid or that’s more than two seconds old. Only one CryptoSoft runs on the machine at a time, and other requests wait their turn.
Shipping
I set up two GitHub Actions workflows. The first builds the project and runs the tests on every pull request, and we couldn’t merge until they passed. The second runs when we push a version tag. It goes through the same checks, then publishes binaries for Windows, Linux and macOS, on x64 and ARM, in a GitHub release. Each version handed to ProSoft matches a tag and a set of tested binaries.
Looking back
I wouldn’t pick Avalonia again. It does the job of running on all three systems, but we struggled to get a pleasant interface out of it, and the result still looks rather dated. If I did the project again, I’d try a more recent C# UI framework, even if it meant spending a bit of time at the start comparing options.
at a glance
- ContextCESI software engineering project
- RoleDeveloper
- TeamFour people, four weeks
- StackC#, .NET 10, Avalonia, xUnit, Docker
- DeliveryWindows, Linux and macOS binaries published with GitHub Actions
- LinksView code