Difference between revisions of "How to find and backup different COS users"

(Created page with "=How to find and backup different COS users= {{KB|{{ZC}}|{{ZCS 8.6}}|{{ZCS 8.5}}|{{ZCS 8.0}}|}} {{WIP}} ==Purpose== ==Resolution== '''8. Backup COS (if different from the...")
 
(Purpose)
 
(2 intermediate revisions by the same user not shown)
Line 1: Line 1:
=How to find and backup different COS users=
+
=How to backup & restore COS, including the COS users. =
 
{{KB|{{ZC}}|{{ZCS 8.6}}|{{ZCS 8.5}}|{{ZCS 8.0}}|}}
 
{{KB|{{ZC}}|{{ZCS 8.6}}|{{ZCS 8.5}}|{{ZCS 8.0}}|}}
 
{{WIP}}
 
{{WIP}}
Line 6: Line 6:
  
 
==Purpose==
 
==Purpose==
 +
 +
In this article we will show how to:
 +
*Back-up COS subtree (LDAP).
 +
*Find which users belong to which COS, and place them into different files, based on COS.
 +
*Restore COS subtree.
 +
*Assign users to specific COS
  
 
==Resolution==
 
==Resolution==
  
'''8. Backup COS (if different from the "source" server).'''
+
'''1. Backup COS.'''
  
If you have only the default COS on the "client", but its with different settings from the COS on the "source" server, you have to rename it and then import it under different name.  
+
This step assumes that you would like to migrate a server to another one, and this is a way to move just the COS to the other server.
  
 
*Download '''JXplorer''' from http://jxplorer.org/downloads/users.html   
 
*Download '''JXplorer''' from http://jxplorer.org/downloads/users.html   
Line 27: Line 33:
  
 
*From the left Tree View, expand '''cos'''.
 
*From the left Tree View, expand '''cos'''.
*Select the COS that you want to export&move to the "source" server.
+
*Select the COS that you want to export&move.
 
*From the File menu line above, click on LDIF '''>''' Export Subtree '''>''' Save on the local disk.  
 
*From the File menu line above, click on LDIF '''>''' Export Subtree '''>''' Save on the local disk.  
 
*Do that with all COS you want to move.  
 
*Do that with all COS you want to move.  
(leave the JXplorer open for the import)
 
 
-------
 
-------
'''9. Create files for each COS, and their respective user members.'''
+
'''2. Create files for each non-default COS, and their respective user members.'''
  mkdir /migration/cos_users
+
   
 +
This step assumes that you are going to move the users from this server to another, and you want to create file for each non-default COS, and to include their members in it.
 +
 
 +
A short script accomplishes that:
 +
 
 
<br>
 
<br>
 
  #!/bin/bash
 
  #!/bin/bash
Line 43: Line 52:
 
  # the end. Zimbra only detect users that are not in the default COS. Thus, every non detected user is in the default COS.  
 
  # the end. Zimbra only detect users that are not in the default COS. Thus, every non detected user is in the default COS.  
 
   
 
   
 +
mkdir /tmp/cos_users
 
  source ~/bin/zmshutil; zmsetvars
 
  source ~/bin/zmshutil; zmsetvars
 
   
 
   
Line 49: Line 59:
 
         id=`zmprov gc $i | grep -e "\bzimbraId\b"|cut -d " " -f 2`
 
         id=`zmprov gc $i | grep -e "\bzimbraId\b"|cut -d " " -f 2`
 
   
 
   
         ldapsearch -x -H $ldap_master_url -D $zimbra_ldap_userdn -w $zimbra_ldap_password| grep -e $id -e "dn: uid=" -e mail:|grep -v Email| grep -e zimbraCOSId -B1 -A1|grep mail|awk '{print $2}' > /migration/cos_users/$i
+
         ldapsearch -x -H $ldap_master_url -D $zimbra_ldap_userdn -w $zimbra_ldap_password| grep -e $id -e "dn: uid=" -e mail:|grep -v Email| grep -e zimbraCOSId -B1 -A1|grep mail|awk '{print $2}' > /tmp/cos_users/$i
 
   
 
   
 
  /bin/rm -rf /migration/cos_users/default*
 
  /bin/rm -rf /migration/cos_users/default*
 
   
 
   
 
  done
 
  done
 +
------
 +
'''3. How to restore COS.'''
  
 +
This step assumes you are restoring the backed up COS to the new server.
  
-----------
+
*Create new entry in the JXplorer as in point '''1''', but this time specify the "destination" server IP.  
 
 
'''1. Restore COS.'''
 
 
 
To import to the "source" server:
 
*Create new entry in the JXplorer as in the import, but this time specify the "source" server IP.  
 
 
*Click on the "cos"
 
*Click on the "cos"
 
*LDIF '''>''' Import File '''>''' Select File '''>''' Import
 
*LDIF '''>''' Import File '''>''' Select File '''>''' Import
 
<br>
 
<br>
 
Do that with all COS you want to import.  
 
Do that with all COS you want to import.  
 
+
----
'''6. Add the migrated users from the "client" to their respective COS on the "source".'''
+
'''4. This step assumes that you moved the users from the old to the new server, and this script will assign the correct COS to the migrated users.'''
 
<br>
 
<br>
  
Line 74: Line 82:
 
  # user to the COS.  
 
  # user to the COS.  
 
   
 
   
  for cos in `/bin/ls -1 /migration/cos_users | tr " " "\n"`
+
  for cos in `/bin/ls -1 /tmp/cos_users | tr " " "\n"`
 
  do
 
  do
  for i in `cat /migration/cos_users/$cos`
+
  for i in `cat /tmp/cos_users/$cos`
 
  do
 
  do
 
  zmprov sac $i $cos
 
  zmprov sac $i $cos
Line 85: Line 93:
  
 
==Additional Content==
 
==Additional Content==
 +
 +
'''References:'''
 +
https://wiki.zimbra.com/wiki/How_to_merge_two_independent_ZCS_servers_into_one
 +
  
  
 
{{Article Footer|Zimbra Collaboration 8.7, 8.6, 8.0| 24/12/2016}}
 
{{Article Footer|Zimbra Collaboration 8.7, 8.6, 8.0| 24/12/2016}}
 
{{NeedSME|SME1|SME2|COPY EDITOR}}
 
{{NeedSME|SME1|SME2|COPY EDITOR}}

Latest revision as of 12:36, 24 December 2016

How to backup & restore COS, including the COS users.

   KB 23121        Last updated on 2016-12-24  




0.00
(0 votes)



Purpose

In this article we will show how to:

  • Back-up COS subtree (LDAP).
  • Find which users belong to which COS, and place them into different files, based on COS.
  • Restore COS subtree.
  • Assign users to specific COS

Resolution

1. Backup COS.

This step assumes that you would like to migrate a server to another one, and this is a way to move just the COS to the other server.

Create new entry as follows:

Host: "client" server IP
Port 389 ; Protocol v3
Base DN: cn=zimbra

Authentication:

Level: User + Password
User DN: cn=config
Password is the output from: zmlocalconfig -s ldap_root_password

Click OK.

  • From the left Tree View, expand cos.
  • Select the COS that you want to export&move.
  • From the File menu line above, click on LDIF > Export Subtree > Save on the local disk.
  • Do that with all COS you want to move.

2. Create files for each non-default COS, and their respective user members.

This step assumes that you are going to move the users from this server to another, and you want to create file for each non-default COS, and to include their members in it.

A short script accomplishes that:


#!/bin/bash

# The result is a file/s for each COS, and the users within this specific COS
# Note: If there are no custom created COS, there will be no users listed in the default and default_external files. That 
# means all users are in the "default" COS.
# Since the default and the default_external files will contain no users, their respective files are deleted at 
# the end. Zimbra only detect users that are not in the default COS. Thus, every non detected user is in the default COS. 

mkdir /tmp/cos_users
source ~/bin/zmshutil; zmsetvars

for i in `zmprov gac`
   do
       id=`zmprov gc $i | grep -e "\bzimbraId\b"|cut -d " " -f 2`

       ldapsearch -x -H $ldap_master_url -D $zimbra_ldap_userdn -w $zimbra_ldap_password| grep -e $id -e "dn: uid=" -e mail:|grep -v Email| grep -e zimbraCOSId -B1 -A1|grep mail|awk '{print $2}' > /tmp/cos_users/$i

/bin/rm -rf /migration/cos_users/default*

done

3. How to restore COS.

This step assumes you are restoring the backed up COS to the new server.

  • Create new entry in the JXplorer as in point 1, but this time specify the "destination" server IP.
  • Click on the "cos"
  • LDIF > Import File > Select File > Import


Do that with all COS you want to import.


4. This step assumes that you moved the users from the old to the new server, and this script will assign the correct COS to the migrated users.

#!/bin/bash
# The script first list the exported cos names, then iterate through all members within this cos and finally assigns the 
# user to the COS. 

for cos in `/bin/ls -1 /tmp/cos_users | tr " " "\n"`
do
	for i in `cat /tmp/cos_users/$cos`
		do
		zmprov sac $i $cos
		done
done


Additional Content

References: https://wiki.zimbra.com/wiki/How_to_merge_two_independent_ZCS_servers_into_one


Verified Against: Zimbra Collaboration 8.7, 8.6, 8.0 Date Created: 24/12/2016
Article ID: https://wiki.zimbra.com/index.php?title=How_to_find_and_backup_different_COS_users Date Modified: 2016-12-24



Try Zimbra

Try Zimbra Collaboration with a 60-day free trial.
Get it now »

Want to get involved?

You can contribute in the Community, Wiki, Code, or development of Zimlets.
Find out more. »

Looking for a Video?

Visit our YouTube channel to get the latest webinars, technology news, product overviews, and so much more.
Go to the YouTube channel »


Wiki/KB reviewed by SME1 SME2 COPY EDITOR Last edit by Teodor Vizirov
Jump to: navigation, search