• You've discovered RedGuides 📕 an EverQuest multi-boxing community 🛡️🧙🗡️. We want you to play several EQ characters at once, come join us and say hello! 👋
  • IS THIS SITE UGLY? Click "RG3" at the very bottom-left of this page to change it. To dismiss this notice, click the X --->
Resource icon

Utility MQ2 Backups

Software Requirements
Windows Powershell
Server Type
  1. Live
  2. Emu
  3. Test Server
BETA

The following is a Powershell script that will help you backup your config and ini files for MQ2. It will do so for your Live, Test, Beta, and Emu installs. If you do not have one of these installed, just leave an empty string. It will automatically create folders at $MQ2Backup_Root with the names MQ2_<Test/Live/Beta/Emu>.

You can most easily run this by cutting and pasting this into the Windows Powershell ISE (run as administrator if you need to restore to a protected location) tool, selecting all the text, and clicking the Run Selection button.

The end goal of this script is to provide some quick logic if someone would like to take this for a better backup tool in a more robust format.

Why Powershell? It was easily something everyone has on their Windows machine without installing anything extra.

RESTORE FUNCTION WILL REQUIRE ADMINISTRATIVE PRIVILEGES IF RESTORING TO REDGUIDES FOLDER AND OTHER NON-USER ACCESSIBLE LOCATIONS.

Future work:
1. Instructions for turning this into a proper .ps1 script that you can more easily execute.

MQ2_Auto_Backup.ps1:
# SCRIPT CONFIGURATION SECTION -- EDIT HERE ######
# Backing this up to a cloud service would work well
$MQ2Backup_Root = "C:\Path\to\my\backup\location"

# Set these to the folders where your MQ2 executable files are located.
# Below is an example of the default RedGuides Location
$MQ2FolderLocations = @{ Live="C:\ProgramData\RedGuides\DesktopUtility\MQ2\Live\Release"; Test="C:\ProgramData\RedGuides\DesktopUtility\MQ2\Test\Release"; Beta=""; Emu=""}
#####################################

Add-Type -AssemblyName System.Windows.Forms
Add-Type -AssemblyName System.Drawing

# SUBROUTINES ######

function Backup-MQ2 {
    # Backup each MQ2 Folder location defined in the MQ2Folder Locations.
    foreach ($folder in $MQ2FolderLocations.GetEnumerator()) {
        # Skip backing up versions of MQ2 we haven't defined folders for
        if( $folder.Value.ToString() -eq "" ) { continue }

        $Dest = $MQ2Backup_Root + "\MQ2_" + $folder.Key.ToString()
        # Create the MQ2_$folder.Key location if it doesn't exist
        if( !(Test-Path $Dest) ) { mkdir $Dest }
        if( !(Test-Path ($Dest + "\Macros")) ) { mkdir ($Dest + "\Macros") }
        if( !(Test-Path ($Dest + "\Configs")) ) { mkdir ($Dest + "\Configs") }

        # Copy MQ2 Plugin and Base INI's -- except mq2autologin as it is encrypted
        # specifically for the host PC
        $Path = ($folder.Value.ToString() + "\*.ini")
        Copy-Item -Path $Path -Destination $Dest -Exclude "mq2autologin.ini"

        # Manually copy over the mq2autologin file so that we can rename it 
        # to connect to the PC that saved it
        $Path = ($folder.Value.ToString() + "\mq2autologin.ini")
        Copy-Item -Path $Path -Destination ($Dest + "\mq2autologin-" + (Get-ComputerInfo -Property "Csname") + ".ini")

        # Copy MQ2 Configs
        $Path = ($folder.Value.ToString() + "\*.cfg")
        Copy-Item -Path $Path -Destination $Dest

        # Copy MQ2 JSON files -- used by some plugins for configs vs. inis
        $Path = ($folder.Value.ToString() + "\*.json")
        Copy-Item -Path $Path -Destination $Dest

        # Copy MQ2 Config Folder
        $Path = ($folder.Value.ToString() + "\Macros\*.ini")
        Write-Output $Dest
        Copy-Item -Path $Path -Destination ($Dest + "\Macros\")

        # Copy MQ2 Macros INI's
        $Path = ($folder.Value.ToString() + "\Configs\*.cfg")
        Copy-Item -Path $Path -Destination ($Dest + "\Configs\")
    }
}

function Restore-MQ2 {
    # Restore each of the Backup locations into the MQ2 directories
    foreach ($folder in $MQ2FolderLocations.GetEnumerator()) {

        # Skip backing up versions of MQ2 we haven't defined folders for
        if( $folder.Value.ToString() -eq "" ) { continue }

        # Get backup location
        $BackupLocation = $MQ2Backup_Root + "\MQ2_" + $folder.Key.ToString()

        # Copy INI files to the base MQ2 Plugin location
        Copy-Item -Path ($BackupLocation + "\*.ini") -Destination ($folder.Value.ToString() + "\") -Exclude "mq2autologin*.ini"

        # Copy Config files into the base MQ2 folder
        Copy-Item -Path ($BackupLocation + "\*.cfg") -Destination ($folder.Value.ToString() + "\")

        # Copy config files into the MQ2 Config folder
        Copy-Item -Path ($BackupLocation + "\Configs\*.cfg") -Destination ($folder.Value.ToString() + "\Configs\")

        # Copy macro INI file into the MQ2 Macro location
        Copy-Item -Path ($BackupLocation + "\Macros\*.ini") -Destination ($folder.Value.ToString() + "\Macros\")
    }
}
# Create a custom message box
$form = New-Object System.Windows.Forms.Form
$form.Text = 'MQ2 Config Backup and Restore'
$form.Size = New-Object System.Drawing.Size(300,150)
$form.StartPosition = 'CenterScreen'

$BackupButton = New-Object System.Windows.Forms.Button
$BackupButton.Location = New-Object System.Drawing.Point(25,60)
$BackupButton.Size = New-Object System.Drawing.Size(75,23)
$BackupButton.Text = 'Backup'
$BackupButton.DialogResult = [System.Windows.Forms.DialogResult]::Yes
$form.AcceptButton = $BackupButton
$form.Controls.Add($BackupButton)

$RestoreButton = New-Object System.Windows.Forms.Button
$RestoreButton.Location = New-Object System.Drawing.Point(100,60)
$RestoreButton.Size = New-Object System.Drawing.Size(75,23)
$RestoreButton.Text = 'Restore'
$RestoreButton.DialogResult = [System.Windows.Forms.DialogResult]::No
$form.CancelButton = $RestoreButton
$form.Controls.Add($RestoreButton)

$CancelButton = New-Object System.Windows.Forms.Button
$CancelButton.Location = New-Object System.Drawing.Point(175,60)
$CancelButton.Size = New-Object System.Drawing.Size(75,23)
$CancelButton.Text = 'Cancel'
$CancelButton.DialogResult = [System.Windows.Forms.DialogResult]::Cancel
$form.CancelButton = $CancelButton
$form.Controls.Add($CancelButton)

$label = New-Object System.Windows.Forms.Label
$label.Location = New-Object System.Drawing.Point(10,20)
$label.Size = New-Object System.Drawing.Size(280,40)
$label.Text = 'Do you want to backup, restore, or do nothing?'
$form.Controls.Add($label)

$form.Topmost = $true
$MsgBoxResults = $form.ShowDialog()

switch ($MsgBoxResults) {
    'Yes' {
        Write-Output "Backing up MQ2"
        Backup-MQ2
    }

    'No' {
        Write-Output "Restoring MQ2"
        Restore-MQ2
    }

    'Cancel' {
        Write-Output "DOING NOTHING"
    }
}
Author
drwhomphd
First release
Last update
Rating
0.00 star(s) 0 ratings

More resources from drwhomphd

Latest updates

  1. 12/27/2019 - Post Xmas Update

    - Now excludes your autologin file for restor because that's encoded per machine - Will backup...
  2. 12/16/2019 Update

    Updated the powershell script: * Added a message box interface to handle Backup, Restore, and...
  3. Comment Update

    - Fixed document wording oversight pointed out by @toadwart. Attempted to make it clearer that...
Top