Export and Import Users from eFa

Mindwatering Incorporated

Author: Tripp W Black

Created: 03/13 at 01:51 PM

 

Category:
Linux
Other

Task:
If your eFa has multiple domains (transports) with more than one LDAP source, you can either configure eFa to used a merged LDAP directory, or you can update via SQL script.
If performing the latter, there is no easy way to migrate just users to a new empty eFA (VM template that has just been deployed) Export MailWatch users from eFA as back-up and re-import to restore.


Steps:
1. Backup the current users on the appliance:
[myadminid@efa5]$ sudo su -
[myadminid@efa5]$ cd /home/myadminid/tmp/
[root@efa5]# MAILWATCHSQLPWD=`grep MAILWATCHSQLPWD /etc/eFa/MailWatch-Config | sed 's/.*://'`
[root@efa5]# mysqldump -u mailwatch --password=$MAILWATCHSQLPWD mailscanner users > /home/myadminid/tmp/efa5_full_users_backup.sql
[root@efa5]# chown myadminid:myadminid efa5_full_users_backup.sql
[root@efa5]# exit


2. Analyze the backup:
The efa5_full_users_backup.sql file includes the commands to:
- Delete/drop the current users table.
- Create a replacement table
- Lock the table
- Import all the users
- Unlock the table
$ vi efa5_full_users_backup.sql
<review file, <esc>:q! to exit w/o saving>


3. Create a backup copy that will only contain the users:
a. Create the copy:
$ cp efa5_full_users_backup.sql efa5_users_import_only.sql

b. Remove the sections of the sql commands not wanted:
Editing notes:
- Entering quickly dd while not in insert mode allows deletion of the current line of the file
- Entering i allows to insert at the cursor point
- Entering a allows insert appending after the cursor point
- Entering /sometext will allow you to jump down to that text w/in the file. Click the <enter> key to drop out of the search at that point.
- Entering <esc>:wq is used to save and exit afterwards

$ vi efa5_users_import_only.sql

Task notes:
- Using dd, delete all the lines above this section listed below:
--
-- Dumping data for table `users`
--

- What about the admin account?
- - Each of the accounts have a unique key column value which is the first column in each record e.g. (91,'firstlast@mindwatering.net', ...)
- - One option is to run the import w/o the keys. The other option is restoring with only the first/original admin account in the view.
- - For this backup, we are removing this account as it will already exist after the init/configure of eFa.

Assuming your admin account is named admin:
- While not in insert mode enter:
/'admin'
- This will display a line starting with something like (51, 'admin', 'HashofPassword', ... ,'Administrator', -1)
- Arrow over until you are in front of the ( of (51. enter i (for insert).
- Using the delete key, remove all the characters slow enough to ensure that you only remove the one user, end after the close parens and comma. e.g. ),
- When done, enter <esc>:wq to save.

Save the user list for the new appliance.


4. Import the list to a new appliance.
[myadminid@efa5]$ sudo su -
[myadminid@efa5]$ cd /home/myadminid/tmp/
[root@efa5]# MAILWATCHSQLPWD=`grep MAILWATCHSQLPWD /etc/eFa/MailWatch-Config | sed 's/.*://'`
[root@efa5]# mysql -u mailwatch --password=$MAILWATCHSQLPWD mailscanner < /home/myadminid/tmp/efa5_users_import_only.sql


5. Verify the users in the MailWatch UI of eFa:
web browser --> efa5.mindwatering.net --> <login> --> TOOLS AND LINKS --> under Tools (heading) --> click User Management and verify all users are imported.



previous page

×