当前位置:   article > 正文

gitea的git库备份与恢复_gitea备份

gitea备份

gitea库的备份与恢复

概述

在本地搭建了gitea的git库.
最开始用的gitea 1.16.8。
本人比较手欠,看见新版本就想升级。
换了几个高版本后,渐渐发现,在启动gitea服务时有以前不曾见过的错误提示(e.g. git库的健康检查错误之类的)。
以前一直用旧版的时候,不曾发现报错问题。
就怀疑是升级后,gitea新版对旧版格式不兼容引起的。因为我的git也换了好几次新版本。
想对现有的本地gitea的git库目录进行备份与恢复,看看能不能解决启动gitea新版的报错问题。
主要还是心里有点怕,为以后gitea的git库损坏和迁移做准备。

笔记

实验环境

win10x64
Git-2.45.1-64-bit.exe
TortoiseGit-2.16.0.0-64bit.msi
gitea-1.22.0-gogit-windows-4.0-amd64.exe.7z

更新git for windows

当前的git也不算旧

E:\git_rep_local>git --version
git version 2.44.0.windows.1
  • 1
  • 2

安装 Git-2.45.1-64-bit.exe

更新 TortoiseGit

当前版本
TortoiseGit 2.15.0.0 (C:\Program Files\TortoiseGit\bin)
安装 TortoiseGit-2.16.0.0-64bit.msi
安装完TortoiseGit-2.16.0.0-64bit.msi后,要关闭计算机,再重启计算机。否则计算机桌面反复启动。
重启后,查看git和TortoiseGit版本,都是最新的了。
在这里插入图片描述

备份已经存在的gitea的git库目录

这个得先做,而且还要保留备份一段时间(确认更新了gitea的库运行正常了),免得发生杯具。
在这里插入图片描述

使用gitea本身来备份所有git库目录

我已经做了实验验证过了,现在重新做实验,顺便记录笔记。
停掉了gitea服务,删掉了目录 e:\git_rep_local
将备份中的git_rep_local目录,释放到 e:
在这里插入图片描述
我用的旧版gitea和新版差的不多。
旧版为gitea-1.21.10
在这里插入图片描述
新版为 gitea-1.22.0-gogit-windows-4.0-amd64.exe.7z
必须用当前原版的gitea(升级前,正常能用的旧版gitea)的来做备份, 否则报错后,库备份的不能用于恢复。

在这里插入图片描述

gitea运行时,要依赖git.
我这里,为了避免环境变量污染,将PATH值都清掉了
先写个.bat, 将git环境备齐。
运行 env_git.bat.

E:\git_rep_local>git --version
git version 2.45.1.windows.1
  • 1
  • 2

看到git已经是刚升级过的2.45.1
开始备份(请确认没有正在运行的gitea实例)

gitea-1.21.10-gogit-windows-4.0-amd64.exe dump
  • 1

不是马上能备份完的,等待命令行结束。
在这里插入图片描述
只有用旧版(原版)的gitea备份git库,才能正确完成,不能用新版的gitea.
如果备份时命令行报错,就要从备份的原版gitea的git库中重新备份。

将gitea库恢复到新目录

恢复到新目录的意义(可以在本机的新的目录开始gitea实例,或者在其他计算机上部署本地git库的副本)
建立 E:\git_rep_local_v1,作为空的新目录。
将env_git.bat,gitea-1.22.0-gogit-windows-4.0-amd64.exe,gitea-dump-1716879579.zip拷贝到新目录。
在这里插入图片描述

先将gitea-dump-1716879579.zip中的东西释放到E:\git_rep_local_v1
在这里插入图片描述
E:\git_rep_local_v1\respos 改名为 gitea-repositories
删掉 E:\git_rep_local_v1\custom\conf\app.ini , 原因 : 这个目录中底层只有一个app.ini,和 E:\git_rep_local_v1\app.ini内容一致,经过实验,发现,最终与运行的配置文件是E:\git_rep_local_v1\custom\conf\app.ini 。等一会将E:\git_rep_local_v1\app.ini,再覆盖回来。

修改 E:\git_rep_local_v1\app.ini 中关于E:\git_rep_local的内容到 E:\git_rep_local_v1
我这里改了2处
在这里插入图片描述
将改完的 E:\git_rep_local_v1\app.ini 拷贝为 E:\git_rep_local_v1\custom\conf\app.ini, 否则看不到存在的git库,且库位置也变到了\data下面的gitea-repositories

将原始gitea的git目录 E:\git_rep_local 改名为 E:\git_rep_local_v0, 这样如果在改E:\git_rep_local_v1中有关于原始库路径E:\git_rep_local时,如果没改对(或漏改),容易看出问题。

运行 E:\git_rep_local_v1\env_git.bat
找到自己计算机上sqlite3的官方工具目录 E:\tools\database\sqlite3.44.2\sqlite-tools-win-x64-3440200
在这里插入图片描述
在E:\git_rep_local_v1\env_git.bat命令行中临时添加sqlite3的环境变量

set path=E:\tools\database\sqlite3.44.2\sqlite-tools-win-x64-3440200;%path%
  • 1

现在看一下PATH,git版本,sqlite3版本

E:\git_rep_local_v1>path
PATH=E:\tools\database\sqlite3.44.2\sqlite-tools-win-x64-3440200;C:\Program Files\Git\cmd;C:\Windows\system32;C:\Windows;C:\Windows\system32\wbem;C:\Program Files\dotnet\;C:\Program Files\Git\cmd;C:\Program Files\TortoiseGit\bin

E:\git_rep_local_v1>sqlite3.exe --version
3.44.2 2023-11-24 11:41:44 ebead0e7230cd33bcec9f95d2183069565b9e709bf745c9b5db65cc0cbf92c0f (64-bit)

E:\git_rep_local_v1>git --version
git version 2.45.1.windows.1

  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9

现在环境全了。
修改 gitea-db.sql
因为我采用的是sqlite3数据库,库的位置是在gitea-db.sql描述的。
在gitea-db.sql中查找 E: (我的库在E盘)子字样的字符串,最终可以找到记录.git库的磁盘物理位置
能找到几处,都改成实际的新库位置。有些SQL还记录要使用的gitea版本,也一起改了。

m1

INSERT INTO `app_state` (`id`, `revision`, `content`) VALUES ('runtime-state',6,'{"last_app_path":"E:/git_rep_local/gitea-1.21.10-gogit-windows-4.0-amd64.exe","last_custom_conf":"E:\\git_rep_local\\custom\\conf\\app.ini"}');

  • 1
  • 2

将磁盘位置改为自己的新git目录 E:\git_rep_local_v1

INSERT INTO `app_state` (`id`, `revision`, `content`) VALUES ('runtime-state',6,'{"last_app_path":"E:/git_rep_local_v1/gitea-1.22.0-gogit-windows-4.0-amd64.exe","last_custom_conf":"E:\\git_rep_local_v1\\custom\\conf\\app.ini"}');

  • 1
  • 2

哦, 原来使用哪个app.ini这里也记录了。

m2

INSERT INTO `notice` (`id`, `type`, `description`, `created_unix`) VALUES (872,1,'Repository garbage collection failed for E:\git_rep_local_v0\gitea-repositories\xx\my_local_git_prj.git. Stdout: ' || X'0a' || 'Error: context deadline exceeded',1715561802);

  • 1
  • 2

修改如下

INSERT INTO `notice` (`id`, `type`, `description`, `created_unix`) VALUES (872,1,'Repository garbage collection failed for E:\git_rep_local_v1\gitea-repositories\xx\my_local_git_prj.git. Stdout: ' || X'0a' || 'Error: context deadline exceeded',1715561802);
  • 1

m3

现在将 gitea-db.sql 导入gitea的sqlite3数据库。
这个导入,必须在没有gitea.db的情况下进行。如果存在gitea.db,需要删掉再运行命令行。

sqlite3.exe gitea.db < gitea-db.sql
  • 1

这个导入需要1分钟左右。
在这里插入图片描述

启动gitea - 此时已经恢复完成

为了方便,写个脚本(run_gitea.bat)来运行gitea

set PATH=C:\Program Files\Git\cmd;%PATH%
call gitea-1.22.0-gogit-windows-4.0-amd64.exe
  • 1
  • 2

运行后,发现有lfs报错。且提示从1.19之后,已经去掉了lfs选项。
查看配置文件,
在这里插入图片描述
删除app.ini中的LFS_CONTENT_PATH选项
在这里插入图片描述

再运行 run_gitea.bat
看到警告

2024/05/28 16:16:45 ...dules/setting/log.go:72:prepareLoggerConfig() [E] Deprecation: config option `[log].ROUTER` presents, please use `[log].logger.router.MODE` instead because this fallback will be/has been removed in 1.21
  • 1

查找log选项
在这里插入图片描述
改为提示中的选项试试

[log]
logger.router.MODE = console
  • 1
  • 2

又看到有警告

2024/05/28 16:22:38 ...dules/setting/log.go:72:prepareLoggerConfig() [E] Deprecation: config option `[log].ROUTER` presents, please use `[log].logger.router.MODE` instead because this fallback will be/has been removed in 1.21
  • 1

查找选项log
在这里插入图片描述
改为如下

[log]
logger.router.MODE = console
LEVEL = info
ROOT_PATH = E:/git_rep_local/log
logger.router.MODE = console
  • 1
  • 2
  • 3
  • 4
  • 5

再试试

现在启动后,只有一个警告

2024/05/28 16:26:11 routers/init.go:116:InitWebInstalled() [I] Git version: 2.45.1 (home: E:\git_rep_local_v1\data\home)2024/05/28 16:26:11 routers/init.go:118:InitWebInstalled() [W] sha256 hash support is disabled - requires Git >= 2.42. Gogit is currently unsupported.
  • 1

因为现在git版本已经为2.45.1, 已经>=2.42, sha256被禁用了。这个正常,就不管了。
现在gitea启动的命令行输出如下,只有一个sha256警告



E:\git_rep_local_v1>set PATH=C:\Program Files\Git\cmd;C:\Windows\system32;C:\Windows;C:\Windows\system32\wbem;C:\Program Files\dotnet\;C:\Program Files\Git\cmd;C:\Program Files\TortoiseGit\bin

E:\git_rep_local_v1>call gitea-1.22.0-gogit-windows-4.0-amd64.exe
2024/05/28 16:55:45 cmd/web.go:242:runWeb() [I] Starting Gitea on PID: 141284
2024/05/28 16:55:45 cmd/web.go:111:showWebStartupMessage() [I] Gitea version: 1.22.0 built with GNU Make 4.3, go1.22.3 : bindata, sqlite, sqlite_unlock_notify
2024/05/28 16:55:45 cmd/web.go:112:showWebStartupMessage() [I] * RunMode: prod
2024/05/28 16:55:45 cmd/web.go:113:showWebStartupMessage() [I] * AppPath: E:/git_rep_local_v1/gitea-1.22.0-gogit-windows-4.0-amd64.exe
2024/05/28 16:55:45 cmd/web.go:114:showWebStartupMessage() [I] * WorkPath: E:\git_rep_local_v1
2024/05/28 16:55:45 cmd/web.go:115:showWebStartupMessage() [I] * CustomPath: E:\git_rep_local_v1\custom
2024/05/28 16:55:45 cmd/web.go:116:showWebStartupMessage() [I] * ConfigFile: E:\git_rep_local_v1\custom\conf\app.ini
2024/05/28 16:55:45 cmd/web.go:117:showWebStartupMessage() [I] Prepare to run web server
2024/05/28 16:55:46 routers/init.go:116:InitWebInstalled() [I] Git version: 2.45.1 (home: E:\git_rep_local_v1\data\home)
2024/05/28 16:55:46 routers/init.go:118:InitWebInstalled() [W] sha256 hash support is disabled - requires Git >= 2.42. Gogit is currently unsupported.
2024/05/28 16:55:46 ...s/setting/session.go:77:loadSessionFrom() [I] Session Service Enabled
2024/05/28 16:55:46 ...s/storage/storage.go:176:initAttachments() [I] Initialising Attachment storage with type: local
2024/05/28 16:55:46 ...les/storage/local.go:33:NewLocalStorage() [I] Creating new Local Storage at E:\git_rep_local_v1\data\attachments
2024/05/28 16:55:46 ...s/storage/storage.go:166:initAvatars() [I] Initialising Avatar storage with type: local
2024/05/28 16:55:46 ...les/storage/local.go:33:NewLocalStorage() [I] Creating new Local Storage at E:\git_rep_local_v1\data\avatars
2024/05/28 16:55:46 ...s/storage/storage.go:192:initRepoAvatars() [I] Initialising Repository Avatar storage with type: local
2024/05/28 16:55:46 ...les/storage/local.go:33:NewLocalStorage() [I] Creating new Local Storage at E:\git_rep_local_v1\data\repo-avatars
2024/05/28 16:55:46 ...s/storage/storage.go:186:initLFS() [I] Initialising LFS storage with type: local
2024/05/28 16:55:46 ...les/storage/local.go:33:NewLocalStorage() [I] Creating new Local Storage at E:\git_rep_local_v1\data\lfs
2024/05/28 16:55:46 ...s/storage/storage.go:198:initRepoArchives() [I] Initialising Repository Archive storage with type: local
2024/05/28 16:55:46 ...les/storage/local.go:33:NewLocalStorage() [I] Creating new Local Storage at E:\git_rep_local_v1\data\repo-archive
2024/05/28 16:55:46 ...s/storage/storage.go:208:initPackages() [I] Initialising Packages storage with type: local
2024/05/28 16:55:46 ...les/storage/local.go:33:NewLocalStorage() [I] Creating new Local Storage at E:\git_rep_local_v1\data\packages
2024/05/28 16:55:46 ...s/storage/storage.go:219:initActions() [I] Initialising Actions storage with type: local
2024/05/28 16:55:46 ...les/storage/local.go:33:NewLocalStorage() [I] Creating new Local Storage at E:\git_rep_local_v1\data\actions_log
2024/05/28 16:55:46 ...s/storage/storage.go:223:initActions() [I] Initialising ActionsArtifacts storage with type: local
2024/05/28 16:55:46 ...les/storage/local.go:33:NewLocalStorage() [I] Creating new Local Storage at E:\git_rep_local_v1\data\actions_artifacts
2024/05/28 16:55:46 routers/init.go:138:InitWebInstalled() [I] SQLite3 support is enabled
2024/05/28 16:55:46 routers/common/db.go:23:InitDBEngine() [I] Beginning ORM engine initialization.
2024/05/28 16:55:46 routers/common/db.go:30:InitDBEngine() [I] ORM engine initialization attempt #1/10...
2024/05/28 16:55:46 cmd/web.go:194:serveInstalled() [I] PING DATABASE sqlite3
2024/05/28 16:55:46 cmd/web.go:194:serveInstalled() [W] Table system_setting Column version db default is , struct default is 1
2024/05/28 16:55:46 routers/init.go:144:InitWebInstalled() [I] ORM engine initialization successful!
2024/05/28 16:55:46 ...er/issues/indexer.go:76:func1() [I] PID 141284: Initializing Issue Indexer: bleve
2024/05/28 16:55:46 ...xer/stats/indexer.go:41:populateRepoIndexer() [I] Populating the repo stats indexer with existing repositories
2024/05/28 16:55:46 ...xer/stats/indexer.go:87:populateRepoIndexer() [I] Done (re)populating the repo stats indexer with existing repositories
2024/05/28 16:55:46 ...er/issues/indexer.go:153:func2() [I] Issue Indexer Initialization took 1.9888ms
2024/05/28 16:55:46 ...s/actions/cleanup.go:36:cleanExpiredArtifacts() [I] Found 0 expired artifacts
2024/05/28 16:55:46 ...s/actions/cleanup.go:60:cleanNeedDeleteArtifacts() [I] Found 0 artifacts pending deletion
2024/05/28 16:55:46 cmd/web.go:304:listen() [I] Listen: http://0.0.0.0:3000
2024/05/28 16:55:46 cmd/web.go:308:listen() [I] AppURL(ROOT_URL): http://localhost:3000/
2024/05/28 16:55:46 cmd/web.go:311:listen() [I] LFS server enabled
2024/05/28 16:55:46 ...s/graceful/server.go:50:NewServer() [I] Starting new Web server: tcp:0.0.0.0:3000 on PID: 141284

  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18
  • 19
  • 20
  • 21
  • 22
  • 23
  • 24
  • 25
  • 26
  • 27
  • 28
  • 29
  • 30
  • 31
  • 32
  • 33
  • 34
  • 35
  • 36
  • 37
  • 38
  • 39
  • 40
  • 41
  • 42
  • 43
  • 44
  • 45
  • 46
  • 47
  • 48
  • 49

去网gitea页端看看 http://localhost:3000/
此时,用户名和密码都是以前自己设置好的。
进去之后,看到没有自己的git库。
看日志,发现访问的还是E:\git_rep_local,估计是导出的data目录还是记录的以前的旧位置。
将data目录删除。
在这里插入图片描述
重新运行run_gitea.bat,看看gitea能不能生成自己需要的data目录中的东西。


E:\git_rep_local_v1>set PATH=C:\Program Files\Git\cmd;C:\Windows\system32;C:\Windows;C:\Windows\system32\wbem;C:\Program Files\dotnet\;C:\Program Files\Git\cmd;C:\Program Files\TortoiseGit\bin

E:\git_rep_local_v1>call gitea-1.22.0-gogit-windows-4.0-amd64.exe
2024/05/28 17:04:07 cmd/web.go:242:runWeb() [I] Starting Gitea on PID: 154472
2024/05/28 17:04:07 cmd/web.go:111:showWebStartupMessage() [I] Gitea version: 1.22.0 built with GNU Make 4.3, go1.22.3 : bindata, sqlite, sqlite_unlock_notify
2024/05/28 17:04:07 cmd/web.go:112:showWebStartupMessage() [I] * RunMode: prod
2024/05/28 17:04:07 cmd/web.go:113:showWebStartupMessage() [I] * AppPath: E:/git_rep_local_v1/gitea-1.22.0-gogit-windows-4.0-amd64.exe
2024/05/28 17:04:07 cmd/web.go:114:showWebStartupMessage() [I] * WorkPath: E:\git_rep_local_v1
2024/05/28 17:04:07 cmd/web.go:115:showWebStartupMessage() [I] * CustomPath: E:\git_rep_local_v1\custom
2024/05/28 17:04:07 cmd/web.go:116:showWebStartupMessage() [I] * ConfigFile: E:\git_rep_local_v1\custom\conf\app.ini
2024/05/28 17:04:07 cmd/web.go:117:showWebStartupMessage() [I] Prepare to run web server
2024/05/28 17:04:08 routers/init.go:116:InitWebInstalled() [I] Git version: 2.45.1 (home: E:\git_rep_local_v1\data\home)2024/05/28 17:04:08 routers/init.go:118:InitWebInstalled() [W] sha256 hash support is disabled - requires Git >= 2.42. Gogit is currently unsupported.
2024/05/28 17:04:08 ...s/setting/session.go:77:loadSessionFrom() [I] Session Service Enabled
2024/05/28 17:04:08 ...s/storage/storage.go:176:initAttachments() [I] Initialising Attachment storage with type: local
2024/05/28 17:04:08 ...les/storage/local.go:33:NewLocalStorage() [I] Creating new Local Storage at E:\git_rep_local_v1\data\attachments
2024/05/28 17:04:08 ...s/storage/storage.go:166:initAvatars() [I] Initialising Avatar storage with type: local
2024/05/28 17:04:08 ...les/storage/local.go:33:NewLocalStorage() [I] Creating new Local Storage at E:\git_rep_local_v1\data\avatars
2024/05/28 17:04:08 ...s/storage/storage.go:192:initRepoAvatars() [I] Initialising Repository Avatar storage with type: local
2024/05/28 17:04:08 ...les/storage/local.go:33:NewLocalStorage() [I] Creating new Local Storage at E:\git_rep_local_v1\data\repo-avatars
2024/05/28 17:04:08 ...s/storage/storage.go:186:initLFS() [I] Initialising LFS storage with type: local
2024/05/28 17:04:08 ...les/storage/local.go:33:NewLocalStorage() [I] Creating new Local Storage at E:\git_rep_local_v1\data\lfs
2024/05/28 17:04:08 ...s/storage/storage.go:198:initRepoArchives() [I] Initialising Repository Archive storage with type: local
2024/05/28 17:04:08 ...les/storage/local.go:33:NewLocalStorage() [I] Creating new Local Storage at E:\git_rep_local_v1\data\repo-archive
2024/05/28 17:04:08 ...s/storage/storage.go:208:initPackages() [I] Initialising Packages storage with type: local
2024/05/28 17:04:08 ...les/storage/local.go:33:NewLocalStorage() [I] Creating new Local Storage at E:\git_rep_local_v1\data\packages
2024/05/28 17:04:08 ...s/storage/storage.go:219:initActions() [I] Initialising Actions storage with type: local
2024/05/28 17:04:08 ...les/storage/local.go:33:NewLocalStorage() [I] Creating new Local Storage at E:\git_rep_local_v1\data\actions_log
2024/05/28 17:04:08 ...s/storage/storage.go:223:initActions() [I] Initialising ActionsArtifacts storage with type: local2024/05/28 17:04:08 ...les/storage/local.go:33:NewLocalStorage() [I] Creating new Local Storage at E:\git_rep_local_v1\data\actions_artifacts
2024/05/28 17:04:08 routers/init.go:138:InitWebInstalled() [I] SQLite3 support is enabled
2024/05/28 17:04:08 routers/common/db.go:23:InitDBEngine() [I] Beginning ORM engine initialization.
2024/05/28 17:04:08 routers/common/db.go:30:InitDBEngine() [I] ORM engine initialization attempt #1/10...
2024/05/28 17:04:08 cmd/web.go:194:serveInstalled() [I] PING DATABASE sqlite3
2024/05/28 17:04:08 cmd/web.go:194:serveInstalled() [W] Table system_setting Column version db default is , struct default is 1
2024/05/28 17:04:08 routers/init.go:144:InitWebInstalled() [I] ORM engine initialization successful!
2024/05/28 17:04:10 ...er/issues/indexer.go:76:func1() [I] PID 154472: Initializing Issue Indexer: bleve
2024/05/28 17:04:10 ...xer/stats/indexer.go:41:populateRepoIndexer() [I] Populating the repo stats indexer with existing repositories
2024/05/28 17:04:10 ...xer/stats/indexer.go:87:populateRepoIndexer() [I] Done (re)populating the repo stats indexer with existing repositories
2024/05/28 17:04:10 ...s/actions/cleanup.go:36:cleanExpiredArtifacts() [I] Found 0 expired artifacts
2024/05/28 17:04:10 ...s/actions/cleanup.go:60:cleanNeedDeleteArtifacts() [I] Found 0 artifacts pending deletion
2024/05/28 17:04:10 cmd/web.go:304:listen() [I] Listen: http://0.0.0.0:3000
2024/05/28 17:04:10 cmd/web.go:308:listen() [I] AppURL(ROOT_URL): http://localhost:3000/
2024/05/28 17:04:10 cmd/web.go:311:listen() [I] LFS server enabled
2024/05/28 17:04:10 ...s/graceful/server.go:50:NewServer() [I] Starting new Web server: tcp:0.0.0.0:3000 on PID: 154472
2024/05/28 17:04:10 ...er/issues/indexer.go:153:func2() [I] Issue Indexer Initialization took 103.8375ms

  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18
  • 19
  • 20
  • 21
  • 22
  • 23
  • 24
  • 25
  • 26
  • 27
  • 28
  • 29
  • 30
  • 31
  • 32
  • 33
  • 34
  • 35
  • 36
  • 37
  • 38
  • 39
  • 40
  • 41
  • 42
  • 43
  • 44
  • 45
  • 46

可以啊,gitea已经按照生成了新的data目录,且启动时需要的目录都指向了新目录 E:\git_rep_local_v1
去网页端看看 http://localhost:3000/
还是没看到自己在新目录的git库
用 sqlitestudio-3.3.3.zip 看看 gitea.db 哪里写了旧库的位置?
看了一圈,没找到,应该不在gitea.db中。如果在的话,那么在导入sql前的替换中,就能看到。
看了一圈,是不是硬写在E:\git_rep_local_v1\gitea-repositories\me\my_local_git_prj.git的文件中了。 这种可能性比较大。找一下。

FETCH_HEAD 中有硬写位置

在这里插入图片描述

073013986e5b302c20976d5978aae4e983ceeac5		branch 'master' of E:\git_rep_local\gitea-repositories\me\my_local_git_prj

  • 1
  • 2

改为

073013986e5b302c20976d5978aae4e983ceeac5		branch 'master' of E:\git_rep_local_v1\gitea-repositories\me\my_local_git_prj

  • 1
  • 2

又翻了翻,好像就这一处。

再运行 run_gitea.bat试试,启动正常。
去网页端看看 http://localhost:3000/, 还不行。
将data目录删掉,重新运行run_gitea.bat试试. 不行。
现在不知道gitea将旧仓库位置写在哪里了。

再查一下app.ini, 是否改漏了。

招了一下,还真改漏了。
这次搜索 E: 这2个字符

m1

[repository]
ROOT = E:/git_rep_local/gitea-repositories
  • 1
  • 2

改为

[repository]
ROOT = E:/git_rep_local_v1/gitea-repositories
  • 1
  • 2

m2

[log]
logger.router.MODE = console
LEVEL = info
ROOT_PATH = E:/git_rep_local/log
  • 1
  • 2
  • 3
  • 4

改为

[log]
logger.router.MODE = console
LEVEL = info
ROOT_PATH = E:/git_rep_local_v1/log
  • 1
  • 2
  • 3
  • 4

将 E:\git_rep_local_v1\app.ini 更新到 E:\git_rep_local_v1\custom\conf\app.ini
将 E:\git_rep_local_v1\data目录删了, 让gitea自动生成。
运行 run_gitea.bat, 启动信息正常。
访问网页 http://localhost:3000/, 不行,git库还是没有。

将 E:\git_rep_local_v1\data目录删了, 从备份gitea-dump-1716879579.zip中释放。
运行 run_gitea.bat, 启动信息正常。
访问网页 http://localhost:3000/, 不行,git库还是没有。
不过已经没有路径找不到的错误信息了。

总结

当前的gitea版本(gitea-1.22.0-gogit-windows-4.0-amd64.exe),只能将仓库恢复到另外一台计算机上的相同位置(包括本机的相同位置)。
那如果是windows的gitea库迁移到linux,那该着办呢?

看到gitea命令行还有针对单个库的备份和恢复,但是命令行不知道怎么用(总是报错)。

现在对gitea有点不放心了。改天再找找,需要将库备份和恢复的目录位置问题搞定才行。
这种git库的备份和恢复,怎么可以和具体的磁盘位置关联起来呢?这不科学啊。

用gitea备份/恢复库无解

官方资料说的和软件实际运行情况不一样,算了。
第三方的资料就更没说我遇到的这种细节。
gitea的这功能(备份/恢复)做的真磕碜。

折中的方法

先从已有gitea库克隆一个完整版本下来到目录dir_a。
在gitea服务端建立一个空库(库名和已经克隆下来的库名相同),这时可以得到库的克隆url_b.
在dir_a中右击,清空save的所有数据。将提交地址改成url_b.
然后在dir_a中,用TortoiseGit push到服务端的空库,等待完成。
此时,在随便一个本地空目录dir_c,克隆url_b, 等待完成。
此时,在dir_c中,右击,用TortoiseGit查看历史,可以看到该库的所有历史记录都有。说明克隆成功。
这种方法,折中的解决了gitea库的备份问题,且和gitea库的物理位置无关。

END

声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/一键难忘520/article/detail/856858
推荐阅读
  

闽ICP备14008679号