Firefox and Thunderbird settings backup and restore (Windows)

      Comments Off on Firefox and Thunderbird settings backup and restore (Windows)

When transferring settings between PCs it is often useful to be able to transfer all our Firefox (web browser) and Thunderbird (email) settings, complete with stored passwords, cookies, cache data and everything else, so that they work exactly the same on the new PC.

I created these batch files to do just that several years ago and have used them successfully on a number of occasions since then. They are tested and known to work correctly with Windows 10, 8.1, 7, Vista, XP and 2000.

The principle is very straightforward. The relevant files are stored in C:\Users\{name}\AppData\Local\Mozilla\ and C:\Users\{name}\AppData\Roaming\Mozilla\ for Firefox and C:\Users\{name}\AppData\Local\Thunderbird\ and C:\Users\{name}\AppData\Roaming\Thunderbird\ for Thunderbird. The complete contents of these folders are packed into ZIP archives using the command line version of 7-Zip, and restored on the new PC.

The locations of the folders are obtained using the %APPDATA% and %LOCALAPPDATA% variables so will still work if these folders are not in the default locations or for different versions of Windows where they are in different locations. %LOCALAPPDATA% does not exist on Windows 2000 and XP so they are created from %USERPROFILE% on those operating systems.

The batch files also delete any existing profiles first (with a warning and option to quit) and check they have all the files they need to run.

There are four batch files, firefox-backup.bat, firefox-restore.bat, thunderbird-backup.bat and thunderbird-restore.bat. Simply put the required backup batch files in an empty folder along with 7za.exe and double-click a batch file to run it. Then copy the resulting ZIP files over to the new PC, again in a folder with 7za.exe and the relevant restore batch files, and double-click to run.

Please read the information displayed carefully before pressing any key to continue, as you only get one chance to abort!

firefox-backup.bat

@echo off
cls
echo About to backup Firefox settings for current user.
echo Any existing backups will be deleted.
echo Firefox must be closed.
echo Make sure this batch file and 7za.exe are in the same folder.
echo.
echo To abort press Ctrl-C now, otherwise...
pause

if not exist 7za.exe goto :NoZip

if "%LOCALAPPDATA%"=="" SET LOCALAPPDATA=%USERPROFILE%\Local Settings\Application Data
del firefox-appdata.zip
del firefox-localappdata.zip
7za a -tzip firefox-appdata.zip -r "%APPDATA%\Mozilla\*"
7za a -tzip firefox-localappdata.zip -r "%LOCALAPPDATA%\Mozilla\*"

echo.
echo Backup Complete
goto :End

:NoZip
echo.
echo ERROR - 7-ZIP NOT FOUND!

:End
pause

firefox-restore.bat

@echo off
cls
echo About to restore Firefox settings for current user.
echo Any existing settings will be deleted.
echo Firefox must be closed.
echo Make sure this batch file and 7za.exe are in the same folder.
echo.
echo To abort press Ctrl-C now, otherwise...
pause

if not exist firefox-appdata.zip goto :NoFile
if not exist firefox-localappdata.zip goto :NoFile

if not exist 7za.exe goto :NoZip

if "%LOCALAPPDATA%"=="" SET LOCALAPPDATA=%USERPROFILE%\Local Settings\Application Data
rd /s /q "%APPDATA%\Mozilla\"
rd /s /q "%LOCALAPPDATA%\Mozilla\"
7za x firefox-appdata.zip -r -aoa -o"%APPDATA%\Mozilla\"
7za x firefox-localappdata.zip -r -aoa -o"%LOCALAPPDATA%\Mozilla\"
echo.
echo Restore Complete
goto :End

:NoFile
echo.
echo ERROR - BACKUP FILES NOT FOUND!
goto :End

:NoZip
echo.
echo ERROR - 7-ZIP NOT FOUND!

:End
pause

thunderbird-backup.bat

@echo off
cls
echo About to backup Thunderbird settings for current user.
echo Any existing backups will be deleted.
echo Thunderbird must be closed.
echo Make sure this batch file and 7za.exe are in the same folder.
echo.
echo To abort press Ctrl-C now, otherwise...
pause

if not exist 7za.exe goto :NoZip

if "%LOCALAPPDATA%"=="" SET LOCALAPPDATA=%USERPROFILE%\Local Settings\Application Data
del thunderbird-appdata.zip
del thunderbird-localappdata.zip
7za a -tzip thunderbird-appdata.zip -r "%APPDATA%\Thunderbird\*"
7za a -tzip thunderbird-localappdata.zip -r "%LOCALAPPDATA%\Thunderbird\*"

echo.
echo Backup Complete
goto :End

:NoZip
echo.
echo ERROR - 7-ZIP NOT FOUND!

:End
pause

thunderbird-restore.bat

@echo off
cls
echo About to restore Thunderbird settings for current user.
echo Any existing settings will be deleted.
echo Thunderbird must be closed.
echo Make sure this batch file and 7za.exe are in the same folder.
echo.
echo To abort press Ctrl-C now, otherwise...
pause

if not exist thunderbird-appdata.zip goto :NoFile
if not exist thunderbird-localappdata.zip goto :NoFile

if not exist 7za.exe goto :NoZip

if "%LOCALAPPDATA%"=="" SET LOCALAPPDATA=%USERPROFILE%\Local Settings\Application Data
rd /s /q "%APPDATA%\Thunderbird\"
rd /s /q "%LOCALAPPDATA%\Thunderbird\"
7za x thunderbird-appdata.zip -r -aoa -o"%APPDATA%\Thunderbird\"
7za x thunderbird-localappdata.zip -r -aoa -o"%LOCALAPPDATA%\Thunderbird\"
echo.
echo Restore Complete
goto :End

:NoFile
echo.
echo ERROR - BACKUP FILES NOT FOUND!
goto :End

:NoZip
echo.
echo ERROR - 7-ZIP NOT FOUND!

:End
pause

Download

To save you copying and pasting, the four batch files are available to download in a single ZIP file here.

Firefox and Thunderbird Backup Batch Files

You will also need to download the command line version of 7-Zip from http://www.7-zip.org/download.html and add put 7za.exe in the same folder as the batch files.

Disclaimer

These batch files are offered on an ‘as-is’ basis with no guarantee that it will work correctly etc. Please carry out your own tests before using them. No liability is accepted for any errors or damage however caused.

These batch files are free of charge, however I would appreciate a link to this website if you find them useful.

These batch files are not endorsed by or in any way connected with Mozilla (publisher of Firefox and Thunderbird).

These batch files are Copyright (c) 2007-2016 Paul Stenning.