备份gitlab代码仓库脚本

1.脚本能做什么

       将gitlab代码仓库备份并将备份迁移到指定服务器,此时我将代码仓库上传到了minio的某个bucket下,便于查看情况,本次脚本并没有做定时执行的脚本,所以脚本需要手动执行。

      文中涉及的配置服务器之间免密,以及授予脚本可执行权限这些一概不讲,太基础不会的自己百度。

2.脚本内容

      我的gitlab在docker容器里面,而映射的数据路径是/home/gitlab/data下,如果你的gitlab是原生方式安装,请以实际路径为准,一般在/var/opt/gitlab/backups下,备份思路是一样的。

     代码服务器与minio服务器做了免密登录,其实只要执行完脚本备份就可以了。没有minio手动拷贝到硬盘也是不错的选择。

#! /bin/bash
echo "开始删除映射backup目录下的文件"
cd /home/gitlab/data/backups/ && rm -rf ./*.tar
echo "delete done,开始执行备份"
docker exec gitlab gitlab-rake gitlab:backup:create
echo "生成的备份文件在------>>>>>>>>>/home/gitlab/data/backups"
cd /home/gitlab/data/backups
scp *.tar root@192.168.xx.xx:/home/minio/data/gitlab/

3.查看脚本执行情况

[root@localhost ~]# sh backup_gitlab.sh 
开始删除映射backup目录下的文件
delete done,开始执行备份
2023-03-14 07:21:49 +0000 -- Dumping database ... 
Dumping PostgreSQL database gitlabhq_production ... [DONE]
2023-03-14 07:21:50 +0000 -- done
2023-03-14 07:21:50 +0000 -- Dumping repositories ...
 * gitlab-instance-56925b38/Monitoring (@hashed/6b/86/6b86b273ff34fce19d6b804eff5a3f5747ada4eaa22f1d49c01e52ddb7875b4b) ... 

2023-03-14 07:21:56 +0000 -- done
2023-03-14 07:21:56 +0000 -- Dumping uploads ... 
2023-03-14 07:21:57 +0000 -- done
2023-03-14 07:21:57 +0000 -- Dumping builds ... 
2023-03-14 07:21:57 +0000 -- done
2023-03-14 07:21:57 +0000 -- Dumping artifacts ... 
2023-03-14 07:21:57 +0000 -- done
2023-03-14 07:21:57 +0000 -- Dumping pages ... 
2023-03-14 07:21:57 +0000 -- done
2023-03-14 07:21:57 +0000 -- Dumping lfs objects ... 
2023-03-14 07:21:57 +0000 -- done
2023-03-14 07:21:57 +0000 -- Dumping container registry images ... 
2023-03-14 07:21:57 +0000 -- [DISABLED]
Creating backup archive: 1678778517_2023_03_14_13.12.3_gitlab_backup.tar ... done
Uploading backup archive to remote storage  ... skipped
Deleting tmp directories ... done
done
done
done
done
done
done
done
Deleting old backups ... skipping
Warning: Your gitlab.rb and gitlab-secrets.json files contain sensitive data 
and are not included in this backup. You will need these files to restore a backup.
Please back them up manually.
Backup task is done.
生成的备份文件在------>>>>>>>>>/home/gitlab/data/backups
1678778517_2023_03_14_13.12.3_gitlab_backup.tar 

 minio看下,扔过去了

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值