1.修改配置文件
[root@gitlab ~/tlbb]# vim /etc/gitlab/gitlab.rb
[root@gitlab ~/tlbb]#
[root@gitlab ~/tlbb]# grep '^gitlab_rails' /etc/gitlab/gitlab.rb
gitlab_rails['manage_backup_path'] = true
gitlab_rails['backup_path'] = "/data/gitlab/backups"
gitlab_rails['backup_archive_permissions'] = 0644
gitlab_rails['backup_keep_time'] = 604800
2.配置文件生效
[root@gitlab ~/tlbb]# gitlab-ctl reconfigure
Starting Chef Client, version 12.12.15
resolving cookbooks for run list: ["gitlab"]
Synchronizing Cookbooks:
- gitlab (0.0.1)
- package (0.1.0)
- mattermost (0.1.0)
- consul (0.0.0)
- registry (0.1.0)
- gitaly (0.1.0)
- runit (0.14.2)
Installing Cookbook Gems:
Compiling Cookbooks...
3.手动备份
[root@gitlab ~/tlbb]# ls
1.txt 2.txt 3.txt dev01.log lixian.log master.txt test.txt Windows.lx
[root@gitlab ~/tlbb]# gitlab-rake gitlab:backup:create
Dumping database ...
4.查看备份文件
[root@gitlab ~/tlbb]# ll /data/gitlab/backups/
total 512
-rw-r--r-- 1 git git 522240 May 13 15:12 1589353976_2020_05_13_10.2.2_gitlab_backup.tar
5.删除远程仓库文件及本地文件
[root@gitlab ~/tlbb]# git rm -f *
rm '1.txt'
rm '2.txt'
rm '3.txt'
rm 'Windows.lx'
rm 'dev01.log'
rm 'lixian.log'
rm 'master.txt'
rm 'test.txt'
[root@gitlab ~/tlbb]# ls
[root@gitlab ~/tlbb]# git commit -m "del all file"
[master 8e07612] del all file
8 files changed, 0 insertions(+), 0 deletions(-)
delete mode 100644 1.txt
delete mode 100644 2.txt
delete mode 100644 3.txt
delete mode 100644 Windows.lx
delete mode 100644 dev01.log
delete mode 100644 lixian.log
delete mode 100644 master.txt
delete mode 100644 test.txt
[root@gitlab ~/tlbb]# git push -u origin master
Counting objects: 3, done.
Delta compression using up to 2 threads.
Compressing objects: 100% (1/1), done.
Writing objects: 100% (2/2), 185 bytes | 0 bytes/s, done.
Total 2 (delta 0), reused 0 (delta 0)
To git@10.0.0.100:Dev/tlbb.git
a26c31d..8e07612 master -> master
Branch master set up to track remote branch master from origin.
6.恢复数据
[root@gitlab ~/tlbb]# gitlab-ctl stop unicorn
ok: down: unicorn: 76s, normally up
[root@gitlab ~/tlbb]# gitlab-ctl stop sidekiq
ok: down: sidekiq: 73s, normally up
[root@gitlab ~/tlbb]# gitlab-rake gitlab:backup:restore BACKUP=1589353976_2020_05_13_10.2.2
#如果有要提示要输入yes即可
[root@gitlab ~/tlbb]# gitlab-ctl restart
7.发现web界面已经有了数据,然后拉取数据
[root@gitlab ~]# git clone git@10.0.0.100:Dev/tlbb.git
Cloning into 'tlbb'...
remote: Counting objects: 20, done.
remote: Compressing objects: 100% (11/11), done.
remote: Total 20 (delta 7), reused 20 (delta 7)
Receiving objects: 100% (20/20), done.
Resolving deltas: 100% (7/7), done.
[root@gitlab ~]# ls tlbb/
1.txt 2.txt 3.txt dev01.log lixian.log master.txt test.txt Windows.lx