Module CedarBackup2.extend.sysinfo
Provides an extension to save off important system recovery
information.
This is a simple Cedar Backup extension used to save off important
system recovery information. It saves off three types of information:
-
Currently-installed Debian packages via
dpkg
--get-selections
-
Disk partition information via
fdisk -l
-
System-wide mounted filesystem contents, via
ls
-laR
The saved-off information is placed into the collect directory and is
compressed using bzip2
to save space.
This extension relies on the options and collect configurations in the
standard Cedar Backup configuration file, but requires no new
configuration of its own. No public functions other than the action are
exposed since all of this is pretty simple.
Author: Kenneth J. Pronovici <pronovic@ieee.org>
Note: If the dpkg
or fdisk
commands cannot be
found in their normal locations or executed by the current user, those
steps will be skipped and a note will be logged at the INFO level.
Function Summary |
|
executeAction (configPath,
options,
config)
Executes the sysinfo backup action. |
|
_dumpDebianPackages (targetDir,
backupUser,
backupGroup,
compress)
Dumps a list of currently installed Debian packages via
dpkg . |
|
_dumpFilesystemContents (targetDir,
backupUser,
backupGroup,
compress)
Dumps complete listing of filesystem contents via ls
-laR . |
|
_dumpPartitionTable (targetDir,
backupUser,
backupGroup,
compress)
Dumps information about the partition table via
fdisk . |
|
_getOutputFile (targetDir,
name,
compress)
Opens the output file used for saving a dump to the filesystem. |
executeAction(configPath,
options,
config)
Executes the sysinfo backup action.
-
- Parameters:
configPath -
Path to configuration file on disk.
(type=String representing a path on disk.)
options -
Program command-line options.
(type=Options object.)
config -
Program configuration.
(type=Config object.)
- Raises:
ValueError -
Under many generic error conditions
IOError -
If the backup process fails for some reason.
|
_dumpDebianPackages(targetDir,
backupUser,
backupGroup,
compress=True)
Dumps a list of currently installed Debian packages via
dpkg .
-
- Parameters:
targetDir -
Directory to write output file into.
backupUser -
User which should own the resulting fule.
backupGroup -
Group which should own the resulting fule.
compress -
Indicates whether to compress the output file.
- Raises:
IOError -
If the dump fails for some reason.
|
_dumpFilesystemContents(targetDir,
backupUser,
backupGroup,
compress=True)
Dumps complete listing of filesystem contents via ls
-laR .
-
- Parameters:
targetDir -
Directory to write output file into.
backupUser -
User which should own the resulting fule.
backupGroup -
Group which should own the resulting fule.
compress -
Indicates whether to compress the output file.
- Raises:
IOError -
If the dump fails for some reason.
|
_dumpPartitionTable(targetDir,
backupUser,
backupGroup,
compress=True)
Dumps information about the partition table via
fdisk .
-
- Parameters:
targetDir -
Directory to write output file into.
backupUser -
User which should own the resulting fule.
backupGroup -
Group which should own the resulting fule.
compress -
Indicates whether to compress the output file.
- Raises:
IOError -
If the dump fails for some reason.
|
_getOutputFile(targetDir,
name,
compress=True)
Opens the output file used for saving a dump to the filesystem.
The filename will be name.txt (or
name.txt.bz2 if compress is
True ), written in the target directory.
-
- Parameters:
targetDir -
Target directory to write file in.
name -
Name of the file to create.
compress -
Indicates whether to write compressed output.
- Returns:
-
Tuple of (Output file object, filename)
|
DPKG_COMMAND
-
- Type:
-
list
- Value:
['/usr/bin/dpkg', '--get-selections']
|
|
DPKG_PATH
-
- Type:
-
str
- Value:
|
FDISK_COMMAND
-
- Type:
-
list
- Value:
|
FDISK_PATH
-
- Type:
-
str
- Value:
|
logger
-
- Type:
-
Logger
- Value:
<logging.Logger instance at 0x40433bcc>
|
|
LS_COMMAND
-
- Type:
-
list
- Value:
|