Your Firefox profile houses some pretty important stuff such as bookmarks, saved passwords and preferences which would be quite inconvenient to lose. As with any valuable data, your Firefox profile should be backed up regularly.

While you can always perform the backup manually or use an external tool (such as MozBackup or FEBE), each of these options have their own shortcomings and none are a true "set it and forget it" method. Our geek oriented solution to Firefox profile backups is to use a batch script which can be run at any time. Regardless of whether or not you have Firefox open, this script will capture your current Firefox profile and store it in a zip file for easy recovery.

The Script

Overall, the script doesn't do anything magical. It simply goes to the respective user's Firefix profile folder and copies all the unlocked files to a temporary directory and finally creates a zip archive of the files. You will need to have the 7-Zip command line tool copied to a folder set in your Windows PATH variable in order for the zip process to complete.

        @ECHO OFFTITLE Firefox Profile BackupECHO Firefox Profile BackupECHO Written by: Jason FaulknerECHO SysadminGeek.comECHO.ECHO.SETLOCALREM Requires the 7-Zip command line tool (7za.exe) which can be downloaded at:REM http://www.7-zip.orgREM This file should be placed in a folder in the PATH variable (i.e. C:Windows)REM Full path the the storage archive file (do not put in quotes)REM Make sure this directory path exists.SET BackupFileName=%USERPROFILE%DocumentsBackupFirefoxProfile.zipREM Leave everything below here aloneSET TempBackupDir=%TEMP%Firefox_ProfileSET TempBackupDirAction="%TempBackupDir%"IF EXIST %TempBackupDirAction% RMDIR %TempBackupDirAction%MKDIR %TempBackupDirAction%XCOPY "%APPDATA%MozillaFirefoxProfiles*" %TempBackupDirAction% /E /V /C /H /YSET BackupFileName="%BackupFileName%"IF EXIST %BackupFileName% DEL /F /Q %BackupFileName%7ZA a %BackupFileName% "%TempBackupDir%*"IF EXIST %TempBackupDirAction% RMDIR /S /Q %TempBackupDirAction%ENDLOCAL
    

Scheduling the Backup

Once you have the script in place, you simply need to schedule it via the Windows Task Scheduler. You can use the graphical interface or via the command line tool, SchTasks, to easily set it to run daily for the current user:

SchTasks /Create /SC DAILY /TN BackupFirefoxProfile /TR %UserProfile%DocumentsScriptsBackupFirefoxProfile.bat /ST 09:00 /RU <UserName> /RP <Password>

Important Note: The script makes reference to profile specific locations (%USERPROFILE% and %APPDATA%), so it is important the scheduled task runs as the respective user account you want to backup the Firefox profile for.

Limitations

This script will pick up any unlocked file as part of the backup. When Firefox is open, a file named "parent.LOCK" is created and this file is not included in the backup. It is a zero byte, so bit-wise the profile backup can complete without including this file.

Certain add-ons may also lock files while Firefox is open, but our testing has not found any instances where this is the case.

Download the 7-Zip Command Line Tool

Manually Backup a Firefox Profile

FEBE Add-on for Firefox