Exporting/Importing User, Groups, etc

Hello folks,

Wondering how we can export/import users (with their passwords) and their groups?

@fernie The admin API will not provide the password associated with the user object. So the only other way I suggest is direct SQL dump of the table / records you are interested in and importing that dump into the target system.

Which tables specifically :upside_down_face:?
auth_user, auth_user_groups and auth_group?

@fernie auth_user has the password for the users.

+--------------+--------------+------+-----+---------+----------------+
| Field        | Type         | Null | Key | Default | Extra          |
+--------------+--------------+------+-----+---------+----------------+
| id           | int(11)      | NO   | PRI | NULL    | auto_increment |
| password     | varchar(128) | NO   |     | NULL    |                |
| last_login   | datetime     | YES  |     | NULL    |                |
| is_superuser | tinyint(1)   | NO   |     | NULL    |                |
| username     | varchar(150) | NO   | UNI | NULL    |                |
| first_name   | varchar(30)  | NO   |     | NULL    |                |
| last_name    | varchar(30)  | NO   |     | NULL    |                |
| email        | varchar(254) | NO   |     | NULL    |                |
| is_staff     | tinyint(1)   | NO   |     | NULL    |                |
| is_active    | tinyint(1)   | NO   |     | NULL    |                |
| date_joined  | datetime     | NO   |     | NULL    |                |
+--------------+--------------+------+-----+---------+----------------+
1 Like

Which tables do we backup so we can bring the user Roles?

@fernie the rbac_role table contains the roles, and their mapping to users and groups.

1 Like