Search code examples
automationfiddler

How to backup and restore sessions on Fiddler startup and shutdown?


What I want is backup all sessions at Fiddler shutdown and when I turn it on again it needs to load that sessions again.

I managed to change the FiddlerScript by creating a save action and dump all sessions with this:

case "save":
    FiddlerObject.UI.actSelectAll();
    FiddlerObject.UI.actSaveSessionsToZip(CONFIG.GetPath("Captures") + "saved.saz");
    FiddlerObject.StatusText = "Saved in " + CONFIG.GetPath("Captures") + "saved.saz";
break;

It works fine and all currently loaded sessions are saved.

I tried to create a action to restore them but it does nothing (I loaded the session but don't know how to get back in the grid):

case "restore":
    //I don't know what I need to do with this
    Utilities.ReadSessionArchive(CONFIG.GetPath("Captures") + "saved.saz", true);
break;

After that I want to do something similar do execute them with ExecAction at startup and shutdown but this is another part of my puzzle.

TL;DR

How to restore a previously saved dump using FiddlerScript on startup?


Solution

  • Rules > Customize Rules.

    Update the OnBoot and OnShutdown functions thusly:

    static function OnBoot() {
        FiddlerApplication.UI.actLoadSessionArchive("_stored.saz");
    }
    
    static function OnShutdown() {
        FiddlerApplication.UI.actSelectAll();
        var sFilename = (CONFIG.GetPath("Captures") + "_stored.saz");
        FiddlerApplication.UI.actSaveSessionsToZip(sFilename);
    }