Lightweight, dependency‑free backup helper for Linux and other POSIX systems. It mirrors a source directory into a destination directory using hard links by default, so repeated backups reuse existing disk blocks instead of copying data. You can switch to plain file copies, preserve symlinks, or dry‑run to see what would change.
- Hard‑link based mirroring for fast, space‑efficient backups
- Optional byte‑for‑byte copy mode
- Verbose logging and dry‑run for safe previews
- Choice to recreate symlinks or follow them
Requires a C compiler with POSIX headers (tested with gcc and clang).
gcc -std=c11 -Wall -Wextra -O2 backup.c -o backup-toolor simply:
makeRun the shell-based integration suite:
make test./backup-tool [options] <source_directory> <backup_directory>Options:
-vverbose output-ndry run (no filesystem writes)-m {link|copy}choose how regular files are duplicated (default:link)-Lfollow symlinks instead of recreating them-hshow help--versionprint version and exit
Examples:
# Fast, space‑efficient snapshot using hard links
./backup-tool -v ~/Projects/myapp ~/Backups/myapp-$(date +%Y%m%d)
# Preview the actions without touching the disk
./backup-tool -vn src/ build/backup-preview
# Force byte‑for‑byte copies and follow symlinks
./backup-tool -m copy -L data/ /mnt/usb/data-backup- The destination path must not already exist; it will be created with the same permissions as the source root.
- Special files other than regular files, directories, and symlinks are skipped.
- Works best on filesystems that support hard links (e.g., ext4, xfs, btrfs).
MIT