Restore settings of Firefox on trouble

Update: 09-29-11 – Using script to automate process, see end of post.

When people have a issue with Firefox I’ve seen many people will resort to deleting their old profile (or folder) and creating a new one. This works but doing this will get rid of any passwords, history, bookmarks… therein. Having used Firefox quite a bit creating a new profile from time to time is a good idea anyhow as cruft, bad extensions, … can slow down browsing.

Manually

Copying the Firefox configs can be done by:

cd ~/.mozilla/firefox/

Backup the old profile and profile list:

mv xxxxxxxx.default{,.bck}
mv profiles.ini{,.bck}

Create a new profile:

firefox -CreateProfile <profilename>

This command will return the name of the new folder. Copy the basic settings to the new profile:

cd *.default.bck
cp places.sqlite key3.db cookies.sqlite mimeTypes.rdf formhistory.sqlite signons.sqlite permissions.sqlite webappsstore.sqlite persdict.dat content-prefs.sqlite ../*.<profilename>

This will transfer the bookmarks, browsing history, form entries, passwords, personal dictonary changes, and page zooms. There might be a couple other things wanted to add (possibly your firefox preferences), take a look at Transferring data to a new profile for more information.

#!/bin/bash
# Create new profile and transfer settings (fixes certain
# problems when there are errors in Firefox settings).
ffsettingsdir=~/.mozilla/firefox/
# Setting files to restore (files to copy):
# (http://kb.mozillazine.org/Transferring_data_to_a_new_profile_-_Firefox)
files="content-prefs.sqlite
cookies.sqlite
formhistory.sqlite
key3.db
mimeTypes.rdf
permissions.sqlite
places.sqlite
searchplugins
signons.sqlite
webappsstore.sqlite"
# Change to Firefox settings directory
if [ -d $ffsettingsdir ]
then
cd "$ffsettingsdir"
else
echo " Firefox settings directory "$ffsettingsdir" does not exist"
exit
fi
# Select current profile directory
printf "Select current Firefox profile settings directory:\n"
select dir_current in */
do
test -n "$dir_current" && break
echo " Select 1, 2, ..."
done
# Check that all listed setting files exist
for f in $files
do
if [ ! -e "$dir_current""$f" ]
then
echo "File "$f" does not exist, exiting."
exit
fi
done
# Rename current profile directory
mv "${dir_current%/}"{,.bck}
dir_old="${dir_current%/}".bck
echo "Renamed old profile directory to: "$dir_old""
# Rename profile list file
if [ -f profiles.ini ]
then
mv -f profiles.ini{,.bck}
fi
# Create new profile
read -p "Name of new profile: " nw_prfl_nm
firefox -CreateProfile "$nw_prfl_nm"
# Select new profile directory
printf "Select NEW Firefox profile settings directory:\n"
select dir_new in */
do
test -n "$dir_new" && break
echo " select 1 , 2 ..."
done
# Copy settings (files) from old profile to new profile
cd "$dir_old"
for f in $files
do
cp -a "$f" "$ffsettingsdir"/"$dir_new"/
done
view raw ff-restore hosted with ❤ by GitHub

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s