Moving Bamboo fails on import with Cipher issue
Asked by David Taylor:

We're moving Bamboo from Server2012 to Server2022. I'm following the Move instructions, installed the same version, but the Import fails:

2023-08-23 23:11:02,977 INFO \[http-nio-8085-exec-6\] \[InstanceSecretStorage\] Generating instance cipher key...  
2023-08-23 23:11:02,978 INFO \[http-nio-8085-exec-6\] \[InstanceSecretStorage\] Securely storing instance key...  
2023-08-23 23:11:03,061 INFO \[http-nio-8085-exec-6\] \[InstanceSecretStorage\] Generating instance initialisation vector...  
2023-08-23 23:11:03,072 INFO \[http-nio-8085-exec-6\] \[InstanceSecretStorage\] Instance cryptography initialised.  
2023-08-23 23:11:03,090 INFO \[http-nio-8085-exec-6\] \[SecretEncryptionServiceImpl\] Can't decrypt data. It's possible data was encrypted by different cipher. Run Bamboo with system property -Dbamboo.security.decryption.ignore.errors=true to ignore this error  
2023-08-23 23:11:03,092 WARN \[http-nio-8085-exec-6\] \[BambooStAXListImportStrategy$4$1\] Exception during processing crowdMemberships.membership #2  
com.google.common.util.concurrent.UncheckedExecutionException: java.lang.RuntimeException: org.bouncycastle.crypto.InvalidCipherTextException: pad block corrupted

I've tried copying the cipher file, but the whole configuration directory gets wiped out on Import anyway. If I return the cipher file just after Import starts, I then get:

2023-08-24 09:41:25,342 INFO \[http-nio-8085-exec-7\] \[XmlMigrator\] Importing with mapper: com.atlassian.bamboo.migration.stream.crowd.MembershipMapper@457247c5  
2023-08-24 09:41:25,344 INFO \[http-nio-8085-exec-7\] \[XmlMigrator\] Reading file: D:\\installers\\export_bambootwo_90304_20230823.zip\\db-export\\crowdMemberships.xml  
2023-08-24 09:41:25,991 FATAL \[http-nio-8085-exec-7\] \[SecretEncryptionServiceInternalImpl\]  
java.lang.IllegalArgumentException: Unable to read cipher data for 0. Reason: Database part of instance key is unavailable

The Move instructions are old - is there a newer process?

Thanks.


Answers:
author: Eduardo Alvarenga
body: Hello [@David Taylor](/t5/user/viewprofilepage/user-id/5294224)

Welcome to the **Atlassian Community**!

Can you share your Bamboo version?

Kind regards,

Eduardo Alvarenga  
Atlassian Support APAC

**--please don't forget to Accept the answer if the reply is helpful--**

comments: author: David Taylor
body: Hi, it's 9.3.2. I ended up going thru support, who pointed me at [\[BAM-22440\] Bamboo cannot import encrypted strings via Exported zip - Create and track feature requests for Atlassian products.](https://jira.atlassian.com/browse/BAM-22440)

This is the issue I was having.


author: Eduardo Alvarenga
body: Hey [@David Taylor](/t5/user/viewprofilepage/user-id/5294224)

Yeah, 9.3.2 has that bug. As you are running Windows, you'll have to adapt the Shell script on the workaround session to Windows.

Can you please test if the following PowerShell script works for you?

```
$BAMBOO_HOME = "C:\atlassian\application-data\bamboo"
$BAMBOO_USER = "bamboo"
$BAMBOO_GROUP = "bamboo"
$CIPHER_FILE = "C:\temp\cipher.key_0"

# Create the directories if they don't exist
if (!(Test-Path -Path "$BAMBOO_HOME\shared\configuration")) {
New-Item -ItemType Directory -Path "$BAMBOO_HOME\shared\configuration" -Force
}

# Create the wait.txt file
New-Item -ItemType File -Path "$BAMBOO_HOME\shared\configuration\wait.txt" -Force

# Wait for the deletion of the wait.txt file
while (Test-Path -Path "$BAMBOO_HOME\shared\configuration\wait.txt") {
Start-Sleep -Seconds 1
}

# Create the cipher directory and file if they don't exist
if (!(Test-Path -Path "$BAMBOO_HOME\shared\configuration\cipher\cipher.key_0")) {
New-Item -ItemType Directory -Path "$BAMBOO_HOME\shared\configuration\cipher" -Force
Copy-Item -Path $CIPHER_FILE -Destination "$BAMBOO_HOME\shared\configuration\cipher\cipher.key_0"
}
```

Thank you,

Eduardo Alvarenga  
Atlassian Support APAC

**--please don't forget to Accept the answer if the reply is helpful--**