Foreword
Due to the operation and maintenance system involved in rights management and user statistics, Gitlab user data needs to be extracted and entered into the house of self-built platform statistics authority.
This article will Gitlab user information data bulk export operation instructions!
Thinking
A) To export the data volume, a first idea is of course a corresponding database in the database, the table data can be derived;
B) via Navicat Database tool to connect Gitlab the Postgresql database, can easily find relevant data and information export, but the tools in computer locally, Gitlab in the server, there is a connection authorization, connection information such as configuration, these operations may involve service restart other operations, there is a potential hazard to the Gitlab active service, it is deprecated tool mode;
C) Therefore, I choose: landing landing Gitlab server database, query data and information export operation;
operating
# Depending on the configuration file, locate relevant information
[root@l-git4 ~]# cat /var/opt/gitlab/gitlab-rails/etc/database.yml
# View Gitlab corresponding system users
[root@l-git4 ~]# cat /etc/passwd | grep gitlab
# According to information databases landing
# Switch User
[root@l-git4 ~]# su - gitlab-psql
# Log database (-h designated host, -d to specify the database)
-sh-4.2$ psql -h /var/opt/gitlab/postgresql -d gitlabhq_production
# View help
gitlabhq_production=# \h
# View database
gitlabhq_production=# \l
# View the table in the library (after executing the command, press the Enter key to display more table information)
gitlabhq_production=# \dt
# Through screening, can be found in the users table in the library, user-related information is recorded in the table!
# View users table structure
gitlabhq_production=# \d users
# View information table
gitlabhq_production=# SELECT * FROM users;
# View name field in the users table
gitlabhq_production=# SELECT name FROM users;
# Logout database
gitlabhq_production=# \q
Determining information table entry name field # users is the need to extract, for export operation
-sh-4.2$ echo 'select name from users;' |psql -h /var/opt/gitlab/postgresql -d gitlabhq_production > users.txt