Jump to content
Sign in to follow this  
careca

Firefox Backup/Restore

Recommended Posts

Hi guys, needed something to speed up the backup of the firefox profile, so i did this,

works for me just right, and it's here available to anyone who needs it.

Obviously gotta thank to everyone who helped me, and had so much patience to help out. Thumbs up for Melba23!

This works like this: press backup, it searches for the file extensions.ini in a subfolder of all fixed drives PROGS01 INSTALL

If not found, backs it up to 'C:FFProfBackup'

The restore function is similar, searches for the same file in the same manner,

not found, searches for 'C:FFProfBackup', if found uses that, not found any, won't do anything.

Uses a method of deleting the destination dir, and copying the source on it, So use at your risk.

Don't blame me if your pc caught fire, or got infested with cockroaches. hehe

PS: Uses Melba23 UDF RecFileListToArray that you can get

#region ;**** Directives created by AutoIt3Wrapper_GUI ****
#AutoIt3Wrapper_Icon=ResourcesFox.ico
#AutoIt3Wrapper_Res_Icon_Add=ResourcesFox.ico
#AutoIt3Wrapper_Run_Tidy=n
#endregion ;**** Directives created by AutoIt3Wrapper_GUI ****
#include <Array.au3>
#include <GuiListView.au3>
#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
#include <ButtonConstants.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>
#include <ListViewConstants.au3>
#include <RecFileListToArray.au3>
Opt("GUIOnEventMode", 1)
Opt("TrayAutoPause", 0)
Opt("TrayIconDebug", 1)

$Form1 = GUICreate("Firefox Profile Backup", 600, 300, 190, 125)
GUISetOnEvent($GUI_EVENT_CLOSE, "Close")
$Backup = GUICtrlCreateButton("Backup", 10, 265, 75, 25)
GUICtrlSetOnEvent($Backup, "Backup")
$Restore = GUICtrlCreateButton("Restore", 120, 265, 75, 25)
GUICtrlSetOnEvent($Restore, "Restore")
$Exit = GUICtrlCreateButton("Exit", 230, 265, 75, 25)
GUICtrlSetOnEvent($Exit, "Close")

$cListView = GUICtrlCreateListView("Path", 10, 80, 580, 130)
GUICtrlSendMsg(-1, $LVM_SETCOLUMNWIDTH, 0, 575)

$Label1 = GUICtrlCreateLabel("Profile Folder", 10, 10, 130, 17)
$Label2 = GUICtrlCreateLabel("Backup/Restore Folder(s) List", 10, 60, 200, 17)
$Label2 = GUICtrlCreateLabel("Backup/Restore Relative Folder", 10, 220, 200, 17)
$Input1 = GUICtrlCreateInput(@AppDataDir & 'MozillaFirefox', 10, 30, 580, 21)
$Input2 = GUICtrlCreateInput('PROGS', 10, 240, 580, 21)
$ProfileDir = GUICtrlRead($Input1)
$DestDir = GUICtrlRead($Input2)
;$DefaultBackup = ('C:FFProfBackup')
$aArray = DriveGetDrive('FIXED')
If @error Then
MsgBox(4096, "DriveGetDrive", "It appears an error occurred.")
Else
For $i = 1 To $aArray[0]
$aList = _RecFileListToArray(StringUpper($aArray[$i]) & $DestDir, "extensions.ini", 1, 1, 0, 2)
If IsArray($aList) Then
For $u = 1 To $aList[0]
GUICtrlCreateListViewItem($aList[$u], $cListView)
Next
EndIf
Next
EndIf

GUISetState(@SW_SHOW)

Func Backup()
$ProfileDir = GUICtrlRead($Input1)
$DestDir = GUICtrlRead($Input2)
If FileExists(@AppDataDir & 'MozillaFirefoxProfilesdefault.defaultextensions.ini') Then
_GUICtrlListView_DeleteAllItems($cListView)
ProgressOn("Progress...", "Working", "")
$aArray = DriveGetDrive('FIXED')
If @error Then
MsgBox(4096, "DriveGetDrive", "It appears an error occurred.")
Else
For $i = 1 To $aArray[0]
$aList = _RecFileListToArray(StringUpper($aArray[$i]) & $DestDir, "extensions.ini", 1, 1, 0, 2)
If IsArray($aList) Then
For $u = 1 To $aList[0]
GUICtrlCreateListViewItem($aList[$u], $cListView)
DirRemove(StringTrimRight($aList[$u], 40), 1)
Sleep(3000)
DirCopy(@AppDataDir & 'MozillaFirefox', StringTrimRight($aList[$u], 40), 1)
If FileExists($aList[$u]) Then
MsgBox(4096, 'Success!', 'Files copied successfully From: ' & $ProfileDir & ' >>> to >>> ' & (StringTrimRight($aList[$u], 40)))
EndIf
ProgressSet(50, "50 %", "Working")
Next
Else
MsgBox(4096, "Info", "No Backup found in subdirectories: " & StringUpper($aArray[$i]) & $DestDir)
;DirCopy($ProfileDir, $DefaultBackup, 1)
DirCopy($ProfileDir, StringUpper($aArray[$i]) & $DestDir, 1)
;MsgBox(4096, "Info", 'Backup done in: ' & $DefaultBackup & ' >>> And >>> ' & StringUpper($aArray[$i]) & $DestDir)
MsgBox(4096, "Info", 'Backup done in: ' & StringUpper($aArray[$i]) & $DestDir)
EndIf
Next
EndIf
ProgressSet(100, "100 %", "Done!")
Sleep(1000)
ProgressOff()
Else
MsgBox(4096, "Info", "No Profile in: " & $ProfileDir)
EndIf
EndFunc ;==>Backup

Func Restore()
$ProfileDir = GUICtrlRead($Input1)
$DestDir = GUICtrlRead($Input2)
_GUICtrlListView_DeleteAllItems($cListView)
ProgressOn("Progress...", "Working", "")
$aArray = DriveGetDrive('FIXED')
If @error Then
MsgBox(4096, "DriveGetDrive", "It appears an error occurred.")
Else
ProgressSet(50, "50 %", "Working")
For $i = 1 To $aArray[0]
$aList = _RecFileListToArray(StringUpper($aArray[$i]) & $DestDir, "extensions.ini", 1, 1, 0, 2)
If IsArray($aList) Then
For $u = 1 To $aList[0]
GUICtrlCreateListViewItem($aList[$u], $cListView)
DirRemove($ProfileDir, 1)
Sleep(2000)
DirCopy(StringTrimRight($aList[$u], 40), $ProfileDir, 1)
ProgressSet(75, "75 %", "Working")
If FileExists(@AppDataDir & 'MozillaFirefoxProfilesdefault.defaultextensions.ini') Then
MsgBox(4096, 'Success!', 'Files copied successfully From: ' & (StringTrimRight($aList[$u], 40)) & ' >>> to >>> ' & $ProfileDir)
Else
MsgBox(4096, "Info", "No Profile in: " & $ProfileDir)
EndIf
Next
Else
MsgBox(4096, "Info", "No Backup found in subdirectories: " & StringUpper($aArray[$i]) & $DestDir)
;If FileExists($DefaultBackup & 'Profilesdefault.defaultextensions.ini') Then
;DirCopy($DefaultBackup, $ProfileDir, 1)
;MsgBox(4096, "Info", 'Backup copied from: ' & $DefaultBackup)
;EndIf
If FileExists(StringUpper($aArray[$i]) & $DestDir & 'Profilesdefault.defaultextensions.ini') Then
DirCopy(StringUpper($aArray[$i]) & $DestDir, $ProfileDir, 1)
MsgBox(4096, "Info", 'Backup copied from: ' & StringUpper($aArray[$i]) & $DestDir)
EndIf
EndIf
Next
EndIf
ProgressSet(100, "100 %", "Done!")
Sleep(1000)
ProgressOff()
EndFunc ;==>Restore

Func Close()
Exit
EndFunc ;==>Close

Do
Sleep(100)
Until $Form1 = 0

Update 1 includes:

1 - input1 is now readable, change path if different

2 - added input2 to set the relative path to save/restore the backup

3 - Removed/commented defaultpath, meaning it no longer saves to C:FFProfBackup, when there's no destination folder set, instead saves to the relative path you wrote.

4 - Included the udf required, icon, and compiled script

Download careca.googlecode.com

post-68092-0-64972400-1352048027_thumb.p

Edited by careca

Spoiler

Renamer - Rename files and folders, remove portions of text from the filename etc.

GPO Tool - Export/Import Group policy settings.

MirrorDir - Synchronize/Backup/Mirror Folders

BeatsPlayer - Music player.

Params Tool - Right click an exe to see it's parameters or execute them.

String Trigger - Triggers pasting text or applications or internet links on specific strings.

Inconspicuous - Hide files in plain sight, not fully encrypted.

Regedit Control - Registry browsing history, quickly jump into any saved key.

Time4Shutdown - Write the time for shutdown in minutes.

Power Profiles Tool - Set a profile as active, delete, duplicate, export and import.

Finished Task Shutdown - Shuts down pc when specified window/Wndl/process closes.

NetworkSpeedShutdown - Shuts down pc if download speed goes under "X" Kb/s.

IUIAutomation - Topic with framework and examples

Au3Record.exe

Share this post


Link to post
Share on other sites

There is a few issues...

1) $Input1 is not used, so no mater what i will input to the «Profile Folder», it will always use predefined path (which can be wrong of course).

2) You can use @AppDataDir to get the firefox data files dir.

And also i think you should put all needed files for this project in one archive, so the user can just download and use it :).


 

Spoiler

Using OS: Win 7 Professional, Using AutoIt Ver(s): 3.3.6.1 / 3.3.8.1

AutoIt_Rus_Community.png AutoIt Russian Community

My Work...

Spoiler

AutoIt_Icon_small.pngProjects: ATT - Application Translate Tool {new}| BlockIt - Block files & folders {new}| SIP - Selected Image Preview {new}| SISCABMAN - SciTE Abbreviations Manager {new}| AutoIt Path Switcher | AutoIt Menu for Opera! | YouTube Download Center! | Desktop Icons Restorator | Math Tasks | KeyBoard & Mouse Cleaner | CaptureIt - Capture Images Utility | CheckFileSize Program

AutoIt_Icon_small.pngUDFs: OnAutoItErrorRegister - Handle AutoIt critical errors {new}| AutoIt Syntax Highlight {new}| Opera Library! | Winamp Library | GetFolderToMenu | Custom_InputBox()! | _FileRun UDF | _CheckInput() UDF | _GUIInputSetOnlyNumbers() UDF | _FileGetValidName() UDF | _GUICtrlCreateRadioCBox UDF | _GuiCreateGrid() | _PathSplitByRegExp() | _GUICtrlListView_MoveItems - UDF | GUICtrlSetOnHover_UDF! | _ControlTab UDF! | _MouseSetOnEvent() UDF! | _ProcessListEx - UDF | GUICtrl_SetResizing - UDF! | Mod. for _IniString UDFs | _StringStripChars UDF | _ColorIsDarkShade UDF | _ColorConvertValue UDF | _GUICtrlTab_CoverBackground | CUI_App_UDF | _IncludeScripts UDF | _AutoIt3ExecuteCode | _DragList UDF | Mod. for _ListView_Progress | _ListView_SysLink | _GenerateRandomNumbers | _BlockInputEx | _IsPressedEx | OnAutoItExit Handler | _GUICtrlCreateTFLabel UDF | WinControlSetEvent UDF | Mod. for _DirGetSizeEx UDF
 
AutoIt_Icon_small.pngExamples: 
ScreenSaver Demo - Matrix included | Gui Drag Without pause the script | _WinAttach()! | Turn Off/On Monitor | ComboBox Handler Example | Mod. for "Thinking Box" | Cool "About" Box | TasksBar Imitation Demo

Like the Projects/UDFs/Examples? Please rate the topic (up-right corner of the post header: Rating AutoIt_Rating.gif)

* === My topics === *

==================================================
My_Userbar.gif
==================================================

 

 

 

AutoIt is simple, subtle, elegant. © AutoIt Team

Share this post


Link to post
Share on other sites

There is a few issues...

1) $Input1 is not used, so no mater what i will input to the «Profile Folder», it will always use predefined path (which can be wrong of course).

2) You can use @AppDataDir to get the firefox data files dir.

And also i think you should put all needed files for this project in one archive, so the user can just download and use it :).

Hello, thanks for the input, you're correct input1 is not changing the path, it's only for the user to see where the application is trying to get the profile files, %appdata% environment variable is a good idea.

In order to upload, i got to upload to an external server, didn't want to include files i haven't created, but it seems like a more pratical option for the user.

Greetz,

Careca

EDIT: updated 1st post including your sugestion, added more stuff.

Edited by careca

Spoiler

Renamer - Rename files and folders, remove portions of text from the filename etc.

GPO Tool - Export/Import Group policy settings.

MirrorDir - Synchronize/Backup/Mirror Folders

BeatsPlayer - Music player.

Params Tool - Right click an exe to see it's parameters or execute them.

String Trigger - Triggers pasting text or applications or internet links on specific strings.

Inconspicuous - Hide files in plain sight, not fully encrypted.

Regedit Control - Registry browsing history, quickly jump into any saved key.

Time4Shutdown - Write the time for shutdown in minutes.

Power Profiles Tool - Set a profile as active, delete, duplicate, export and import.

Finished Task Shutdown - Shuts down pc when specified window/Wndl/process closes.

NetworkSpeedShutdown - Shuts down pc if download speed goes under "X" Kb/s.

IUIAutomation - Topic with framework and examples

Au3Record.exe

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

  • Recently Browsing   0 members

    No registered users viewing this page.

  • Similar Content

    • By TXTechie
      Hello Everyone,
      I've developed my own GUI using AutoIt and I'm allowing users to minimize the GUI, but I also want to include some kind of timer so that it will automatically restore the GUI after something like 30 minutes or an hour. However, I also want them to be able to manually restore the GUI by clicking the application's icon in the taskbar.
      I've searched through the forums, but I'm not sure how to get started.
      Any ideas or functions to research are appreciated!
      Regards,
      TX Techie
    • By Jahar
      Hi All,
      Please help me on how to fetch date/time of last windows 10 system restore point using autoit? Basically its about querying the last restore point.
    • By FUD
      hello 
      please i need help 
      i need to open link in default browser only one windows without duplicate if i try to open the same link 
       
      thanks 
    • By picorico2
      Hi all, 
       
      I´m trying to use the command "WD_LoadWait" because I want to pause the script until the web page fully loads in Firefox but I don´t know how to use it.
      Here´s the full help
      ; #FUNCTION# ==================================================================================================================== ; Name ..........: _WD_LoadWait ; Description ...: Wait for a browser page load to complete before returning ; Syntax ........: _WD_LoadWait($sSession[, $iDelay = 0[, $iTimeout = -1[, $sElement = '']]]) ; Parameters ....: $sSession - Session ID from _WDCreateSession ; $iDelay - [optional] Milliseconds to wait before checking status ; $iTimeout - [optional] Period of time to wait before exiting function ; $sElement - [optional] Element ID to confirm DOM invalidation ; Return values .: Success - 1 ; Failure - 0 and sets the @error flag to non-zero ; Author ........: Dan Pollak ; Modified ......: ; Remarks .......: ; Related .......: ; Link ..........: ; Example .......: No ; =============================================================================================================================== Func _WD_LoadWait($sSession, $iDelay = Default, $iTimeout = Default, $sElement = Default) Local Const $sFuncName = "_WD_LoadWait" Local $iErr, $sResponse, $oJSON, $sReadyState   If $iDelay = Default Then $iDelay = 0 If $iTimeout = Default Then $iTimeout = $_WD_DefaultTimeout If $sElement = Default Then $sElement = ""   If $iDelay Then Sleep($iDelay)   Local $hLoadWaitTimer = TimerInit()   While True If $sElement <> '' Then _WD_ElementAction($sSession, $sElement, 'name')   If $_WD_HTTPRESULT = $HTTP_STATUS_NOT_FOUND Then $sElement = '' Else $sResponse = _WD_ExecuteScript($sSession, 'return document.readyState', '') $iErr = @error   If $iErr Then ExitLoop EndIf   $oJSON = Json_Decode($sResponse) $sReadyState = Json_Get($oJSON, "[value]")   If $sReadyState = 'complete' Then ExitLoop EndIf   If (TimerDiff($hLoadWaitTimer) > $iTimeout) Then $iErr = $_WD_ERROR_Timeout ExitLoop EndIf   Sleep(100) WEnd   If $iErr Then Return SetError(__WD_Error($sFuncName, $iErr, ""), 0, 0) EndIf   Return SetError($_WD_ERROR_Success, 0, 1) EndFunc
       
      Any sugestions or examples?
    • By water
      Internet Explorer is nearly dead, newer versions of Firefox can't any longer be automated using Stilgar's FF UDF.
      Hence more and more users (including me) need to look at automating Webbrowsers using WebDriver.
      That's why I have started to create a tutorial in the wiki.
      It should describe all necessary steps from intallation to usage.

      I'm still collecting ideas for the tutorial - that's where you come into play.
      What do you expect to see in such a tutorial?
      Which browsers should be covered (Firefox, Chrome and Edge are settled)? Any questions for the FAQ? Which (high level) coding examples do you expect (like "How to attach to a running browser instance") ... Like to see your comments
       
      ToDo-List:
      Add "Tools" section and add ChroPath plugin. Done. FAQ: "How to attach to a running browser instance". Done. Explain the difference between iuiautomation, iaccessible, autoit, webdriver. Done. The AutoIt FAQ 40 has been extended. Detailed description of each function. Done Example for "how to deal with downloading". Use function _WD_DownloadFile. Example for "how to deal with popups (alerts, print or save dialog). Use function_WD_AlertRespond to respond to a user prompt. Example for "how to deal with multiple tabs". Use functions _WD_NewTab (create a new tab), _WD_Window (close or switch to a tab) and _WD_Attach (attach to existing tab).
×
×
  • Create New...