- Go to gitlab's task folder. Something like
cd /home/git/gitlab/lib/tasks
- Download rake task file by running
wget https://raw.githubusercontent.com/rahul286/gitlab-bulk-delete-users/master/bulk_delete.rake
- Open file in editor
vim bulk_delete.rake
- Change domain from
example.com
toyourdoamin.com
- Comment out
abort(...)
Line#12.
sudo -u git -H bundle exec rake gitlab:cleanup:delete_users_except_email_domain RAILS_ENV=production
This rake task...
- will NOT touch users if they are admin OR have email address ending in your
domain
. - will DELETE users if they have 0 project AND 0 issue AND 0 note.
- will BLOCK users if they have any single project OR issue OR note attached.
P.S. I forgot to test if user has snippets while cleaning our Gitlab. But I am 99.999999% sure that no deleted user has ever created any snippet. You will find some codes commented towards end. I ran a for loop on events to verify some users.
I also deleted all users who never logged in. Line#14-15