Robert Rothenberg > Mozilla-Backup-0.06 > Mozilla::Backup



Annotate this POD


New  4
Open  1
View/Report Bugs
Module Version: 0.06   Source  


Mozilla::Backup - Backup utility for Mozilla profiles


  $moz = Mozilla::Backup->new();
  $file = $moz->backup_profile("firefox", "default");


This package provides a simple interface to back up and restore the profiles of Mozilla-related applications such as Firefox or Thunderbird.

Method calls may use named or positional parameters (named calls are recommended). Methods are outlined below:

  $moz = Mozilla::Backup->new( %options );

Creates a new Mozilla::Backup object. The options are as follows:


A Log::Dispatch object for receiving log messages.

This value is passed to plugins if they accept it.


A plugin to use for archiving. Plugins included are:


Saves the profile in a zip archive. This is the default plugin.


Copies the files in the profile into another directory.


Saves the profile in a tar or tar.gz archive.

You may pass options to the plugin in the following manner:

  $moz = Mozilla::Backup->new(
    plugin => [ 'Mozilla::Backup::Plugin::Tar', compress => 1 ],

An array reference of regular expressions for files to exclude from the backup. For example,

  $moz = Mozilla::Backup->new(
    exclude => [ '^history', '^Cache' ],

Regular expressions can be strings or compiled Regexps.

By default the Cache, <Cache.Trash> folders, XUL cache, mail folders cache and lock files are excluded.

  @types = $moz->profile_types;

Returns a list of all profile types that are supported by this version of the module.

Supported profile types:


Some of these profile types are for platform-specific or obsolete applications, so you may never run into them.

  @types = $moz->found_profile_types();

Returns a list of applications for which profiles were found. (This does not mean that the applications are installed on the machine, only that profiles were found where they were expected.)

  $ini = $moz->type( type => $type );

  $ini = $moz->type( $type );

  if ($moz->type( $type )->profile_exists( $name )) { ... }

Returns the Mozilla::ProfilesIni object for the corresponding $type, or an error if it is invalid.

  if ($moz->type_exists( type => $type)) { ... }

  if ($moz->type_exists($type)) { ... }

Returns true if a profile type exists on the machine.

  $file = $moz->backup_profile(
    type         => $type,
    name         => $name,
    destination  => $dest,
    archive_name => $arch,
    relative     => $rel,

  $file = $moz->backup_profile($type,$name,$dest,$arch,$rel);

Backs up the profile as a zip archive to the path specified in $dest. (If none is given, the current directory is assumed.)

$arch is an optional name for the archive file. If none is given, it assumes type-name-date-time.ext (for example, if the Zip plugin is used.)

$rel is an optional flag to backup files with relative paths instead of absolute pathnames. It defaults to the value of "profile_is_relative" for that profile. (Non-relative profiles will show a warning message.)

If the profile is currently in use, it may not be backed up properly.

This version does no munging of the profile data, nor does it store any meta information. See "KNOWN ISSUES" below.

  $res = $moz->restore_profile(
    archive_path => $backup,
    type         => $type,
    name         => $name,
    is_default   => $is_default,
    munge_prefs  => $munge_prefs, # update prefs.js file

  $res = $moz->restore_profile($backup,$type,$name,$is_default);

Restores the profile at $backup. Returns true if successful, false otherwise.

$munge_prefs can only be specified using named parameter calls. If $munge_prefs is true, then it will attempt to correct any absolute paths specified in the prefs.js file.

Warning: this does not check that it is the correct profile type. It will allow you to restore a profile of a different (and possibly incompatible) type.

Potential incompatabilities with extensions are also not handled. See "KNOWN ISSUES" below.

Compatabilty with Earlier Versions

The interface has been changed from version 0.04. Various methods for querying profile information were moved into the Mozilla::ProfilesIni module. Code that was of the form


should be changed to


The older method calls should still work, but are deprecated and will issue warnings. (Support for them will be removed in some future version.)

See the "type" method for more information.


This module is a prototype. Use at your own risk!

Not all of the profile types have been tested, and are implemented based on information gleaned from sources which may or may not be accurate.

The current version of this module only copies files and does little manipulation of any files, except for the profiles.ini and prefs.js to update some pathnames. This means that information specific to a profile on a machine such as extensions and themes is kept as-is, which may not be a good thing if a profile is restored to a different location or machine, or even application.

(By default cache files are excluded from backups; there may be problems if cache files are restored to incompatible applications or machines.)

To Do List

A list of to-do items, in no particular order:


Save meta-data about backups (such as profile type, file locations, platform) so that file-restoration can make the appropriate conversions.

Improved Parameter Checking

Improve parameter type and value checking.


The test suite needs improved coverage. Sample profiles should be included for more thorough testing.

User-friendly Exclusion Lists

User-friendly exclusion lists (via another module?). Exclusion by categories (privacy protection, E-mail, Bookmarks, etc.).

Standardize Log Messages

Have a standard format (case, puntuation etc.) for log messages. Also standardize error levels (error, alert, critical, etc.).

Possiblly add hooks for internationalisation of messages.


Other "TODO" items marked in source code.


Mozilla web site at

MozillaZine KnowledgeBase article on Profiles at

Mozilla Profile Service source code at


Robert Rothenberg <rrwo at>

Suggestions and Bug Reporting

Feedback is always welcome. Please use the CPAN Request Tracker at to submit bug reports.

There is now a SourceForge project for this module at


Copyright (c) 2005 Robert Rothenberg. All rights reserved. This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.

syntax highlighting: