美文网首页
内部代码仓库Gogs搭建及备份容灾

内部代码仓库Gogs搭建及备份容灾

作者: veeeeeeeeeeee | 来源:发表于2018-12-17 15:11 被阅读67次

项目:https://gogs.io

运行

docker run -d --name=gogs -p 10022:22 -p 10088:3000 -v /storage/app/gogs:/data gogs/gogs

挂载在/storage/app/gogs

配置文件:

APP_NAME = 内部协作开发仓库
RUN_USER = git
RUN_MODE = prod

[database]
DB_TYPE  = mysql
HOST     = 192.:13306
NAME     = gogs
USER     = root
PASSWD   = 
SSL_MODE = disable
PATH     = data/gogs.db

[repository]
ROOT = /data/git/gogs-repositories
ENABLE_LOCAL_PATH_MIGRATION = true  
FORCE_PRIVATE = false 
DISABLE_HTTP_GIT = false

[server]
DOMAIN           = 192.
HTTP_PORT        = 3000
ROOT_URL         = http://192.:10088/
DISABLE_SSH      = false
SSH_PORT         = 10022
START_SSH_SERVER = false
OFFLINE_MODE     = false

[mailer]
ENABLED = true
HOST= smtp.exmail.qq.com:465
USER= 
PASSWD=
FROM=`xx <xx@xxx.com>`
SUBJECT_PREFIX=`[xxx提醒你]`

[service]
REGISTER_EMAIL_CONFIRM = true
ENABLE_NOTIFY_MAIL     = true
DISABLE_REGISTRATION   = false
ENABLE_CAPTCHA         = true
REQUIRE_SIGNIN_VIEW    = true

[picture]
DISABLE_GRAVATAR        = false
ENABLE_FEDERATED_AVATAR = true

[session]
PROVIDER = file

[log]
MODE      = file
LEVEL     = Info
ROOT_PATH = /data/logs

[security]
INSTALL_LOCK = true
SECRET_KEY   = Tgjni2mMDkKqB88

备份容灾

需要定时备份数据库:

# gogs_backup.sh

mysqldump -uroot -pxxx -h192. -P13306 gogs > /backup/sql/mygogs_`date +%Y%m%d_%H%M%S`.sql
  
#删除一周之前的备份文件
find /backup/sql/mygogs* -type f -mtime +7 -exec rm -f {} \;

定时器:

#每天凌晨5点备份
0 5 * * * /bin/bash -x /backup/gogs_backup.sh > /dev/null 2>&1

和同步/storage/app/gogs文件夹:

# gogs_backup2.sh

nohup rsync -e 'ssh -p 22' -avL --delete --exclude "logs" --exclude "ssh" --exclude "gogs/data/sessions" --exclude "gogs/git/.ssh" jinhan@192.168.0.101:/storage/app/gogs /backup/data >> /backup/data/rsync.log 2>&1 &

定时器:

# 每30分一次同步
30 * * * * /bin/bash -x /backup/gogs_backup2.sh > /dev/null 2>&1

需要添加:

vim ~/.ssh/authorized_keys

相关文章

网友评论

      本文标题:内部代码仓库Gogs搭建及备份容灾

      本文链接:https://www.haomeiwen.com/subject/ktqckqtx.html