Jump to content
LaunchBox Community Forums

LaunchBox Config Backup


Recommended Posts

This is a very simple AutoHotKey script that backs up (and optionally restores) all xml and ini files in your LaunchBox directory. I.E., the configuration files of LaunchBox, your emulators, etc.. I made this a while back for HyperSpin and have tweaked it a bit so it works and is branded for LaunchBox since I've switched to it. ;)

I didn't wanna go crazy and add backing up other extensions like zip and 7z since that includes roms and it would kill your drive space within 10 seconds. ^_^ Use a service like Carbonite if you want to back up everything in the cloud. Making a local backup of xml and ini files are the bulk of how configs are stored whether it's an emulator or LaunchBox itself, although cfg files would be realistic.

All this script really does is copy all configs to a new directory, and as far as I know xml and ini files hold all config files whether it's LaunchBox or an Emulator. You can either do a bulk restore, which copies all of the files back to their original locations (easiest), or you can manually select any file (like mame.ini or ThemeSettings.xml) and copy/paste it back to it's original location.

When I say it's a simple script, I mean it. :) Features could be added so it internally supports additional directories (such as backing up both G:\LaunchBox and X:\Emulators, although you can run it multiple times and specify said directories)

Other features could include scheduling, automatic uploading to external services like DropBox and OneDrive, pseudo version control, and so on. Consider this a very functional proof-of-concept at this point. Feature suggestions are more than welcomed.

I'm sure Jason could add this as a feature within about 15 minutes, but until that happens, LaunchBox-Backup gets it done.

lbb-screenshot2.png

lbb-screenshot3.png

 

lbb-screenshot1.png

Edited by DJQuad
Link to comment
Share on other sites


; LaunchBox-Backup Changelog
; v1 - 5/26/17 - Initial Beta Release


#NoEnv  ; Recommended for performance and compatibility with future AutoHotkey releases.
SendMode Input  ; Recommended for new scripts due to its superior speed and reliability.
SetWorkingDir %A_ScriptDir%  ; Ensures a consistent starting directory.

; File types to save
FileTypes := Object()
FileTypes.Insert(".ini")
FileTypes.Insert(".xml")

; Window definition
Gui, Add, Text, x12 y9 w80 h20 , Source Folder :
Gui, Add, Edit, x92 y9 w330 h20 vSourceFolder, %A_ScriptDir%
Gui, Add, Button, x432 y9 w30 h20 , ...
Gui, Add, Button, x12 y39 w80 h40 , Backup
Gui, Add, Button, x102 y39 w90 h40 , Restore
Gui, Add, Text, x202 y39 w260 h40 , Backup all .XML and .INI files in a folder. Choose the folder to back up.
Gui, Show, x377 y225 h105 w483, Backup .XML and .INI files
Gui, Add, Text, x12 y89 w450 h20 vStatusResult,
Return

; Button events
Button...:
	; Save the input from the user to each control's associated variable.
	Gui, Submit, NoHide

	FileSelectFolder, chosenFolder, *%SourceFolder%, 3, Choose your path to LaunchBox
	chosenFolder := TrimPath(chosenFolder)
	If (StrLen(chosenFolder) <= 2) {
		MsgBox You cannot choose the root directory
	} else {
		GuiControl,, SourceFolder, %chosenFolder%
	}
	return

ButtonBackup:
	Gui, Submit, NoHide
	BackupFolder := GetBackupPath(SourceFolder)
	CopyFiles(FileTypes, SourceFolder, BackupFolder)

	SoundPlay *-1
	GuiControl,, StatusResult, Updated
	return

ButtonRestore:
	Gui, Submit, NoHide
	BackupFolder := GetBackupPath(SourceFolder)
	CopyFiles(FileTypes, BackupFolder, SourceFolder)

	SoundPlay *64
	GuiControl,, StatusResult, Restored
	return

GuiClose:
	ExitApp

; Support functions
TrimPath(inputPath)
{
	return RegExReplace(inputPath, "\\$")
}

GetBackupPath(inputPath)
{
	path := TrimPath(inputPath) . "_configBackup"
	return path
}

CopyFiles(fileTypes, source, destination)
{
	Loop % fileTypes.MaxIndex()
	{
		extension := fileTypes[A_Index]
		copyCommand = xcopy "%source%\*%extension%" "%destination%\" /S /Y /H /R
		RunWait %comspec% /c %copyCommand% 
	}
}

 

LaunchBox-Backup.ahk

Link to comment
Share on other sites

  • 3 weeks later...

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...