GitLab: Terminal CMDS

Locked
User avatar
Mihai Romania
Posts: 60
Joined: 2023 May 03, 14:12
Location: ROMANIA
Contact:

GitLab: Terminal CMDS

Post by Mihai »

  • Starting a Rails console session:
Linux package (Omnibus):

Code: Select all

sudo gitlab-rails console
Docker:

Code: Select all

docker exec -it <container-id> gitlab-rails console
Self-compiled (source):

Code: Select all

sudo -u git -H bundle exec rails console -e production
Helm chart (Kubernetes):

Code: Select all

# find the pod
kubectl get pods --namespace <namespace> -lapp=toolbox

# open the Rails console
kubectl exec -it -c toolbox <toolbox-pod-name> -- gitlab-rails console
  • Unblock / Re-activate a user:

Code: Select all

user = User.find_by_email("[email protected]")
user.state = "active"
user.save
exit
  • Manual create a backup:

Code: Select all

gitlab-backup create GZIP_RSYNCABLE=yes
  • Regenerate Health Check Token via gitlab-rails console and retrieve the New Token:

Code: Select all

sudo gitlab-rails runner "ApplicationSetting.current.update!(health_check_access_token: SecureRandom.hex(20)); puts ApplicationSetting.current.health_check_access_token"
  • Manually set a Specific Health Check Token:

Code: Select all

sudo gitlab-rails runner "ApplicationSetting.current.update!(health_check_access_token: 'YOUR_CUSTOM_TOKEN')"
  • Force send mail confirmation code from CLI:

Code: Select all

sudo gitlab-rails console
user = User.find_by(email: '[email protected]')
user.send_confirmation_instructions
  • Test send mail configuration from CLI:

Code: Select all

sudo gitlab-rails console
Notify.test_email('[email protected]', 'Message Subject', 'Message Body').deliver_now
  • Change password for username from CLI:

Code: Select all

sudo gitlab-rails console
user = User.find_by_username('testuser)
user.password = 'YourNewSecurePassword'
user.password_confirmation = 'YourNewSecurePassword'
user.save!
  • PSQL Check for background migrations:

Code: Select all

sudo gitlab-psql -c "SELECT job_class_name, table_name, column_name, job_arguments FROM batched_background_migrations WHERE status NOT IN(3, 6);"
  • Rails query check pending background migrations:

Code: Select all

sudo gitlab-rails runner -e production 'puts Gitlab::BackgroundMigration.remaining'
sudo gitlab-rails runner -e production 'puts Gitlab::Database::BackgroundMigration::BatchedMigration.queued.count'
  • Rails query check for failed background migrations:

Code: Select all

sudo gitlab-rails runner -e production 'puts Gitlab::Database::BackgroundMigration::BatchedMigration.with_status(:failed).count'
I'm on LinkedIn
Locked