π Building GXBackup: A Smart, Load-Aware Linux Backup Utility in C++17 and Qt 6
When working on Linux desktops or development workstations, backups are essential. However, many existing GUI backup utilities suffer from common drawbacks:
- They are heavy Electron wrappers that consume hundreds of megabytes of RAM.
- They hog system resources during background backup tasks, causing stuttering while compiling code or rendering assets.
- They lack granular control over resource usage and desktop integration.
To solve this, I created GXBackup β a fast, lightweight, native C++17 and Qt 6/Qt 5 application for Linux. It combines the bulletproof reliability of rsync with a modern UI, system tray integration, and smart CPU/load-aware auto-pausing.
Here is an overview of how GXBackup works, its key features, and some of the technical design decisions behind it.
π Key Features at a Glance
-
πΈ Time Machine Style Snapshots: Uses
rsync's--link-destoption to create incremental point-in-time snapshots using hardlinks, saving significant disk space. -
β‘ Smart Load Throttling: Monitors
/proc/statand/proc/loadavgin real time. If CPU usage or load average exceeds configured thresholds, GXBackup automatically pauses the backup job and resumes it once the system cools down. - β° Automated Scheduling & Catch-Up: Set daily or weekly backup schedules. If your machine was powered off during a scheduled run, GXBackup detects the missed run at boot and executes a "catch-up" backup automatically.
- π System Tray & Desktop Integration: Operates quietly in the background with minimal memory footprint and native notification support.
- π Dynamic Runtime i18n: Ships in English by default with dynamic runtime language switching (e.g., Japanese/English) without requiring an app restart.
π Tech Stack & Architecture
- Language: C++17
-
Framework: Qt 6 / Qt 5 (
Core,Gui,Widgets,Concurrent) -
Backend Engine:
rsync - Build System: CMake (3.16+)
Project Structure
GXBackup/
βββ CMakeLists.txt # Build configuration
βββ resources/ # Icons & embedded Qt resources (.qrc)
βββ translations/ # Translation files (.ts / .qm)
βββ src/
βββ main.cpp # Entry point & CLI argument parsing
βββ core/ # Core logic & backend
β βββ AutostartManager.cpp # XDG desktop autostart manager
β βββ BackupController.cpp # Backup workflow coordinator
β βββ HistoryManager.cpp # Execution history persistence
β βββ LanguageManager.cpp # Dynamic i18n & QTranslator manager
β βββ ProfileManager.cpp # Profile configuration (JSON)
β βββ RsyncProcess.cpp # rsync process lifecycle & progress parser
β βββ ScheduleManager.cpp # Cron-like timer & missed run detector
β βββ SystemMonitor.cpp # Real-time /proc resource reader
βββ ui/ # Qt GUI & dialogs
βββ HistoryDialog.cpp # History table view
βββ LogViewer.cpp # Console log output window
βββ MainWindow.cpp # Main dashboard & tray icon
βββ ProfileDialog.cpp # Profile configuration editor
π‘ Deep-Dive: What Makes GXBackup Unique?
1. Smart Resource Throttling (SystemMonitor)
One of the biggest pain points of background backups on developer machines is resource contention. If rsync starts indexing thousands of files while you are running cmake --build or docker build, your PC can lock up.
GXBackup addresses this by inspecting system metrics directly from /proc:
// Reading CPU & Load Average from Linux pseudo-filesystems
void SystemMonitor::checkMetrics()
{
double cpuUsage = readCpuUsagePercent();
double loadAvg = readLoadAverage1Min();
emit metricsUpdated(cpuUsage, loadAvg);
bool highLoad = (cpuUsage >= m_cpuThreshold) || (loadAvg >= m_loadAvgThreshold);
if (highLoad != m_isHighLoadState) {
m_isHighLoadState = highLoad;
emit loadStateChanged(m_isHighLoadState);
}
}
When high load is detected, BackupController intercepts the event and signals RsyncProcess to pause execution, ensuring your desktop stays responsive.
2. Native rsync Execution & Real-Time Progress Parsing
Rather than wrapping rsync blindly, GXBackup launches rsync asynchronously via QProcess and parses its output stream (--progress format) in real time to calculate:
- Transfer percentage
- Current transfer speed (
MB/s) - Transferred data size
- Estimated time remaining (
ETA)
void RsyncProcess::parseProgress(const QString &line)
{
// Regular expression parsing of rsync --progress output lines:
// " 1,234,567 45% 12.34MB/s 0:00:15"
static QRegularExpression re(R"(\s*([\d,]+)\s+(\d+)%\s+([\d\.]+\w+/s)\s+([\d:]+))");
QRegularExpressionMatch match = re.match(line);
if (match.hasMatch()) {
int percent = match.captured(2).toInt();
QString speed = match.captured(3);
QString transferred = formatBytes(match.captured(1).remove(',').toULongLong());
QString eta = match.captured(4);
emit progressUpdated(percent, speed, transferred, eta);
}
}
3. Dynamic i18n & Instant Language Switcher
In Qt applications, switching languages usually requires restarting the app. GXBackup uses a custom LanguageManager singleton that loads .qm binary translation files from Qt's resource system (:/translations/gxbackup_ja.qm) and broadcasts dynamic QEvent::LanguageChange events.
All UI windows override changeEvent:
void MainWindow::changeEvent(QEvent *event)
{
if (event->type() == QEvent::LanguageChange) {
retranslateUi();
}
QMainWindow::changeEvent(event);
}
This allows users to switch between English and Japanese on the fly from the Settings -> Language menu with zero restart downtime!
π» Getting Started
Prerequisites
For Ubuntu / Debian:
sudo apt update
sudo apt install build-essential cmake qt6-base-dev rsync
Build & Run
# Clone repository
git clone https://github.com/amekusa03/GXBackup.git
cd GXBackup
# Build project
mkdir build && cd build
cmake ..
make -j$(nproc)
# Run GUI
./GXBackup
π₯ Open Source & Feedback
GXBackup is open source under the MIT License.
- π GitHub Repository: github.com/amekusa03/GXBackup
- π Issues & Feature Requests: Contributions and feedback are welcome!
If you are looking for a fast, responsive backup tool for your Linux desktop or home server, give GXBackup a try!
Tags: #linux #cpp #qt #opensource
Top comments (0)