NAME

pkgBackup - A Perl script for selectively backing up an RPM-based or DEB-based system.


SYNOPSIS

debBackup.pl <options> [cfgfile] ...
rpmBackup.pl <options> [cfgfile] ...


OPTIONS

At least one of the following action options must be present:

--help
Prints this message.

--full
Shortcut: has the same effect as specifying the options: --build_package_list --scan_pkgfiles --write_archive_manifest --do_backup --new_archive

--incremental
Shortcut: has the same effect as specifying the options: --update_package_list --write_archive_manifest --do_backup

--build_package_list
--build_pkglist
--bpkgl
Builds the list of all installed RPM/DEB packages. This is a required first step of any new full backup.

When this option is not specified, a previously saved version of the package list is loaded. The program will abort with an error if no such version exists.

--update_package_list
--update_pkglist
--upkgl
Reads the previously saved version of the package list and the time at which that list was built. Adds any packages installed since that time to the list.

--scan_pkgfiles
--check_pkgfiles
--scan_rpms
--scan_debs
Scans the RPM/DEB package database for files that are part of an installed package, but have since changed. Any files that have changed are automatically added to the backup list. When the check finishes, the backup list is saved.

When this option is not specified, a previously saved version of the backup list is loaded. The program will abort with an error if no such version exists.

Use this option whenever you have installed new RPM/DEB packages between backups.

Because this option scans the entire filesystem and the entire RPM/DEB package database, it is very load-intensive and takes some time to complete.

--write_archive_manifest
--make_manifest
--write_manifest
Using the results of an earlier --scan_rpms, write a manifest of files to backup. This manifest is handed to the --files-from option of the archive action (see below).

One can also specify directories to exclude from and explicitly include in the manifest.

The --do_backup option and its aliases (see below) imply this option.

--do_backup
--archive
As the names imply, these options all begin the backup process.

--verify=archive_name
Performs a simple verify by comparing the contents of the file archive_name with the most recent output of the --write_archive_manifest option. Note that this does not verify the (GNU-tar, cpio, etc.) archive itself for errors; it's for verifying the results of this script.


OTHER OPTIONS

You may also include the following modifier options (they are not required):

--verbose
Print out extra info while doing the backup. Also passes the --verbose option to the archive command called by the --do_backup action.

-c cfgfile
--conf cfgfile
cfgfile (plain commandline arg)
Read certain parameters from the configuration file cfgfile. The comments in the out-of-the-box configuration file describe the file syntax and the options. If this option isn't specified, a set of sane builtin defaults are used instead. (I.e. no configuration file is read.)

Note that you can also specify the name of the configuration file as a plain commandline argument.

--no_update
Disables --update_package_list, including implicit ones. Use this with the --incremental option to skip the ``Update Package List'' phase and restrict the backup to modified files only.

--new_archive
Force --do_backup to do a full backup. Only affects the --do_backup option and its aliases. This is the default behavior if the backup archive doesn't exist.

Use this with the --incremental option to override its default (which is to have --do_backup do an incremental backup).

You may also use the following additional action options (they are not required, but exist for convenience):

--build_master_list
--update_master_list

They are documented in greater detail in the DESCRIPTION section of the full manpage.


DESCRIPTION

Motivation

Most backup systems assume that you will be archiving all (or nearly all) of the files on your filesystem to some form of tape drive. This is a reasonable assumption for corporate environments or large servers, but what about the ``home'' Linux user? Most home/hobby users will not have a high-capacity tape jukebox, let alone a single-tape 10Gb tape backup drive. They will usually have a CD-RW drive. Faced with daunting task of backing up 3Gb or more to multiple CDs, these home/hobby users simply ignore the chore of backing up their system.

And why should these users back up their systems? Aside from the contents of ``/home'' and ``/tmp'', little else on the filesystem will have changed since they installed the software from the packages. To compound the problem, users migrating from the Winblows world have long since given up all hope of backing up software configurations. Consider, too, that reinstalling packages takes about as much time as restoring a backup from a CD-R.

Nevertheless, these home & hobby users still should do backups. With current Linux packaging software, there's no reason why they can't.

This Perl script contains a modular set of tools for backing up files on your system:

The Action Options

The aforementioned ``modular set of tools'' are the action options, described in the OPTIONS. Each action has certain dependencies on others. Additionally, the script performs the actions in a specific sequence. The order in which you specify the action options on the commandline has no bearing on their execution order.

This is the order in which the action options execute. Listed with them are the operations that take place as part of that option, or as an alternative, if any:

  1. Get the list of packages.
    1. a.
    2. --build_package_list
      1. a.(i)
      2. Build the list of packages.

      3. a.(ii)
      4. Write the package list to a file.

    3. b.
    4. Read and update the list of packages
      1. b.(i)
      2. Read package list from disk (written there by previous run of this script).

      3. b.(ii)
      4. --update_package_list

        Get a list of all packages installed since the package list was written to the file just read in.

  2. Get the Master List (see Utility Actions for details).
    1. a.
    2. --build_master_list

      Build the Master List

    3. b.
    4. --update_package_list

      Read the Master List from disk (written there by previous run of this script). Then, update the Master List.

  3. Retrieve the set of files installed from a package, and altered since the package's install date.
    1. a.
    2. --scan_rpms

      (Also does this if the --build_master_list option is specified.)

      1. a.(i)
      2. Scan all packages for modified files. Build a fileset that describes how each file changed.

      3. a.(ii)
      4. Write the sets of modified package files to disk.

    3. b.
    4. Read and update the list of modified package-member-files.
      1. b.(i)
      2. Read the sets of modified package files from disk (written there by previous run of this script).

      3. b.(ii)
      4. If --update_package_list found any new packages, scan each of them for modified member files.

      5. b.(iii)
      6. If the previous step yielded any new modified package-member-files, merge the results in with the sets read from disk. Then, write these new results to disk.

  4. If either --build_master_list or --update_package_list was used, save the Master List to a file.

  5. --write_archive_manifest
    1. a.
    2. Create the restore-scripts (which are /bin/sh scripts) for files not requiring full archiving.

    3. b.
    4. Write a manifest for use by the archiver (i.e. a list of files to backup). The restore-scripts will be on this manifest.

  6. --do_backup

    Call the archiver. Performs a full backup if --new_archive was specified. Otherwise, the backup is incremental.

    Presently, the archiver is the GNU tar program with bzip2 compression. One can easily use a different archiver by creating a new module and loading it in place of tarBackupUtils.pm.

  7. --verify

    Verifies against the appropriate --write_archive_manifest file, based on the specified archive name.

Each option depends on the successful completion of the previous one. Some have even stronger interdependencies. Specifically:

To make life easier on you, forgetting these requirements doesn't generate an error. Instead, specifying an action option also activates any action options it requires.

Utility Actions

Some other action options:

--build_master_list
--bml
Builds the ``Master List,'' a list of files that are not part of any installed RPM/DEB packages This option searches the entire filesystem, starting at ``/'', and skips certain filesystem types (such as ``proc'', ``iso9660'', ``nfs''). When the search is completed, the Master List is saved to a file.

This option implies the --scan_rpms option. (I.e. it acts as if you also specified --scan_rpms, whether you did or not.)

When this option is not specified, a previously saved version of the Master List is loaded. The program will abort with an error if no such version exists.

Because this option scans the entire filesystem and the entire RPM/DEB package database, it is very load-intensive and takes some time to complete.

--update_master_list
--uml
Updates the ``Master List'' by searching for files created or modified since the last time the Master List changed. This option also begins searching at ``/'' and skips the same filesystem types skipped by --build_master_list. After the update, the Master List is saved to a file.

This option does nothing when --build_master_list (or one of its aliases) is specified.