X
Tap here to go to the mobile version of the site.

Support Forum

Need to automate export/import or backup bookmarks for an organzation

Posted

I work in IT for a medium-sized organization (enterprise). I need a way of exporting and exporting bookmarks for all of my users, and I need to to it in a way that is automated or CLI (babysitting 100+ laptops and importing in person is not an option). We're transferring users to new laptops in three weeks, but we will need this functionality to exist afterwards too (so we can build something to automate bookmark backups and restorations with our internal network). We do use Zenworks at work, but we'll have other scripting options too.

Any link I've found on command-line options for running Firefox with other tools doesn't allow me to quite do what I need to (i.e. I have a way of exporting to an html, but not importing it; -migration switch gives me a GUI). Any resources I've found on Firefox's command line arguments are inconsistent and not clear on what options work with what version. As such, I don't even know if options exist that would actually help.

Due to security issues, running a plugin or storing bookmarks off-site are not options.

I found the existence of profiles.ini and was able to write a script (windows cmd bat - God help me) to pull out what directory gets created for the profile, and then copy files to the user's network drive. I also wrote one to copy one from the user's network drive to their new profile. The problem I'm encountering at this point is that firefox doesn't use the newest bookmark-<date>.json file that gets slapped in the directory. Something else must be referencing what bookmark filename to use. Hoping it's something in the registry or in a plain text file, not a sqllite db, otherwise I'm kind of hosed.

I guess my question is this... is there not a simpler way of doing this, or a (firefox) command line option to do what I need?

In lieu of that, anyone have an idea of how I can tell firefox to use a specific bookmark file to start off with, or the most recent one in the profile directory? Again, it needs to be hands-off. We're not talking about a solution for one person.

And thirdly, if there is no answer to my first question, my question to Firefox developers is "why is this basic feature omitted"? In my opinion, it's obvious and serious enough I would be willing to call it a bug. Many others are having the same problem. (If I don't get a workable solution to the first two questions, I'll follow up with this one in a more appropriate forum or email...)

I work in IT for a medium-sized organization (enterprise). I need a way of exporting and exporting bookmarks for all of my users, and I need to to it in a way that is automated or CLI (babysitting 100+ laptops and importing in person is not an option). We're transferring users to new laptops in three weeks, but we will need this functionality to exist afterwards too (so we can build something to automate bookmark backups and restorations with our internal network). We do use Zenworks at work, but we'll have other scripting options too. Any link I've found on command-line options for running Firefox with other tools doesn't allow me to quite do what I need to (i.e. I have a way of exporting to an html, but not importing it; -migration switch gives me a GUI). Any resources I've found on Firefox's command line arguments are inconsistent and not clear on what options work with what version. As such, I don't even know if options exist that would actually help. Due to security issues, running a plugin or storing bookmarks off-site are not options. I found the existence of profiles.ini and was able to write a script (windows cmd bat - God help me) to pull out what directory gets created for the profile, and then copy files to the user's network drive. I also wrote one to copy one from the user's network drive to their new profile. The problem I'm encountering at this point is that firefox doesn't use the newest bookmark-<date>.json file that gets slapped in the directory. Something else must be referencing what bookmark filename to use. Hoping it's something in the registry or in a plain text file, not a sqllite db, otherwise I'm kind of hosed. I guess my question is this... is there not a simpler way of doing this, or a (firefox) command line option to do what I need? In lieu of that, anyone have an idea of how I can tell firefox to use a specific bookmark file to start off with, or the most recent one in the profile directory? Again, it needs to be hands-off. We're not talking about a solution for one person. And thirdly, if there is no answer to my first question, my question to Firefox developers is "why is this basic feature omitted"? In my opinion, it's obvious and serious enough I would be willing to call it a bug. Many others are having the same problem. (If I don't get a workable solution to the first two questions, I'll follow up with this one in a more appropriate forum or email...)

Chosen solution

Thanks a lot folks, you really helped my pull together a solution! I think this solution will be fine for now (I'm running these .bat files as the user, not system or an admin.) I'm deploying this via Zenworks, though there is more than one way to skin this cat...

For exports I made a file named override.ini I placed it in c:\program files (x86)\mozilla firefox\ It contains:

  • [XRE]
  • EnableProfileMigrator=false

... I needed to do that because I didn't want the GUI to auto import on a first run (ticks me off, regardless of it being actually necessary or not in this case).

My export bat file for XP (because of goto:EOF you need to run cmd.exe for this one with /x):

  • set copycmd=/y
  • c:
  • if not exist "%userprofile%\application data\mozilla\firefox\profiles.ini" goto:EOF
  • cd "%userprofile%\application data\mozilla\firefox\"
  • for /f "tokens=1,2 delims=/" %%i in ('findstr /l ".default" profiles.ini') do call set var1=%%j
  • cd profiles\%var1%
  • if not exist h:\backupbookmarks (mkdir H:\backupbookmarks)
  • copy places.sqlite H:\backupbookmarks

My import bat file for Windows 7:

  • set copycmd=/y
  • start "browser" /d "C:\Program Files (x86)\Mozilla Firefox" firefox.exe
  • timeout 7
  • c:
  • cd %userprofile%\AppData\Roaming\Mozilla\Firefox\
  • for /f "tokens=1,2 delims=/" %%i in ('findstr /l ".default" profiles.ini') do call set var1=%%j
  • cd profiles\%var1%
  • if exist h:\backupbookmarks\places.sqlite copy h:\backupbookmarks\places.sqlite

Hope that helps someone else out there. I made similar scripts for Chrome and Safari too, so I really should post this on my blog... will have to start a blog that isn't Linux-only, though!

Read this answer in context 2

Additional System Details

Installed Plug-ins

none (it needs to stay that way)

Application

  • User Agent: Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/536.5 (KHTML, like Gecko) Chrome/19.0.1084.52 Safari/536.5

More Information

old laptop windows xp to new laptop windows 7
will need to export & import from either system in the long run
xp profile - userprofile%\application data\mozilla\firefox\profiles\%var1%\bookmarkbackups
w7 profile - %userprofile%\AppData\Roaming\Mozilla\Firefox\profiles\%var1%\bookmarkbackups

cor-el
  • Top 10 Contributor
  • Moderator
12316 solutions 114011 answers

You can make Firefox create an HTML backup of the bookmarks each time Firefox is closed by setting the browser.bookmarks.autoExportHTML pref to true on the about:config page.

You can set the location of the backup via the browser.bookmarks.file pref.

See also:


The only way to restore/rebuild bookmarks is to delete places.sqlite, but that will cause them to lose the history and all bookmarks they currently have.
If places.sqlite is missing then Firefox will rebuild the bookmarks from the most recent JSON backup in the bookmarkbackups folder and if there aren't any JSON backups then the bookmarks.html file in the profile folder is used.

You can make Firefox create an HTML backup of the bookmarks each time Firefox is closed by setting the <b>browser.bookmarks.autoExportHTML</b> pref to true on the about:config page. * http://kb.mozillazine.org/browser.bookmarks.autoExportHTML *http://kb.mozillazine.org/Export_bookmarks You can set the location of the backup via the browser.bookmarks.file pref. * http://kb.mozillazine.org/browser.bookmarks.file See also: *http://kb.mozillazine.org/about:config ---- The only way to restore/rebuild bookmarks is to delete places.sqlite, but that will cause them to lose the history and all bookmarks they currently have.<br /> If places.sqlite is missing then Firefox will rebuild the bookmarks from the most recent JSON backup in the bookmarkbackups folder and if there aren't any JSON backups then the bookmarks.html file in the profile folder is used. *http://kb.mozillazine.org/Backing_up_and_restoring_bookmarks_-_Firefox
Gingerbread Man 403 solutions 1537 answers

Helpful Reply

Why not simply replace places.sqlite with your backup copy and be done with it? The caveat is that you'll replace history along with bookmarks.

Why not simply replace ''places.sqlite'' with your backup copy and be done with it? The caveat is that you'll replace history along with bookmarks.

Question owner

Actually, I think the places.sqllite replacement will work for my situation anyway because it will be copied over a 1st use run of Firefox.

The other solution may be more useful for building backups after they've already done that first run. I'll have to figure out now if there's an automated way of setting the stuff in about:config.

Testing...

Actually, I think the places.sqllite replacement will work for my situation anyway because it will be copied over a 1st use run of Firefox. The other solution may be more useful for building backups after they've already done that first run. I'll have to figure out now if there's an automated way of setting the stuff in about:config. Testing...

Modified by uniquegeek

philipp
  • Top 10 Contributor
  • Moderator
2974 solutions 13817 answers

maybe this article is a good starting point for that: http://kb.mozillazine.org/Locking_preferences

maybe this article is a good starting point for that: http://kb.mozillazine.org/Locking_preferences
cor-el
  • Top 10 Contributor
  • Moderator
12316 solutions 114011 answers

You can use a mozilla.cfg file in the Firefox program folder to lock prefs or specify (new) default values.

Place a file local-settings.js in the defaults\pref folder where you also find the file channel-prefs.js to specify using mozilla.cfg.

pref("general.config.filename", "mozilla.cfg");
pref("general.config.obscure_value", 0); // use this to disable the byte-shift

See:

You can use these functions in mozilla.cfg:

defaultPref();  // set new default value
pref();         // set pref, but allow changes in current session
lockPref();     // lock pref, disallow changes
You can use a mozilla.cfg file in the Firefox program folder to lock prefs or specify (new) default values. Place a file local-settings.js in the defaults\pref folder where you also find the file channel-prefs.js to specify using mozilla.cfg. pref("general.config.filename", "mozilla.cfg"); pref("general.config.obscure_value", 0); // use this to disable the byte-shift See: * http://kb.mozillazine.org/Locking_preferences You can use these functions in mozilla.cfg: defaultPref(); // set new default value pref(); // set pref, but allow changes in current session lockPref(); // lock pref, disallow changes

Chosen Solution

Thanks a lot folks, you really helped my pull together a solution! I think this solution will be fine for now (I'm running these .bat files as the user, not system or an admin.) I'm deploying this via Zenworks, though there is more than one way to skin this cat...

For exports I made a file named override.ini I placed it in c:\program files (x86)\mozilla firefox\ It contains:

  • [XRE]
  • EnableProfileMigrator=false

... I needed to do that because I didn't want the GUI to auto import on a first run (ticks me off, regardless of it being actually necessary or not in this case).

My export bat file for XP (because of goto:EOF you need to run cmd.exe for this one with /x):

  • set copycmd=/y
  • c:
  • if not exist "%userprofile%\application data\mozilla\firefox\profiles.ini" goto:EOF
  • cd "%userprofile%\application data\mozilla\firefox\"
  • for /f "tokens=1,2 delims=/" %%i in ('findstr /l ".default" profiles.ini') do call set var1=%%j
  • cd profiles\%var1%
  • if not exist h:\backupbookmarks (mkdir H:\backupbookmarks)
  • copy places.sqlite H:\backupbookmarks

My import bat file for Windows 7:

  • set copycmd=/y
  • start "browser" /d "C:\Program Files (x86)\Mozilla Firefox" firefox.exe
  • timeout 7
  • c:
  • cd %userprofile%\AppData\Roaming\Mozilla\Firefox\
  • for /f "tokens=1,2 delims=/" %%i in ('findstr /l ".default" profiles.ini') do call set var1=%%j
  • cd profiles\%var1%
  • if exist h:\backupbookmarks\places.sqlite copy h:\backupbookmarks\places.sqlite

Hope that helps someone else out there. I made similar scripts for Chrome and Safari too, so I really should post this on my blog... will have to start a blog that isn't Linux-only, though!

'''Thanks a lot folks, you really helped my pull together a solution! I think this solution will be fine for now (I'm running these .bat files as the user, not system or an admin.) I'm deploying this via Zenworks, though there is more than one way to skin this cat...''' '''For exports I made a file named''' override.ini '''I placed it in''' c:\program files (x86)\mozilla firefox\ '''It contains:''' * [XRE] * EnableProfileMigrator=false '''... I needed to do that because I didn't want the GUI to auto import on a first run (ticks me off, regardless of it being actually necessary or not in this case).''' '''My export bat file for XP (because of goto:EOF you need to run cmd.exe for this one with /x):''' * set copycmd=/y * c: * if not exist "%userprofile%\application data\mozilla\firefox\profiles.ini" goto:EOF * cd "%userprofile%\application data\mozilla\firefox\" * for /f "tokens=1,2 delims=/" %%i in ('findstr /l ".default" profiles.ini') do call set var1=%%j * cd profiles\%var1% * if not exist h:\backupbookmarks (mkdir H:\backupbookmarks) * copy places.sqlite H:\backupbookmarks '''My import bat file for Windows 7:''' * set copycmd=/y * start "browser" /d "C:\Program Files (x86)\Mozilla Firefox" firefox.exe * timeout 7 * c: * cd %userprofile%\AppData\Roaming\Mozilla\Firefox\ * for /f "tokens=1,2 delims=/" %%i in ('findstr /l ".default" profiles.ini') do call set var1=%%j * cd profiles\%var1% * if exist h:\backupbookmarks\places.sqlite copy h:\backupbookmarks\places.sqlite Hope that helps someone else out there. I made similar scripts for Chrome and Safari too, so I really should post this on my blog... will have to start a blog that isn't Linux-only, though!

Modified by uniquegeek