gitlab备份,还原,升级,更改root密码

一、备份和还原

1.备份

查看当前Gitlab版本cat /opt/gitlab/embedded/service/gitlab-rails/VERSION

13.10.0

查看备份路径

[root@localhost /]# cat /etc/gitlab/gitlab.rb | grep -v "#"

external_url 'http://10.19.49.203'   //安装设定的访问域名

gitlab_rails['manage_backup_path'] = true

gitlab_rails['backup_path'] = "/opt/backups"    //备份路径

备份命令gitlab-rake gitlab:backup:create

手动备份gitlab配置文件和项目文件

2.还原

gitlab中的相关进程

gitlab-ctl stop sidekiq

gitlab-ctl stop unicorn

恢复命令(gitlab-rake gitlab:backup:restore BACKUP=后面只需要备份文件中的那一段数字编号即可)

恢复完成后,重启gitlab

二、升级 

1.关闭gitlab服务

gitlab-ctl stop unicorn

gitlab-ctl stop sidekiq

gitlab-ctl stop nginx

2.备份gitlab

gitlab-rake gitlab:backup:create

3.下载gitlabRPM包并进行升级

使用 rpm -Uvh gitlab-ce-13.12.9-ce.0.el7.x86_64

4.启动并查看gitlab版本信息

gitlab-ctl reconfigure

gitlab-ctl restart

# head -1 /opt/gitlab/version-manifest.txt

gitlab-ce 13.12.9

三、找回root密码

输入命令:gitlab-rails console -e production
找到root用户user = User.where(id: 1).first
user = User.find_by(email: 'admin@example.com')

    修改密码 user.password = 'secret_pass'

     user.password_confirmation = 'secret_pass'

    保存 user.save!

    操作样例

root@www_001 ~]# gitlab-rails console -e production

--------------------------------------------------------------------------------

 Ruby:         ruby 2.7.2p137 (2020-10-01 revision 5445e04352) [x86_64-linux]

 GitLab:       13.12.9 (af9df3fee54) FOSS

 GitLab Shell: 13.18.1

 PostgreSQL:   12.6

--------------------------------------------------------------------------------

Loading production environment (Rails 6.0.3.7)

irb(main):001:0> user = User.where(id: 1).first

=> #<User id:1 @root>

irb(main):002:0> user.password = '66666666'

=> "66666666"

irb(main):003:0> user.password_confirmation = '66666666'

=> "66666666"

irb(main):004:0> user.save!

Enqueued ActionMailer::MailDeliveryJob (Job ID: 8698539c-b716-4ad5-9991-949e885e76b8) to Sidekiq(mailers) with arguments: "DeviseMailer", "password_change", "deliver_now", {:args=>[#<GlobalID:0x00007fd4a2a2f2a0 @uri=#<URI::GID gid://gitlab/User/1>>]}

=> true

irb(main):005:0> exit

 

注:升级完了以后除了root用户其他用户的密码需要重新配置

 

posted @   星尘yuan  阅读(293)  评论(0编辑  收藏  举报
编辑推荐:
· AI与.NET技术实操系列(二):开始使用ML.NET
· 记一次.NET内存居高不下排查解决与启示
· 探究高空视频全景AR技术的实现原理
· 理解Rust引用及其生命周期标识(上)
· 浏览器原生「磁吸」效果!Anchor Positioning 锚点定位神器解析
阅读排行:
· DeepSeek 开源周回顾「GitHub 热点速览」
· 物流快递公司核心技术能力-地址解析分单基础技术分享
· .NET 10首个预览版发布:重大改进与新特性概览!
· AI与.NET技术实操系列(二):开始使用ML.NET
· .NET10 - 预览版1新功能体验(一)
点击右上角即可分享
微信分享提示