createArchive

fnArchiveHandle createArchive(string fsRoot, string outDir, string base, string ext, CreateOptions co) @safe

Creates an archive (full backup) writing slices to the given output directory.

This function creates a new DAR archive containing all files and directories under the specified filesystem root. The archive is written as slice files to the output directory.

Parameters

fsRootfilesystem root to back up (all files under this path are archived)
outDirdirectory where archive slices are written
basearchive base name (slices will be named base.1.ext, base.2.ext, etc.)
extslice extension (typically "dar")
cocreate options created via CreateOptions.create()

Returns

ArchiveHandle for the created archive.

Throws

DarException if archive creation fails (permission denied, disk full,

invalid options, I/O errors).

Example:

// Create a simple uncompressed backup
auto co = CreateOptions.create();
auto archive = createArchive("/home/user/documents", "/backups", "docs", "dar", co);

// Create a compressed, encrypted backup
auto co2 = CreateOptions.create();
co2.setCompression(DarCompression.GZIP);
co2.setCompressionLevel(6);
co2.setCryptoAlgo(DarCryptoAlgo.AES256);
co2.setPassword("mysecretpassword");
co2.setAllowOverwrite(true);
auto secureArchive = createArchive("/data", "/backups", "secure_backup", "dar", co2);