Jump to content

Firefox Backup/Restore


careca
 Share

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

Link to comment
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

Link to comment
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

Link to comment
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
 Share

×
×
  • Create New...