rbackup.plugins package

Submodules

rbackup.plugins.packagemanager module

class rbackup.plugins.packagemanager.PackageManager(cachedir=None, db_path=None, lockfile=None, pkglist_cmd=None)

Bases: object

Class for abstracting package manager-based operations.

The package manager can be used in conjunction with a Snapshot for backups.

Lockfile Management

This class can be used as a context manager for creating a lockfile for the specific package manager. This is to prevent transactions from occurring during backup operations which would most likely leave the package manager’s database in an inconsistent state on the backup.

Note

Subclasses can override the context manager and implement i.e. blocking until the process is complete with a timeout.

Note

The lockfile is only created if it was configured. Otherwise it is silently ignored.

cache_directory
Returns

the cache directory of this package manager

Return type

path-like object or None

database_path
Returns

the database path of this package manager

Return type

path-like object or None

gen_db_archive(compress=None)

Generate a database archive for this package manager.

Parameters

compress (str) – compression mode

Returns

the path to the created file

Return type

path-like object

Raises
  • ValueError – if compress is not in packagemanager.VALID_DB_COMPRESS_MODES

  • NotImplementedError – if database path is not present

gen_pkglist()

Generate a text file listing installed packages on the system and return the path to that file.

If there is an error in the package listing command, then it is to be assumed that no file was created, therefore there is no file to cleanup.

Returns

path to temporary file

Return type

path-like object

Raises

NotImplementedError – if package list generation command is not present

lockfile
Returns

the lockfile path of this package manager

Return type

path-like object or None

pkglist_cmd
Returns

the package listing command of this package manager

Return type

iterable, str or None

Module contents