Here is a simple PowerShell cmdlet for SmarterMail to backup settings/config files.
Problem reported by J. LaDow - Today at 1:34 AM
Submitted
This is a small little PowerShell script that will pull all the .json, .cfg, .config, .sbin, and .xml files found in SmarterMail's two main folders and copy them into a user-supplied destination folder, recreating the directory structure as it goes (minus drive letters). No, it's not perfect - I'm not some world-class developer, but it works and has some basic parameter input error checking to avoid most issues. It will NOT overwrite files - so you will need to make sure the "TargetRootFolder" is empty before running.

This is based on Windows installations - you will need to edit/adjust paths and path separators in the script for it to work on Linux hosts.

For usage and instructions, it responds to the Get-Help command as well:
PS> Get-Help .\BackupSmarterMailSettings -detailed

Copy the code within the box to a text-editor and save as BackupSmarterMailSettings.ps1 (somewhere outside your SmarterMail folder is recommended)...

#############################################################################
# SETTINGS AND CONFIGURATION BACKUP SCRIPT FOR SMARTERMAIL .NET Core BUILDS #
#############################################################################
# THIS SCRIPT (IDENTIFIED AS PROGRAM IN SUBSEQUENT TERMS) IS FREE. 
#
# THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY 
# APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT 
# HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM “AS IS” WITHOUT WARRANTY
# OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, 
# THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 
# PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM 
# IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF 
# ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
#
# IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING 
# WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS 
# THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING 
# ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF 
# THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO 
# LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU 
# OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY 
# OTHER PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF
# THE POSSIBILITY OF SUCH DAMAGES.

<#
.SYNOPSIS 
    SETTINGS AND CONFIGURATION BACKUP SCRIPT FOR SMARTERMAIL .NET Core BUILDS

.DESCRIPTION
    This script relies on the primary "default" OR user supplied installation
    and root data folder paths, and gathers/catalogs all settings data files
    (.json, .sbin, .xml, .cfg, and .config) and re-creates a folder-structure
    in the root of a user submitted destination folder.

    Use Get-Help .\BackupSmarterMailSettings.ps1 -detailed for parameters and examples.

.PARAMETER TargetRootFolder
    The destination drive/folder path to recreate the folder structure into (will be automatically seperated into APP and DATA folders).

.PARAMETER AppRootFolder
    [OPTIONAL] A string value for the source SmarterMail Application (default is C:\Program Files (x86)\SmarterTools\SmarterMail)

.PARAMETER DataRootFolder
    [OPTIONAL] A string value for the source SmarterMail Application (default is C:\SmarterMail)

.EXAMPLE
    ./BackupSmarterMailSettings.ps1 -TargetRootFolder "d:\smartermail-config" -AppRootFolder "C:\app\SmarterMail" -DataRootFolder "D:\pub\mail"
    
    Non-standerd install and data paths defined - destination root is D:\smartermail-config (.\APP and .\DATA subfolders will be created within).
    
.NOTES
    THIS SCRIPT (IDENTIFIED AS PROGRAM IN SUBSEQUENT TERMS) IS FREE. 
    THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY 
    APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT 
    HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM “AS IS” WITHOUT WARRANTY
    OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, 
    THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 
    PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM 
    IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF 
    ALL NECESSARY SERVICING, REPAIR OR CORRECTION.

    IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING 
    WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS 
    THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING 
    ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF 
    THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO 
    LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU 
    OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY 
    OTHER PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF
    THE POSSIBILITY OF SUCH DAMAGES.
#>

param (
    [Parameter(Mandatory)]
    [string]$TargetRootFolder, 
    
    [string]$AppRootFolder = 'C:\Program Files (x86)\SmarterTools\SmarterMail', 
    
    [string]$DataRootFolder = 'C:\SmarterMail'
)

if ($TargetRootFolder.EndsWith('\')) {
    $TargetRootFolder = $TargetRootFolder.Substring(0,$TargetRootFolder.Length - 1)
}

if ($AppRootFolder.EndsWith('\')) {
    $AppRootFolder = $AppRootFolder.Substring(0,$AppRootFolder.Length - 1)
}

if ($DataRootFolder.EndsWith('\')) {
    $DataRootFolder = $DataRootFolder.Substring(0,$DataRootFolder.Length - 1)
}

$Source_APP_ROOT = ${AppRootFolder}
$Source_DATA_ROOT = ${DataRootFolder}


$Target_APP_ROOT = "${TargetRootFolder}\APP"
$Target_DATA_ROOT = "${TargetRootFolder}\DATA"

Write-Host "Configuration: "
Write-Host "Source_APP_ROOT = ${Source_APP_ROOT}"
Write-Host "Source_DATA_ROOT = ${Source_DATA_ROOT}"
Write-Host "Target_APP_ROOT = ${Target_APP_ROOT}"
Write-Host "Target_DATA_ROOT = ${Target_DATA_ROOT}"
Write-Host ""

if ($Source_APP_ROOT.Contains('*')) {
    Write-Host "WILDCARD NOT ALLOWED FOR SOURCE APP PATH"
    exit
}
if ($Source_DATA_ROOT.Contains('*')) {
    Write-Host "WILDCARD NOT ALLOWED FOR SOURCE DATA PATH"
    exit
}
if ($TargetRootFolder.Contains('*')) {
    Write-Host "WILDCARD NOT ALLOWED FOR DESTINATION PATH"
    exit
}

if (-not (Test-Path -Path $Source_APP_ROOT -PathType Container)) {
    Write-Host "ERROR: Source APP directory does not exist."
    exit
}

if (-not (Test-Path -Path $Source_DATA_ROOT -PathType Container)) {
    Write-Host "ERROR: Source DATA directory does not exist."
    exit
}

# Get all files from the source folders and subfolders
Write-Host "Gathering from APP_ROOT"
$Files_APP = Get-ChildItem -Path $Source_APP_ROOT -Recurse | Where-Object { $_.Extension -eq ".cfg" -or $_.Extension -eq ".json" -or $_.Extension -eq ".xml" -or $_.Extension -eq ".sbin" -or $_.Extension -eq ".config" }
Write-Host "Gathering from DATA_ROOT"
$Files_DATA = Get-ChildItem -Path $Source_DATA_ROOT -Recurse | Where-Object { $_.Extension -eq ".cfg" -or $_.Extension -eq ".json" -or $_.Extension -eq ".xml" -or $_.Extension -eq ".sbin" -or $_.Extension -eq ".config" }

[int]$copyCount = 0

Write-Host "Creating Backup Files..."
foreach ($File in $Files_APP) {
    # Determine the relative path of the file
    $RelativePath = $File.FullName.Substring($Source_APP_ROOT.Length).TrimStart("\")

    # Determine the target path
    $TargetPath = Join-Path -Path $Target_APP_ROOT -ChildPath $RelativePath

    # Ensure the target directory exists
    $TargetDirectory = Split-Path -Path $TargetPath
    if (-not (Test-Path -Path $TargetDirectory)) {
        New-Item -ItemType Directory -Path $TargetDirectory -Force | Out-Null
    }
    
    # Copy the file
    Write-Host "$File.Name -> ${TargetPath}"
    Copy-Item -Path $File.FullName -Destination $TargetPath 
    $copyCount++
}

foreach ($File in $Files_DATA) {
    # Determine the relative path of the file
    $RelativePath = $File.FullName.Substring($Source_DATA_ROOT.Length).TrimStart("\")
    
    # Determine the target path
    $TargetPath = Join-Path -Path $Target_DATA_ROOT -ChildPath $RelativePath
    
    # Ensure the target directory exists
    $TargetDirectory = Split-Path -Path $TargetPath
    if (-not (Test-Path -Path $TargetDirectory)) {
        New-Item -ItemType Directory -Path $TargetDirectory -Force | Out-Null
    }
    
    # Copy the file
    Write-Host "$File.Name -> ${TargetPath}"
    Copy-Item -Path $File.FullName -Destination $TargetPath
    $copyCount++
}

Write-Host ""
Write-Host "DONE."
Write-Host "$copyCount TOTAL FILES FOUND AND COPIED."
Write-Host ""




MailEnable survivor / convert --

Reply to Thread

Enter the verification text