A command-line backup utility that uses rsync to synchronize folders or entire disks on Linux systems. The C++ program (backup_scripts_2.cpp) asks the user for source and destination paths, then executes rsync -av --delete to perform the synchronization.
--delete option will remove files from the destination that are not present in the source.
- Simple CLI interface written in C++
- Uses
rsyncfor reliable and efficient synchronization - Two modes: copy a specific folder or sync an entire disk
- Support for paths with spaces (quoted rsync commands)
- Shows which paths are being copied in the output
- Linux (or any system with
rsyncinstalled) rsyncinstalledg++to compile the C++ program- (Optional) Python3 +
pyfigletlibrary for ASCII art header
sudo apt update
sudo apt install -y rsync g++ python3-pip
pip3 install pyfigletsudo dnf update
sudo dnf install -y rsync g++ python3-pip
pip3 install pyfigletOpen the file backup_scripts_2.cpp and replace the default paths with your actual paths.
Line 20 - Option 1 (Copy a single folder):
system("rsync -av --delete /your/source/path/ /your/destination/path/");Replace /your/source/path/ and /your/destination/path/ with your actual paths (e.g., /media/user/HDD/documents/ and /media/user/SSD/backup/documents/).
Line 30 - Option 2 (Sync entire disk):
system("rsync -av --delete /your/source/path/ /your/destination/path/");Replace /your/source/path/ and /your/destination/path/ with your actual disk or partition paths (e.g., /mnt/source_disk/ and /mnt/destination_disk/).
g++ -o backup_scripts_2 backup_scripts_2.cpp./backup_scripts_2Follow the prompts to select the mode and enter your source and destination paths.
- Choose option 1 to copy a single folder, or option 2 to sync an entire disk
- Enter your source path (e.g.,
/media/user/HDD/documents/) - Enter your destination path (e.g.,
/media/user/SSD/backup/documents/) - Confirm and wait for the synchronization to complete
The program uses --delete with rsync by default. This means files that exist in the destination but not in the source will be deleted. Double-check your source and destination paths before running to avoid accidental data loss.
If you prefer to keep files in the destination, remove the --delete option from the command in backup_scripts_2.cpp.
- "rsync: command not found": install rsync
- Permission denied: run with appropriate permissions (use
sudoif needed) - Path not found: verify your source/destination paths and that devices are mounted
- Compilation errors: ensure
g++is installed and up to date
backup_scripts/
├── backup_scripts_2.cpp # C++ backend program
├── README.md # This file
└── LICENSE # GPLv3 License
This project is licensed under GPLv3.