ddn-lib-dar 2.8.1
libdar binding to D
To use this package, run the following command in your project's root directory:
Manual usage
Put the following dependency into your project's dependences section:
ddn-lib-dar
D language bindings for libdar — the Disk ARchive library.
ddn-lib-dar provides comprehensive D bindings to libdar, enabling D developers to create,
read, and manipulate DAR archives with an idiomatic, type-safe API. The library offers both
low-level bindings (ddn.lib.dar) for direct control and a high-level wrapper (ddn.wrp.dar)
with RAII resource management, range-based iteration, and fluent option builders.
libdar
DAR (Disk ARchive) is a powerful, feature-rich backup and archiving tool created by Denis Corbin. Unlike tar, DAR supports:
- Differential and incremental backups — only store changed files
- Strong encryption — AES-256, Blowfish, Twofish, Serpent, Camellia
- Compression — gzip, bzip2, xz, lz4, zstd
- Slicing — split archives across multiple volumes/media
- Extended attributes and ACLs — full filesystem metadata preservation
- On-the-fly integrity checking — detect corruption early
- Catalogue isolation — extract archive metadata for fast browsing
The upstream DAR project is hosted at:
- Git Repository: https://github.com/Edrusb/DAR
- Website: http://dar.linux.free.fr
Installation
Prerequisites
Install libdar development headers on your system:
# Fedora/RHEL
sudo dnf install libdar libdar-devel
# Debian/Ubuntu
sudo apt install libdar64-dev
# Arch Linux
sudo pacman -S dar
However, for anything more serious than "hello DAR world" you would need some extra libraries. This is what I typically do on Fedora and derivatives:
sudo dnf intall libargon2-devel gpgme-devel librsync-devel libattr-devel rhash-devel \
libgcrypt-devel libgpg-error-devel
Using DUB
Add ddn-lib-dar as a dependency in your dub.sdl:
name "my-backup-app"
description "My backup application"
dependency "ddn-lib-dar" version="~>1.0"
Or in dub.json:
{
"name": "my-backup-app",
"dependencies": {
"ddn-lib-dar": "~>1.0"
}
}
Demo
Here is a minimal example demonstrating archive creation, listing, and extraction using
the high-level ddn.wrp.dar API. The complete source is available in
demo/ddn/wrp/dar_intro.d.
Project Setup (dub.sdl)
name "dar-demo"
description "DAR archive demo"
dependency "ddn-lib-dar" version="~>1.0"
targetType "executable"
targetName "dar-demo"
Example Code
import ddn.wrp.dar;
import std.stdio;
void main()
{
// 1. Create an archive with compression
auto createOptions = createOpts()
.withCompression(DarCompression.GZIP)
.withCompressionLevel(6)
.withAllowOverwrite(true)
.toLow();
auto archive = Archive.create(
"/home/user/documents", // Source directory
"/backups", // Output directory
"docs_backup", // Archive base name
"dar", // Extension
createOptions
);
if (archive.isValid)
writeln("Archive created successfully!");
archive.close();
// 2. Open and list archive contents
auto readOptions = readOpts()
.withExtension("dar")
.toLow();
auto arc = Archive.open("/backups", "docs_backup", "dar", readOptions);
foreach (entry; arc.list())
{
writefln(" %s: %s (%d bytes)",
entry.entryType == DarEntryType.FILE ? "FILE" : "DIR",
entry.name,
entry.size);
}
// 3. Extract the archive
arc.extract("/home/user/restored");
// 4. Test archive integrity
auto result = arc.test();
if (result.errors == 0)
writefln("Archive OK: %d files verified", result.filesChecked);
}
Features
The following table lists libdar features and their implementation status in ddn-lib-dar:
| Feature | Implemented | Notes |
|---|---|---|
| Archive creation (full backup) | Yes | |
| Archive reading/opening | Yes | |
| Archive listing | Yes | Range-based iteration |
| Archive extraction | Yes | With filtering support |
| Archive testing (integrity) | Yes | |
| Differential/incremental backups | Yes | Via reference archive |
| Archive merging | Yes | |
| Archive comparison (diff) | Yes | |
| Catalogue isolation | Yes | |
| Archive repair | Yes | |
| Compression (gzip, bzip2, xz, lz4, zstd) | Yes | All algorithms supported |
| Encryption (AES, Blowfish, Twofish, etc.) | Yes | All algorithms supported |
| Slicing (multi-volume archives) | Yes | |
| Delta/binary diff (librsync) | Yes | If libdar built with librsync |
| Extended attributes (EA) | Yes | |
| Filesystem-specific attributes (FSA) | Yes | |
| ACL preservation | Yes | |
| Sparse file handling | Yes | |
| Hard link preservation | Yes | |
| Symlink handling | Yes | |
| Include/exclude filters | Yes | Glob and regex patterns |
| Path-based filtering | Yes | |
| dar_manager database | Yes | Full API |
| dar_xform (re-slicing) | Yes | Path, pipe, and FD modes |
| dar_slave (remote serving) | Yes | Pipe and FD modes |
| User interaction callbacks | Yes | Full class support |
| Progress callbacks | Yes | |
| Compile-time feature detection | Yes | |
| Sequential read mode | Yes | For tape/streaming |
| Hash/checksum sidecar files | Yes | MD5, SHA1, SHA256, SHA512 |
| Secure password handling | Yes | SecurePassword class |
| Custom overwrite policies | Yes | |
| Empty directory handling | Yes | |
| Unix socket handling | Yes | |
| Remote repositories (FTP/SFTP) | Partial | URL configuration only |
| Thread cancellation | No | Not exposed |
| Custom entrepôt implementations | No |
API Modules
| Module | Description |
|---|---|
ddn.lib.dar | Low-level bindings with direct C shim access |
ddn.wrp.dar | High-level wrapper with RAII, ranges, and fluent builders |
For detailed API documentation and tutorials, see:
- API_TUTORIAL.md — Comprehensive tutorial with examples
License
This project was originally intended to be released under the BSD-3-Clause license. However, since DAR and libdar are released under the GNU General Public License (GPL), any code that links against libdar must also be covered by the GPL or a GPL-compatible license. Therefore, ddn-lib-dar is licensed under the GPL.
See the LICENSE file for the full license text.
See Also
- DAR Homepage — Original DAR project
- DAR GitHub Repository — DAR source code
- libdar API Documentation — C++ API reference
- libdar Tutorial — Original C++ tutorial
- 2.8.1 released 7 hours ago
- ddn/ddn-lib-dar
- GPL-2.0
- Copyright © 2025, Dejan Lekić
- Authors:
- Dependencies:
- none
- Versions:
-
Show all 2 versions2.8.1 2025-Dec-05 ~main 2025-Dec-05 - Download Stats:
-
-
2 downloads today
-
2 downloads this week
-
2 downloads this month
-
2 downloads total
-
- Score:
- 0.0
- Short URL:
- ddn-lib-dar.dub.pm