BackupPC::XS(3)

๐Ÿฆ‹ BackupPC::XS โ€” the Perl extension for the BackupPC libraries ๐Ÿ’…

okay bestie, so this is a page from the User Contributed Perl Documentation, and it's literally the manual for BackupPC::XS, the Perl extension that gives you all the BackupPC library functions. it's giving "backstage pass to the pool" energy. let's get into it ๐ŸŽ€


โœจ NAME โœจ

BackupPC::XS โ€” the Perl extension for the BackupPC libraries. periodt.


๐ŸŒธ SYNOPSIS ๐ŸŒธ

use BackupPC::XS;
use BackupPC::XS qw( :all );

that's it, that's the vibe check. ๐Ÿ’–


๐Ÿ’œ DESCRIPTION ๐Ÿ’œ

BackupPC::XS hands you a bunch of submodules, and each one implements some BackupPC library functions. the sections below go through every submodule one by one, no skipping. ๐Ÿ‘‘

real talk though: this documentation is very terse. BackupPC::XS is not meant to be a general-purpose module โ€” it's closely tied to BackupPC, like, soulmate-level tied. if you want actual examples of using it, go look in the BackupPC code. iykyk. ๐Ÿซถ

๐Ÿ—‚๏ธ BackupPC::XS::FileZIO

compressed file I/O using zlib โ€” the main character of file compression:

$fd = BackupPC::XS::FileZIO::open($fileName, $writeFlag, $compressLevel);
$fd = BackupPC::XS::FileZIO::fdopen($stream, $writeFlag, $compressLevel);
$nWrite   = $fd->write($dataRef);
$nRead    = $fd->read($dataRef, $maxRead);
$textLine = $fd->readLine();
$fd->rewind();
$fd->close();
$fd->writeTeeStderr($boolean);

๐Ÿงฎ BackupPC::XS::PoolRefCnt

pool file reference counting โ€” keeping track of who's holding onto what:

$countDB = BackupPC::XS::PoolRefCnt::new(initialEntryCnt);
$refCount = $countDB->get($digest);
$countDB->set($digest, $refCount);
$countDB->delete($digest);
$countDB->incr($digest, $refIncr);
($digest, $refCnt, $idx) = $countDB->iterate($idx);
$countDB->read($fileName);
$countDB->write($fileName);
$countDB->print();

and pool file delta accumulation, aka the receipts-collecting squad:

BackupPC::XS::PoolRefCnt::DeltaFileInit($hostDir);
BackupPC::XS::PoolRefCnt::DeltaFileFlush();
BackupPC::XS::PoolRefCnt::DeltaUpdate($digest, $refIncr);
BackupPC::XS::PoolRefCnt::DeltaPrint();

โœ๏ธ BackupPC::XS::PoolWrite

writing and matching files in the pool โ€” this one ate and left no crumbs:

$poolWrite = BackupPC::XS::PoolWrite::new($compressLevel [, $digest]);
$poolWrite->write($dataRef);
($match, $digest, $poolSize, $error) = $poolWrite->close();
$poolWrite->addToPool($fileName, $isV3PoolFile);

๐Ÿ“ BackupPC::XS::Attrib

manipulating a set of files and attributes โ€” usually one directory's worth at a time, lowkey cozy:

$a = BackupPC::XS::Attrib::new($compressLevel);
$attrHash = $a->get($fileName);
$a->set($fileName, $attrHash);
$numDirEntries = $a->count();
$a->read($dirPath, $attribFileName);
$a->write($dirPath, $attribFileName);

$textType = BackupPC::XS::Attrib::fileType2Text(BPC_FTYPE_....);

๐Ÿงš BackupPC::XS::AttribCache

maintaining a cache of directories, with full share/path semantics โ€” the whole share/path situation, fully handled:

$ac = BackupPC::XS::AttribCache::new($host, $backupNum, $shareNameUM, $compress);

$attrHash = $ac->get($fileName, $allocateIfMissing, $dontReadInode);
$ac->set($fileName, $attrHash, $dontOverwriteInode);
$ac->delete($fileName);

$attrHash = $ac->getInode($inode, $allocateIfMissing);
$ac->setInode($inode, $attrHash);
$ac->deleteInode($inode);

$ac->getAll($path, $dontReadInode);

$ac->flush($all, $path);
$ac->getFullMangledPath($path);

๐Ÿ› ๏ธ BackupPC::XS::DirOps

directory operations, the practical bestie of the group:

$zeroMeansOk = BackupPC::XS::DirOps::path_create($path);
$errorCnt = BackupPC::XS::DirOps::path_remove($path, $compress);

$errorCnt = BackupPC::XS::DirOps::refCountAll($path, $compress);

$lockFd = BackupPC::XS::DirOps::lockRangeFile($lockFile, $offset, $len, $block);
BackupPC::XS::DirOps::unlockRangeFile($lockFd);

๐Ÿ“š BackupPC::XS::Lib

the utility drawer โ€” init things, grab log messages, count errors, set the log level:

BackupPC::XS::Lib::ConfInit($topDir, $hardLinkMax, $poolV3Enabled, $logLevel)

$messageArrayRef = BackupPC::XS::Lib::logMsgGet();
$errorCnt = BackupPC::XS::Lib::logErrorCntGet;
BackupPC::XS::Lib::logLevelSet($level);

๐ŸŽ EXPORTS ๐ŸŽ

if you specify :all (peep the SYNOPSIS above ๐Ÿ‘€), then the BPC_FTYPE_ values get exported. that's the whole deal, slay.


๐Ÿ‘€ SEE ALSO ๐Ÿ‘€

  • BackupPC
  • backuppc.sourceforge.net
  • rsync-bpc

go read those too, bestie, they're iconic in their own right. ๐Ÿ’–


โœ๏ธ AUTHOR โœ๏ธ

Craig Barratt, <cbarratt@users.sourceforge.net<gt>


BackupPC code is copyright (C) 2013-2017 Craig Barratt <cbarratt@users.sourceforge.net>.

bpc_hashTable.c is based on code from rsync. Rsync is Copyright (C) 1996-2001 by Andrew Tridgell, 1996 by Paul Mackerras, 2001-2002 by Martin Pool, and 2003-2009 by Wayne Davison, and others.

the md5 library is from the rsync codebase, and is Copyright (C) 2001-2003 Christophe Devine. see the code for the license.

the zlib library is from the rsync codebase, and is Copyright (C) 1995-2005 Jean-loup Gailly and Mark Adler. see the code for the license.

this program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 3 of the License, or (at your option) any later version.

this program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. see the GNU General Public License for more details. ๐Ÿ˜ญ (yes that's the scary all-caps part, it means it, fr fr)

you should have received a copy of the GNU General Public License along with this program; if not, visit the http://fsf.org website.


๐Ÿ’€ reminder bestie: this module is tightly coupled to BackupPC, not a general-purpose grab-and-go thing. don't just yeet it into random projects, okay? ๐Ÿซถ

and that's the whole page! this beauty came to you as perl v5.32.1, dated 2023-01-18 โ€” shoutout to that version and that date, they ate. bye bestie, go compress some files ๐Ÿ’…โœจ๐ŸŽ€

๐Ÿ“ฆ where this page comes from