FAQ
How can we help?
Categories
Full site search

    How to Set Up Database Encryption at Rest on an On-premises Server

    Contents
    Before You Begin Step 0: Verify the Encryption Component and Startup Scripts Step 1: Generate and Store the Key Step 2: Configure the Key Source and Switch the Startup Script Step 3: Set the Key Fingerprint Step 4: Back Up and Specify the Databases Step 5: Convert Existing Data to Encrypted Format Step 6: Post-Startup Verification Rolling Back and Key Issues Operations and Feature Impact
    This article explains how to enable encryption at rest for databases on a Ragic On-premises Private Server (Linux and Windows). This feature is available for On-premises Private Servers that already use Berkeley DB JE 7. Before you set it up for the first time, run through the entire process on a test machine: enabling encryption, converting all existing data, restoring, and converting back to plaintext.

    Before You Begin

    Encryption Scope
    • Encryption covers the .jdb data files in each JE environment of the databases you specify.
    • Attachments, full-text search indexes, Ragic secondary indexes, exported files, and general logs are not encrypted automatically.
    • A leaked copy of the data is protected by this feature only if it does not contain a usable key and its data has already been converted.
    • To cover other data stored on disk, plan separate disk encryption, such as LUKS on Linux or BitLocker on Windows.
    Note:
    1. If the key is lost, the corresponding encrypted data can never be read again.
    2. The key fingerprint can only be used to check whether a key is correct. You still need the original key to decrypt data.
    3. After you change any DB_ENCRYPTION_* setting described in this article, restart Ragic.
    4. Once the first encrypted file is written, you can no longer roll back by simply switching back to the original startup script. See Rolling Back and Key Issues.

    The setup in this article is divided into 7 stages (Steps 0–6). The commands for each stage are listed separately for Linux and Windows (PowerShell). Use the commands that match your environment.

    Step 0: Verify the Encryption Component and Startup Scripts

    1. Verify the Encryption Component
    Verify that the following file exists in the Ragic installation directory:
    lib/db/je7enc/je-7.5.11-ragic.jar

    If the file does not exist, update to a Ragic patch that supports database encryption, and verify again after updating.

    2. Verify the Encryption Startup Scripts
    Verify that the following files exist in the Ragic installation directory:
    • Linux

    bin/ragic_dbv7enc.sh
    bin/setclasspath_dbv7enc.sh
    • Windows
    bin/ragic_dbv7enc.bat
    bin/setclasspath_dbv7enc.bat
    If either file is missing, download the full installation package that matches your current Ragic version, extract it to a temporary directory, and copy the missing files to the bin folder of your existing installation. These two startup scripts are not included in patches.

    On Linux, after copying, make sure both files are readable and executable by the Ragic service account:
    # RagicHome: the Ragic installation directory. Set this value for your environment first
    
    # Set the read and execute permissions of the startup scripts
    chmod 755 -- "$RagicHome/bin/ragic_dbv7enc.sh" "$RagicHome/bin/setclasspath_dbv7enc.sh"
    3. Verify the System Is Running Normally
    Keep using your existing startup method, and verify that:
    • The system functions normally.
    • log/ragic.out does not contain any Log encryption messages since the latest startup. Identify the new log entries by startup time so that older messages are not included in this check.
    Do not switch to the encryption startup script yet. Keep the existing lib/db/je7/ directory. The encryption JAR must stay in the separate lib/db/je7enc/ directory, and the two JE directories must not be in the classpath at the same time.

    Step 1: Generate and Store the Key

    1. Generate the Key File
    Create a dedicated key folder on a different volume from the Ragic data directory (cust/data), and then run the following command to generate the key file. If a key file already exists, do not regenerate or overwrite it.

    • Linux
    First, make sure the key disk is mounted, and create a dedicated key folder, for example /mnt/ragic-key/ragic. A different path does not necessarily mean a different volume, so verify the actual mount location.
    # Allow only the current user to access newly created files
    umask 077
    
    # Generate a 256-bit key and write it to the dedicated key folder you created
    openssl rand -hex -out /mnt/ragic-key/ragic/db-master.key 32
    • Windows (PowerShell)
    First, create a key folder, for example E:\RagicKey.
    openssl rand -hex -out E:/RagicKey/db-master.key 32

    This command generates a 256-bit random key and writes it to the file as 64 hexadecimal characters.

    2. Set File Permissions
    Have someone with administrator privileges set the owner of the key file to the user account that actually runs Ragic on the operating system, and remove access for all users who do not need it.

    • Linux
    Set the owner of the key file and the dedicated key folder to the user account that actually runs Ragic. Set the key file permission to 600 and the folder permission to 700, and make sure that account can traverse all parent directories to read the key.

    # RagicServiceUser: the Linux user account that actually runs Ragic. Set this value for your environment first
    
    # Give ownership of the key folder and key file to the Ragic service account
    chown -- "$RagicServiceUser" /mnt/ragic-key/ragic /mnt/ragic-key/ragic/db-master.key
    
    # Allow only the owner to access the folder
    chmod 700 -- /mnt/ragic-key/ragic
    
    # Allow only the owner to read and write the key file
    chmod 600 -- /mnt/ragic-key/ragic/db-master.key
    • Windows
    In the key file's "Properties → Security → Advanced" settings, set the owner to the user account that actually runs Ragic, grant it read permission, and remove access for all users who do not need it.

    3. Back Up the Key
    Note that if the key is lost, the corresponding encrypted data can never be read again. Back up the key offline in two copies and store them in separate locations.

    Step 2: Configure the Key Source and Switch the Startup Script

    Stop the Ragic service, and make sure the Java process has fully exited.

    Edit conf/ragic.properties and add the following two parameters. If a setting with the same name already exists, modify that line instead of adding a duplicate.
    • DB_ENCRYPTION_ACCOUNTS: Specifies the databases to encrypt.
    • DB_ENCRYPTION_MASTER_KEY: Specifies the key source.
    • Linux
    DB_ENCRYPTION_ACCOUNTS=
    DB_ENCRYPTION_MASTER_KEY=file:/mnt/ragic-key/ragic/db-master.key
    • Windows
    DB_ENCRYPTION_ACCOUNTS=
    DB_ENCRYPTION_MASTER_KEY=file:E:/RagicKey/db-master.key
    Leave the value of DB_ENCRYPTION_ACCOUNTS blank for now, but the key must exist, and it must be placed before the key line in this order. After file:, use the actual absolute path with forward slashes and no quotation marks.

    Change the ragic_dbv7.sh (Linux) or ragic_dbv7.bat (Windows) you currently use to the same-version ragic_dbv7enc.sh (Linux) or ragic_dbv7enc.bat (Windows), keep the original startup mode, and restart the Ragic service. On Linux, if you modified a systemd unit or drop-in, run systemctl daemon-reload before starting so that systemd reloads the service configuration.

    Check the contents of log/ragic.out since this startup, and record the full fingerprint from the following message:

    • Linux
    Log encryption master key version 1 fingerprint 【full fingerprint, 32 hexadecimal characters】 (record it as DB_ENCRYPTION_MASTER_KEY_FINGERPRINT in conf/ragic.properties to have a wrong key refused)

    • Windows

    Log encryption master key version 1 fingerprint 【full fingerprint, 32 hexadecimal characters】 (record it as DB_ENCRYPTION_MASTER_KEY_FINGERPRINT in conf\ragic.properties to have a wrong key refused)

    Step 3: Set the Key Fingerprint

    Stop the Ragic service, enter the fingerprint you recorded in Step 2 in the configuration file, and keep the original key source:

    • Linux

    DB_ENCRYPTION_ACCOUNTS=
    DB_ENCRYPTION_MASTER_KEY=file:/mnt/ragic-key/ragic/db-master.key
    DB_ENCRYPTION_MASTER_KEY_FINGERPRINT=【full fingerprint recorded in Step 2】
    • Windows
    DB_ENCRYPTION_ACCOUNTS=
    DB_ENCRYPTION_MASTER_KEY=file:E:/RagicKey/db-master.key
    DB_ENCRYPTION_MASTER_KEY_FINGERPRINT=【full fingerprint recorded in Step 2】
    Restart Ragic the same way you did in Step 2, and confirm that this startup's log no longer shows the prompt to record the fingerprint and has no key provider errors.

    Note: You must set the correct key fingerprint before enabling encryption for any account. Otherwise, the system refuses to open that account.

    Step 4: Back Up and Specify the Databases

    After confirming that the Ragic service has fully stopped, copy the entire cust/data directory to a brand-new backup destination to make a full physical backup, and verify that the backup is complete and readable.

    After the backup is complete, modify DB_ENCRYPTION_ACCOUNTS in conf/ragic.properties and enter the databases to encrypt. Use the actual database directory names under cust/data, with exactly the same capitalization. For example:
    DB_ENCRYPTION_ACCOUNTS=default

    An On-premises Private Server includes the account database (ragic) and the user database (default) by default. To also encrypt the account database, separate the names with a semicolon. For example:

    DB_ENCRYPTION_ACCOUNTS=default;ragic

    If you set both default and ragic, you must also complete the conversion of both databases in Step 5.

    After saving the changes, start the Ragic service with ragic_dbv7enc.sh (Linux) or ragic_dbv7enc.bat (Windows), confirm that data can be opened, written, and read back, and then stop the service.

    At this point, only newly created database files are encrypted. You must still complete the conversion in Step 5 for existing files before the full encryption is complete.

    Step 5: Convert Existing Data to Encrypted Format

    In this step, you export the existing data and load it into a new encrypted database. After verification, you replace the original database with the new one.

    Ragic must stay stopped during this step.

    5.1 Prepare the Conversion Directories

    Use a separate working directory for each database you want to encrypt. For example, default and ragic must be handled separately.

    The following uses default as an example. Adjust the paths and database names for your environment, and run the following commands in order in the same Bash session (Linux) or PowerShell window (Windows):

    • Linux

    # Stop on unhandled command errors. You still need to check the error messages of each JE tool
    set -e
    
    # Allow only the current user to access the newly created working directory and export files
    umask 077
    
    # RagicHome: the Ragic installation directory. Set this value for your environment first
    
    # MigrationDir: root path of the working directory for this conversion, used to store export files and the new encrypted data
    
    # Name of the Ragic database directory to encrypt in this run, such as default or ragic
    AccountName='default'
    
    # Source database directory, composed of the installation directory and the database name
    EnvHome="$RagicHome/cust/data/$AccountName"
    
    # Working directory for this database conversion. Use a different path for each database
    WorkDir="$MigrationDir/$AccountName/main"
    
    # Stores the reloaded encrypted data
    NewEnv="$WorkDir/encrypted"
    
    # Stores the export files from before and after the conversion, for comparing contents
    DumpDir="$WorkDir/dump"
    
    # Use a brand-new working directory to avoid mixing in data from earlier conversions
    if [ -e "$WorkDir" ]; then
        echo 'The working directory already exists. Verify it and use a new directory.' >&2
        exit 1
    fi
    
    # Create the directories for the new encrypted data and the export files
    mkdir -p -- "$NewEnv" "$DumpDir"
    • Windows (PowerShell)
    # $RagicHome: the Ragic installation directory
    
    # $MigrationDir: root path of the working directory for this conversion, used to store export files and the new encrypted data
    
    # Name of the Ragic database directory to encrypt in this run, such as default or ragic
    $AccountName = 'default'
    
    # Source database directory, composed of the installation directory and the database name
    $EnvHome = Join-Path $RagicHome "cust\data\$AccountName"
    
    # Working path for this database's main directory. Use a different path for each database
    $WorkDir = Join-Path $MigrationDir "$AccountName\main"
    
    # Stores the reloaded encrypted data
    $NewEnv = Join-Path $WorkDir 'encrypted'
    
    # Stores the export files from before and after the conversion, for comparing contents
    $DumpDir = Join-Path $WorkDir 'dump'
    
    # Use a brand-new working directory to avoid mixing in data from earlier conversions
    if (Test-Path -LiteralPath $WorkDir) {
        throw 'The working directory already exists. Verify it and use a new directory.'
    }
    
    # Create the directories for the new encrypted data and the export files
    New-Item -ItemType Directory -Path $NewEnv, $DumpDir | Out-Null
    Set the parameters used by the encryption tools, and enable encryption in the new directory:

    • Linux
    # Java startup parameter array shared by the JE tools that follow
    # "${JeArgs[@]}" expands this set of parameters item by item when a tool is called
    JeArgs=(
        '-Dje.log.encryption.keyProvider=com.sleepycat.je.log.PropertiesFileKeyProvider'
        "-Dje.log.encryption.propertiesFile=$RagicHome/conf/ragic.properties"
        '-cp' "$RagicHome/lib/db/je7enc/je-7.5.11-ragic.jar"
    )
    
    # Explicitly require the new directory to produce encrypted files
    printf '%s\n' 'je.log.encryption.encryptNewFiles=true' > "$NewEnv/je.properties"
    • Windows (PowerShell)
    # Java startup parameter array shared by the JE tools that follow
    # @JeArgs expands this set of parameters when a tool is called
    $JeArgs = @(
        '-Dje.log.encryption.keyProvider=com.sleepycat.je.log.PropertiesFileKeyProvider'
        "-Dje.log.encryption.propertiesFile=$RagicHome\conf\ragic.properties"
        '-cp', "$RagicHome\lib\db\je7enc\je-7.5.11-ragic.jar"
    )
    
    # Explicitly require the new directory to produce encrypted files
    Set-Content -LiteralPath "$NewEnv\je.properties" -Encoding Ascii `
        -Value 'je.log.encryption.encryptNewFiles=true'
    Note: Export files contain plaintext data that can be restored. Control access to them carefully.

    5.2 Export and Load the Data

    First, list the internal JE databases in the source directory:

    • Linux
    # JavaBin: full path of the Java executable used to start Ragic. Set this value for your environment first
    
    # List the names of all internal JE databases in the source directory
    # Every name in the list must be converted and compared separately in the steps that follow
    "$JavaBin" "${JeArgs[@]}" com.sleepycat.je.util.DbDump -h "$EnvHome" -l
    • Windows (PowerShell)
    # $JavaBin: full path of the Java executable used to start Ragic
    
    # List the names of all internal JE databases in the source directory
    # Every name in the list must be converted and compared separately in the steps that follow
    & $JavaBin @JeArgs com.sleepycat.je.util.DbDump -h $EnvHome -l
    Every name in the list must be processed. The following uses one of the names, p, as an example, exporting it and loading it into the new directory:

    • Linux
    # Specify the internal database name for this run. This example uses p from the list
    DbName='p'
    
    # Path of the file exported from the original database
    Before="$DumpDir/$DbName.before.dump"
    
    # Path of the file re-exported from the new encrypted database
    After="$DumpDir/$DbName.after.dump"
    
    # Export the specified internal database from the original database
    "$JavaBin" "${JeArgs[@]}" com.sleepycat.je.util.DbDump -h "$EnvHome" -s "$DbName" -f "$Before"
    
    # Load the exported data into the new directory with encryption enabled
    "$JavaBin" "${JeArgs[@]}" com.sleepycat.je.util.DbLoad -h "$NewEnv" -s "$DbName" -f "$Before"
    • Windows (PowerShell)
    # Specify the internal database name for this run. This example uses p from the list
    $DbName = 'p'
    
    # Path of the file exported from the original database
    $Before = Join-Path $DumpDir "$DbName.before.dump"
    
    # Path of the file re-exported from the new encrypted database
    $After = Join-Path $DumpDir "$DbName.after.dump"
    
    # Export the specified internal database from the original database
    & $JavaBin @JeArgs com.sleepycat.je.util.DbDump -h $EnvHome -s $DbName -f $Before
    
    # Load the exported data into the new directory with encryption enabled
    & $JavaBin @JeArgs com.sleepycat.je.util.DbLoad -h $NewEnv -s $DbName -f $Before
    Then export the same internal database from the new directory, and compare the contents from before and after the conversion:

    • Linux
    # Re-export the same internal database from the new directory
    "$JavaBin" "${JeArgs[@]}" com.sleepycat.je.util.DbDump -h "$NewEnv" -s "$DbName" -f "$After"
    
    # Calculate the SHA-256 of both export files
    # The hashes of the two files must be identical to confirm that the exported contents are the same before and after the conversion
    sha256sum -- "$Before" "$After"
    • Windows (PowerShell)
    # Re-export the same internal database from the new directory
    & $JavaBin @JeArgs com.sleepycat.je.util.DbDump -h $NewEnv -s $DbName -f $After
    
    # Calculate the SHA-256 of both export files
    # The hashes of the two files must be identical to confirm that the exported contents are the same before and after the conversion
    Get-FileHash -LiteralPath $Before, $After -Algorithm SHA256
    The hashes of the two files should be identical, and the last line of each export file should be DATA=END.

    After each command, confirm that there are no error messages. If an error occurs or the contents do not match, stop and do not switch the production data. Do not rely on the command exit code alone to determine success.

    5.3 Verify the New Database

    After all internal databases are converted, confirm that the database list in the new directory matches the source:

    • Linux
    # List the internal database names in the new directory and confirm they match the source list
    "$JavaBin" "${JeArgs[@]}" com.sleepycat.je.util.DbDump -h "$NewEnv" -l
    • Windows (PowerShell)
    # List the internal database names in the new directory and confirm they match the source list
    & $JavaBin @JeArgs com.sleepycat.je.util.DbDump -h $NewEnv -l
    Check the integrity of the database files:

    • Linux
    # Verify the integrity of all JE log files in the new directory
    "$JavaBin" "${JeArgs[@]}" com.sleepycat.je.util.DbVerifyLog -h "$NewEnv"
    • Windows (PowerShell)
    # Verify the integrity of all JE log files in the new directory
    & $JavaBin @JeArgs com.sleepycat.je.util.DbVerifyLog -h $NewEnv
    Check the encryption status of each file. The following command lists only the file header records:

    • Linux
    # List only the file header records to check whether each file has the encryption flag
    # -ty 25 specifies the FileHeader record type
    # Every file header should contain encrypted="true"
    "$JavaBin" "${JeArgs[@]}" com.sleepycat.je.util.DbPrintLog -h "$NewEnv" -ty 25
    • Windows (PowerShell)
    # List only the file header records to check whether each file has the encryption flag
    # -ty 25 specifies the FileHeader record type
    # Every file header should contain encrypted="true"
    & $JavaBin @JeArgs com.sleepycat.je.util.DbPrintLog -h $NewEnv -ty 25
    Every file header should contain:
    encrypted="true"

    Switch over only after all checks pass.

    5.4 Switch to the Encrypted Database

    After confirming that all databases are converted and verified, keep Ragic stopped and perform the following in order:

    1. Keep the original files
    Move all .jdb files in the original database directory ($EnvHome) to a separate backup directory. Store each database's files separately, and keep them until post-startup verification is complete.

    2. Put the encrypted files in place
    Copy all .jdb files in the new encrypted directory ($NewEnv) back to the original database directory ($EnvHome). Replace the whole set. Do not mix .jdb files from before and after the conversion.

    3. Keep the other files
    Leave attachments, search indexes, and other non-.jdb files in the original directory as they are. The je.properties file in the new encrypted directory is used only for the conversion and does not need to be copied back.

    4. Verify the files and permissions
    Confirm that the list and contents of the copied .jdb files match the new encrypted directory, and that the operating system account that runs Ragic has read and write permission.

    If you are processing multiple databases (for example, default and ragic), complete the steps above for each directory, and then start Ragic and perform the verification in Step 6.

    If an error occurs during the switch, keep Ragic stopped and start it again only after all files are fully restored.

    Step 6: Post-Startup Verification

    After switching all databases, start Ragic with ragic_dbv7enc.sh (Linux) or ragic_dbv7enc.bat (Windows), and confirm the following in order:

    1. Log in normally, and confirm that the databases and forms open normally.

    2. Open existing entries, and confirm that data and attachments can be read normally and that search works.

    3. Create a test entry, enter RAGIC_ENCRYPTION_TEST_12345678 in a text field, save it, reopen it, and confirm that the content is correct.

    4. Stop Ragic normally, search the production database that stores the test entry as described in Raw File String Check below, and confirm that the test string cannot be found in the raw .jdb files.

    5. Restart Ragic, and confirm again that both the existing entries and the new test entry can be read.

    6. Check the Log encryption messages in log/ragic.out since this startup, as well as log/BDBMgr.txt. If log/dbEncryption.log was generated, also check whether ENCRYPTION REFUSAL appears. Confirm that there are no encryption errors or database open, read, or write errors.

    Raw File String Check

    Run this check after stopping Ragic in item 4, and make sure $EnvHome points to the production database directory that stores the test entry. This check uses a test string made up of English letters, numbers, and underscores. If you use a different string, the entry content and $TestText below must match exactly, including capitalization.

    • Linux

    # EnvHome: production database directory that stores the test entry, such as cust/data/default
    
    # The string written to the test entry. It must match the entry content exactly
    TestText='RAGIC_ENCRYPTION_TEST_12345678'
    
    # All .jdb files to check. If there are no files, the array stays empty
    shopt -s nullglob
    JdbFiles=("$EnvHome"/*.jdb)
    if [ "${#JdbFiles[@]}" -eq 0 ]; then
        echo 'No .jdb files found. Verify the production database directory.' >&2
        exit 1
    fi
    
    # Treat the files as raw text and search for the fixed string, case-sensitive. When found, list only the file path
    if grep -aFl -- "$TestText" "${JdbFiles[@]}"; then
        echo 'Test string found. Stop the verification and find out why.' >&2
        exit 1
    else
        # GrepStatus: exit code of grep. 1 means the string was not found; any other non-zero value indicates an error
        GrepStatus=$?
        if [ "$GrepStatus" -ne 1 ]; then
            echo 'The string search failed and cannot be treated as a pass.' >&2
            exit 1
        fi
    fi
    • Windows (PowerShell)
    # Stop the check on file enumeration or read errors
    $ErrorActionPreference = 'Stop'
    
    # $EnvHome: production database directory that stores the test entry, such as cust/data/default
    
    # The string written to the test entry. It must match the entry content exactly
    $TestText = 'RAGIC_ENCRYPTION_TEST_12345678'
    
    # All .jdb files to check
    $JdbFiles = @(Get-ChildItem -LiteralPath $EnvHome -File -Filter '*.jdb')
    if ($JdbFiles.Count -eq 0) {
        throw 'No .jdb files found. Verify the production database directory.'
    }
    
    # $File is the file being checked. Read the raw bytes directly and search for the ASCII test string
    # When found, list only the file path and do not output the file contents
    foreach ($File in $JdbFiles) {
        if ([System.Text.Encoding]::ASCII.GetString([System.IO.File]::ReadAllBytes($File.FullName)).Contains($TestText)) {
            $File.FullName
        }
    }
    If a file path is listed, the test string was found. The check found no string only when there is no output and no errors. If the string is found or an error occurs, stop the verification and find out why before continuing.

    The string search is a supplementary check. You must still complete the encryption flag and file integrity verification in 5.3.

    Before verification is complete, keep the original data, backups, and export files. After verification is complete, handle them according to your agreed retention period and cleanup procedure.

    Rolling Back and Key Issues

    If No Encrypted Files Have Been Created

    If none of the production databases or their subdirectories has produced encrypted .jdb files yet, stop Ragic, set DB_ENCRYPTION_ACCOUNTS to blank, change the startup script back to ragic_dbv7.sh (Linux) or ragic_dbv7.bat (Windows), restart, and confirm that everything works normally.

    The rollback method depends on whether encrypted files have been created, not on the step number alone. The startup and write test in Step 4 may already produce encrypted files. If you cannot tell, follow the procedure in If Encrypted Files Have Been Created below.

    If Encrypted Files Have Been Created

    The original JE cannot open encrypted .jdb files, so you cannot simply switch back to the original startup script. Use the encryption tools to export the data, load it into a brand-new plaintext directory with the original JE, and switch only after verification is complete.

    Keep Ragic stopped during the rollback, and keep the compatible encryption JAR, the required keys, and the fingerprint. Export files and the rolled-back data are plaintext. Restrict access to the working directory.

    1. Prepare the Rollback Directories and Tools
    Roll back each database directory that contains encrypted files separately, for example default and ragic. The following uses default as an example.

    First, set the three base paths below, and run the following commands in order in the same Bash session (Linux) or PowerShell window (Windows):

    • Linux
    # Stop on unhandled command errors. You still need to check the error messages of each JE tool
    set -e
    
    # Allow only the current user to access the newly created working directory and export files
    umask 077
    
    # RagicHome: the Ragic installation directory. Set this value for your environment first
    
    # JavaBin: full path of the Java executable used to start Ragic. Set this value for your environment first
    
    # MigrationDir: root path of the rollback working directory, used to store export files and the new plaintext database
    
    # Name of the Ragic database directory to roll back in this run
    AccountName='default'
    
    # Production database directory to convert back to plaintext
    EnvHome="$RagicHome/cust/data/$AccountName"
    
    # Separate working directory for this rollback
    WorkDir="$MigrationDir/$AccountName/rollback/main"
    
    # Stores the reloaded plaintext database
    NewEnv="$WorkDir/plain"
    
    # Stores the export files from before and after the rollback, for comparing contents
    DumpDir="$WorkDir/dump"
    
    # Use a brand-new working directory to avoid mixing in data from earlier runs
    if [ -e "$WorkDir" ]; then
        echo 'The rollback working directory already exists. Verify it and use a new directory.' >&2
        exit 1
    fi
    
    # Create the directories for the new plaintext database and the export files
    mkdir -p -- "$NewEnv" "$DumpDir"
    • Windows (PowerShell)
    # $RagicHome: the Ragic installation directory
    
    # $JavaBin: full path of the Java executable used to start Ragic
    
    # $MigrationDir: root path of the rollback working directory, used to store export files and the new plaintext database
    
    # Name of the Ragic database directory to roll back in this run
    $AccountName = 'default'
    
    # Production database directory to convert back to plaintext
    $EnvHome = Join-Path $RagicHome "cust\data\$AccountName"
    
    # Separate working directory for this rollback
    $WorkDir = Join-Path $MigrationDir "$AccountName\rollback\main"
    
    # Stores the reloaded plaintext database
    $NewEnv = Join-Path $WorkDir 'plain'
    
    # Stores the export files from before and after the rollback, for comparing contents
    $DumpDir = Join-Path $WorkDir 'dump'
    
    # Use a brand-new working directory to avoid mixing in data from earlier runs
    if (Test-Path -LiteralPath $WorkDir) {
        throw 'The rollback working directory already exists. Verify it and use a new directory.'
    }
    
    # Create the directories for the new plaintext database and the export files
    New-Item -ItemType Directory -Path $NewEnv, $DumpDir | Out-Null
    Set the startup parameters for the encryption tools and the original JE tools separately:

    • Linux
    # Java startup parameters for the encryption tools, used to read the original encrypted database
    # "${JeArgs[@]}" expands this set of parameters item by item and obtains the key and fingerprint through the original configuration file
    JeArgs=(
        '-Dje.log.encryption.keyProvider=com.sleepycat.je.log.PropertiesFileKeyProvider'
        "-Dje.log.encryption.propertiesFile=$RagicHome/conf/ragic.properties"
        '-cp' "$RagicHome/lib/db/je7enc/je-7.5.11-ragic.jar"
    )
    
    # Java startup parameters for the original JE tools, used to load and verify the new plaintext database
    # "${PlainJeArgs[@]}" expands this set of parameters item by item and loads only the original JE JAR
    PlainJeArgs=('-cp' "$RagicHome/lib/db/je7/je-7.5.11.jar")
    • Windows (PowerShell)
    # Java startup parameters for the encryption tools, used to read the original encrypted database
    # @JeArgs expands this set of parameters and obtains the key and fingerprint through the original configuration file
    $JeArgs = @(
        '-Dje.log.encryption.keyProvider=com.sleepycat.je.log.PropertiesFileKeyProvider'
        "-Dje.log.encryption.propertiesFile=$RagicHome\conf\ragic.properties"
        '-cp', "$RagicHome\lib\db\je7enc\je-7.5.11-ragic.jar"
    )
    
    # Java startup parameters for the original JE tools, used to load and verify the new plaintext database
    # @PlainJeArgs expands this set of parameters and loads only the original JE JAR
    $PlainJeArgs = @('-cp', "$RagicHome\lib\db\je7\je-7.5.11.jar")
    Keep the new plaintext directory brand new. Do not put the je.properties encryption configuration file used in Step 5 in it.

    2. Export and Load the Plaintext Database
    First, list all internal databases in the source directory:

    • Linux
    # Use the encryption tools to list the names of all internal databases in the source
    "$JavaBin" "${JeArgs[@]}" com.sleepycat.je.util.DbDump -h "$EnvHome" -l
    • Windows (PowerShell)
    # Use the encryption tools to list the names of all internal databases in the source
    & $JavaBin @JeArgs com.sleepycat.je.util.DbDump -h $EnvHome -l
    Every name in the list must go through the following export, load, and comparison separately. The following uses p as an example:

    • Linux
    # Internal database name for this run. Adjust it for each name in the source list
    DbName='p'
    
    # Plaintext file exported from the original encrypted database
    Before="$DumpDir/$DbName.before.dump"
    
    # File re-exported from the new plaintext database
    After="$DumpDir/$DbName.after.dump"
    
    # Use the encryption tools to read and export the source data
    "$JavaBin" "${JeArgs[@]}" com.sleepycat.je.util.DbDump -h "$EnvHome" -s "$DbName" -f "$Before"
    
    # Use the original JE to load the data into the new plaintext directory
    "$JavaBin" "${PlainJeArgs[@]}" com.sleepycat.je.util.DbLoad -h "$NewEnv" -s "$DbName" -f "$Before"
    • Windows (PowerShell)
    # Internal database name for this run. Adjust it for each name in the source list
    $DbName = 'p'
    
    # Plaintext file exported from the original encrypted database
    $Before = Join-Path $DumpDir "$DbName.before.dump"
    
    # File re-exported from the new plaintext database
    $After = Join-Path $DumpDir "$DbName.after.dump"
    
    # Use the encryption tools to read and export the source data
    & $JavaBin @JeArgs com.sleepycat.je.util.DbDump -h $EnvHome -s $DbName -f $Before
    
    # Use the original JE to load the data into the new plaintext directory
    & $JavaBin @PlainJeArgs com.sleepycat.je.util.DbLoad -h $NewEnv -s $DbName -f $Before
    Then use the original JE to export the same internal database, and confirm that the contents match:

    • Linux
    # Use the original JE to re-export the data from the new plaintext database
    "$JavaBin" "${PlainJeArgs[@]}" com.sleepycat.je.util.DbDump -h "$NewEnv" -s "$DbName" -f "$After"
    
    # Calculate the SHA-256 of the export files from before and after the rollback. The hashes of the two files must be identical
    sha256sum -- "$Before" "$After"
    • Windows (PowerShell)
    # Use the original JE to re-export the data from the new plaintext database
    & $JavaBin @PlainJeArgs com.sleepycat.je.util.DbDump -h $NewEnv -s $DbName -f $After
    
    # Calculate the SHA-256 of the export files from before and after the rollback. The hashes of the two files must be identical
    Get-FileHash -LiteralPath $Before, $After -Algorithm SHA256
    The hashes of the two files must be identical, and the last line of each export file must be DATA=END. After each command, confirm that there are no error messages. Do not rely on the exit code alone to determine success. If there is an error or the comparison does not match, stop and do not switch the production data.

    3. Verify the Plaintext Database
    After all internal databases are loaded and compared, use the original JE to confirm that the list matches the source, and verify file integrity:

    • Linux
    # Use the original JE to list the internal databases in the new plaintext directory and confirm they match the source list
    "$JavaBin" "${PlainJeArgs[@]}" com.sleepycat.je.util.DbDump -h "$NewEnv" -l
    
    # Use the original JE to verify all log files in the new plaintext directory
    "$JavaBin" "${PlainJeArgs[@]}" com.sleepycat.je.util.DbVerifyLog -h "$NewEnv"
    • Windows (PowerShell)
    # Use the original JE to list the internal databases in the new plaintext directory and confirm they match the source list
    & $JavaBin @PlainJeArgs com.sleepycat.je.util.DbDump -h $NewEnv -l
    
    # Use the original JE to verify all log files in the new plaintext directory
    & $JavaBin @PlainJeArgs com.sleepycat.je.util.DbVerifyLog -h $NewEnv
    Switch over only after confirming that there are no error messages. Every database directory that contains encrypted files must go through the processing above separately.

    4. Switch Back to the Plaintext Database
    Keep Ragic stopped, and perform the following in order for each verified database directory:

    1. Move all .jdb files in the production directory ($EnvHome) to a separate backup directory, and store each database separately.

    2. Copy all .jdb files in the new plaintext directory ($NewEnv) back to the corresponding production directory ($EnvHome). Replace the whole set. Do not mix files from before and after the rollback.

    3. Leave attachments, search indexes, and other non-.jdb files as they are. Confirm that the list and contents of the copied .jdb files match the new plaintext directory, and that the operating system account that runs Ragic has read and write permission.

    After switching all the related directories, set DB_ENCRYPTION_ACCOUNTS to blank, and change the service startup script back to ragic_dbv7.sh (Linux) or ragic_dbv7.bat (Windows).

    If an error occurs during the switch, keep Ragic stopped and start it again only after all files are fully restored.

    5. Post-Rollback Verification
    Start Ragic with ragic_dbv7.sh (Linux) or ragic_dbv7.bat (Windows), and confirm that you can log in, open forms, and read existing data and attachments, and that search and creating entries work normally. After stopping and restarting normally, confirm again that both existing and new entries can be read. Then check log/ragic.out, log/BDBMgr.txt, and log/dbEncryption.log (if present) since this startup, and confirm that there are no database open, read, write, or encryption-related errors.

    Before verification is complete, keep the original encrypted files, backups, keys, and export files. After that, handle them according to your agreed retention period. As long as you keep an encrypted backup, you must also keep the corresponding key and a compatible tool.

    Troubleshooting Key Issues

    If the key disk is not mounted, the path is incorrect, or permissions are insufficient, databases that require the key cannot be opened. Check the disk mount, the configured path, and the read permission of the operating system account that runs Ragic. After resolving the problem, restart Ragic.

    If the shared ragic account database also requires the key, features such as login may be affected as well. If the entire ragic.properties file cannot be read or required settings are missing, the impact may extend to the whole service.

    Operations and Feature Impact

    1. Verify the key is readable before startup
    Before starting Ragic, verify that the key disk is mounted, the key path is correct, and the operating system account that runs Ragic has read permission. Include this check in your boot procedure.

    2. Check the logs regularly
    Check log/ragic.out, log/BDBMgr.txt, and log/dbEncryption.log (if present). If ENCRYPTION REFUSAL or another database error appears, keep the complete error message and check the key and startup settings.

    3. Verify the encryption settings after updates
    Every patch you apply must include the matching version of the encryption component, lib/db/je7enc/je-7.5.11-ragic.jar. After updating, verify that the file still exists and that the service is still started with ragic_dbv7enc.sh (Linux) or ragic_dbv7enc.bat (Windows).

    4. Keep the keys needed for backups
    As long as you keep an encrypted backup, you must keep all keys that backup requires. When restoring, use a compatible encryption build, and first confirm in a test environment that the data can be read normally.

    Share your feedback with Ragic

    What would you like to tell us?(required, multi select)

    Please provide detailed explanations for the selected items above:

    Screenshots to help us better understand your feedback:

    Thank you for your valuable feedback!

    Start Ragic for free

    Sign up with Google

    Ragic, Inc.
    1-888-666-8037
    info@ragic.com
    440 N Barranca Ave #8198, Covina, CA 91723, U.S.A.
    Terms of Service | Privacy Policy | Cookie Settings