Automatic folder backup with real-time updates, written in low-level C.
Backup Manager is a low-level Linux backup system written in pure C.
It provides real-time directory mirroring using filesystem event monitoring, process isolation, and iterative directory traversal.
The project focuses on correctness, robustness, and system-level mechanisms, rather than high-level abstractions.
| Feature | Description |
|---|---|
| ✅ Real-time backup | Automatically synchronizes changes using Linux inotify |
| ✅ Full directory mirroring | Source and target directories are kept structurally identical |
| ✅ Iterative traversal | All subdirectories are processed without recursive function calls |
| ✅ Process isolation | Each backup runs in its own child process |
| ✅ Signal handling | Clean shutdown using POSIX signals |
| ✅ Safe symlink handling | Symbolic links are preserved and rewritten correctly |
| ✅ Robust memory management | Explicit allocation control with clear ownership and cleanup |
| ✅ POSIX-compliant | Uses standard UNIX system calls only |
- The main process starts an interactive CLI.
- When
addis called, the program forks a child process for the backup task. - The child process:
- Performs an initial full synchronization (
sync_mirror) - Registers all directories with
inotify - Waits for filesystem events
- Performs an initial full synchronization (
- On any detected event, a safe full resynchronization is performed.
- The parent process tracks active backups and controls them via signals.
sop-backup.c— main program, CLI, signal handlingkopia_operacje.c— backup lifecycle operations (add,end,restore)proces_potomny.c— child worker logic andinotifyhandlingzarzadzanie.c— directory mirroring and cleanup logicpomocnicze.c— utilities (paths, parsing, filesystem helpers)
Instead of applying incremental diffs, the system:
- Iteratively traverses the entire source tree
- Copies only files that are newer or missing
- Removes files from the target that no longer exist in the source
This approach is:
- Safer against missed
inotifyevents - Easier to reason about correctness
- Efficient enough for typical user directories
add <source> <target1> [target2 ...]
end <source> <target>
list
restore <source> <backup>
exit
add "/home/user/Documents" "/mnt/backup/Documents"
- C (GNU11)
- POSIX system calls
fork,waitpid, signalsinotifyopendir,readdir,lstat- Manual memory management
- Demonstrate low-level filesystem programming
- Practice safe process management
- Implement real-time synchronization without external libraries
- Ensure deterministic and debuggable behavior
MIT License