Difference between revisions of "Restore HSM volumes"

(Created page with "=== <h1>Restore HSM volumes</h1> === <hr> <br> <h2>Problem</h2> How to restore lost HSM volume <h2>Solution:</h2> '''1)''' Restore an account backup to a new account <br...")
 
 
Line 18: Line 18:
 
Preliminary: you need to have the replacement HSM volume mounted at the same path as the old one. For example:  
 
Preliminary: you need to have the replacement HSM volume mounted at the same path as the old one. For example:  
  
<pre>% zmvolume -l  
+
<pre>zmvolume -l  
 
Volume id: 1  
 
Volume id: 1  
 
name: message1  
 
name: message1  
Line 39: Line 39:
 
compressed: false  
 
compressed: false  
 
current: true  
 
current: true  
 +
</pre>
  
</pre>
 
 
In the above example, /opt/zimbra/hsm was the HSM store. Mount the replacement at /opt/zimbra/hsm, and make sure to  
 
In the above example, /opt/zimbra/hsm was the HSM store. Mount the replacement at /opt/zimbra/hsm, and make sure to  
<pre>"chown zimbra:zimbra /opt/zimbra/hsm".
+
chown zimbra:zimbra /opt/zimbra/hsm  
</pre>
 
  
 
'''1)''' Restore from a full account backup to a new account:  
 
'''1)''' Restore from a full account backup to a new account:  
  
<pre>% zmrestore -rf -a account@example.com -ca -pre "hsm_" </pre>
+
zmrestore -rf -a account@example.com -ca -pre "hsm_"  
  
 
Depending on the HSM policy (30 days default), you need to be sure the latest full backup is newer than that (?). <br><br>
 
Depending on the HSM policy (30 days default), you need to be sure the latest full backup is newer than that (?). <br><br>
Line 53: Line 52:
 
'''2)''' Gather account data: <br>
 
'''2)''' Gather account data: <br>
  
<pre>2.1) Mailbox ID:  
+
* Mailbox ID:  
% zmprov gmi account@example.com | grep mailboxId  
+
zmprov gmi account@example.com | grep mailboxId  
Mailbox ID: 4  
+
Mailbox ID: 4  
  
2.2) Account Hash (substitute actual Mailbox ID):  
+
* Account Hash (substitute actual Mailbox ID):  
% perl -e "print (mailboxId>>12)"  
+
perl -e "print (mailboxId>>12)"  
Account Hash: 0   
+
Account Hash: 0   
  
2.3) Restored Mailbox ID:  
+
* Restored Mailbox ID:  
% zmprov gmi hsm_account@example.com | grep mailboxId  
+
zmprov gmi hsm_account@example.com | grep mailboxId  
Restored MailboxID: 37  
+
Restored MailboxID: 37  
  
2.4) Restored Account Hash (substitute actual Mailbox ID):  
+
* Restored Account Hash (substitute actual Mailbox ID):  
% perl -e "print (mailboxId>>12)"
+
perl -e "print (mailboxId>>12)"
Restored Account Hash: 0 </pre><br>
+
Restored Account Hash: 0 </pre><br>
  
 
'''3)''' Recreate the filesystem HSM path for the existing account (/opt/zimbra/hsm/Account Hash/MailboxID):  
 
'''3)''' Recreate the filesystem HSM path for the existing account (/opt/zimbra/hsm/Account Hash/MailboxID):  
<pre>% mkdir -p /opt/zimbra/hsm/0/4 </pre>
+
mkdir -p /opt/zimbra/hsm/0/4 </pre>
  
 
'''4)''' Move the HSM blobs from the restored account to the real account:  
 
'''4)''' Move the HSM blobs from the restored account to the real account:  
<pre>% mv /opt/zimbra/hsm/Restored Account Hash/Restored MailboxID/msg /opt/zimbra/hsm/Account Hash/MailboxID/  
+
mv /opt/zimbra/hsm/Restored Account Hash/Restored MailboxID/msg /opt/zimbra/hsm/Account Hash/MailboxID/  
  
 
Actual:  
 
Actual:  
% mv /opt/zimbra/hsm/0/37/msg /opt/zimbra/hsm/0/4/ </pre>
+
mv /opt/zimbra/hsm/0/37/msg /opt/zimbra/hsm/0/4/ </pre>
  
 
'''5)''' Delete the restored account:  
 
'''5)''' Delete the restored account:  
  
<pre>% zmprov da hsm_account@example.com   
+
zmprov da hsm_account@example.com   
  
 
'''6)''' Restart mailboxd for account to see HSM blobs:  
 
'''6)''' Restart mailboxd for account to see HSM blobs:  
  
% zmmailboxdctl restart </pre>
+
zmmailboxdctl restart </pre>
  
 
'''7)''' Log in to account (account@example.com) and verify HSM messages are there
 
'''7)''' Log in to account (account@example.com) and verify HSM messages are there
  
  
Raunaq Malik
+
 
 +
 
 +
Submitted by:  Raunaq Malik

Latest revision as of 10:48, 21 August 2017

Restore HSM volumes




Problem

How to restore lost HSM volume


Solution:

1) Restore an account backup to a new account
2) Recreate the filesystem HSM path for the existing account
3) Move the restored HSM blobs to the correct filesystem path
4) Delete the restored account

Preliminary: you need to have the replacement HSM volume mounted at the same path as the old one. For example:

zmvolume -l 
Volume id: 1 
name: message1 
type: primaryMessage 
path: /opt/zimbra/store 
compressed: false 
current: true 

Volume id: 2 
name: index1 
type: index 
path: /opt/zimbra/index 
compressed: false 
current: true 

Volume id: 3 
name: hsm1 
type: secondaryMessage 
path: /opt/zimbra/hsm 
compressed: false 
current: true 

In the above example, /opt/zimbra/hsm was the HSM store. Mount the replacement at /opt/zimbra/hsm, and make sure to

chown zimbra:zimbra /opt/zimbra/hsm 

1) Restore from a full account backup to a new account:

zmrestore -rf -a account@example.com -ca -pre "hsm_" 

Depending on the HSM policy (30 days default), you need to be sure the latest full backup is newer than that (?).

2) Gather account data:

  • Mailbox ID:
zmprov gmi account@example.com | grep mailboxId 
Mailbox ID: 4 
  • Account Hash (substitute actual Mailbox ID):
perl -e "print (mailboxId>>12)" 
Account Hash: 0  
  • Restored Mailbox ID:
zmprov gmi hsm_account@example.com | grep mailboxId 
Restored MailboxID: 37 
  • Restored Account Hash (substitute actual Mailbox ID):
perl -e "print (mailboxId>>12)"
Restored Account Hash: 0 </pre>

3) Recreate the filesystem HSM path for the existing account (/opt/zimbra/hsm/Account Hash/MailboxID):

mkdir -p /opt/zimbra/hsm/0/4 </pre>

4) Move the HSM blobs from the restored account to the real account:

mv /opt/zimbra/hsm/Restored Account Hash/Restored MailboxID/msg /opt/zimbra/hsm/Account Hash/MailboxID/ 

Actual:

mv /opt/zimbra/hsm/0/37/msg /opt/zimbra/hsm/0/4/ </pre>

5) Delete the restored account:

zmprov da hsm_account@example.com  

6) Restart mailboxd for account to see HSM blobs:

zmmailboxdctl restart </pre>

7) Log in to account (account@example.com) and verify HSM messages are there



Submitted by: Raunaq Malik

Jump to: navigation, search