文章目錄
- gitea庫的備份與恢復
- 概述
- 筆記
- 實驗環境
- 更新git for windows
- 更新 TortoiseGit
- 備份已經存在的gitea的git庫目錄
- 使用gitea本身來備份所有git庫目錄
- 將gitea庫恢復到新目錄
- m1
- m2
- m3
- 啟動gitea - 此時已經恢復完成
- FETCH_HEAD 中有硬寫位置
- 再查一下app.ini, 是否改漏了。
- m1
- m2
- 總結
- 用gitea備份/恢復庫無解
- 折中的方法
- END
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
安裝 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
看到git已經是剛升級過的2.45.1
開始備份(請確認沒有正在運行的gitea實例)
gitea-1.21.10-gogit-windows-4.0-amd64.exe dump
不是馬上能備份完的,等待命令行結束。
只有用舊版(原版)的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%
現在看一下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\binE:\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
現在環境全了。
修改 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"}');
將磁盤位置改為自己的新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"}');
哦, 原來使用哪個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);
修改如下
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);
m3
現在將 gitea-db.sql 導入gitea的sqlite3數據庫。
這個導入,必須在沒有gitea.db的情況下進行。如果存在gitea.db,需要刪掉再運行命令行。
sqlite3.exe gitea.db < gitea-db.sql
這個導入需要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
運行后,發現有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
查找log選項
改為提示中的選項試試
[log]
logger.router.MODE = console
又看到有警告
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
查找選項log
改為如下
[log]
logger.router.MODE = console
LEVEL = info
ROOT_PATH = E:/git_rep_local/log
logger.router.MODE = console
再試試
現在啟動后,只有一個警告
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.
因為現在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\binE:\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
去網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\binE:\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
可以啊,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
改為
073013986e5b302c20976d5978aae4e983ceeac5 branch 'master' of E:\git_rep_local_v1\gitea-repositories\me\my_local_git_prj
又翻了翻,好像就這一處。
再運行 run_gitea.bat試試,啟動正常。
去網頁端看看 http://localhost:3000/, 還不行。
將data目錄刪掉,重新運行run_gitea.bat試試. 不行。
現在不知道gitea將舊倉庫位置寫在哪里了。
再查一下app.ini, 是否改漏了。
招了一下,還真改漏了。
這次搜索 E: 這2個字符
m1
[repository]
ROOT = E:/git_rep_local/gitea-repositories
改為
[repository]
ROOT = E:/git_rep_local_v1/gitea-repositories
m2
[log]
logger.router.MODE = console
LEVEL = info
ROOT_PATH = E:/git_rep_local/log
改為
[log]
logger.router.MODE = console
LEVEL = info
ROOT_PATH = E:/git_rep_local_v1/log
將 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庫的物理位置無關。