我在Windows VM框上運行VisualSVN。虛擬機崩潰並損壞了映像。恢復較舊的映像(2007年)後,我們發現我們的數據備份無法正常運行。因此,我在我的筆記本電腦(客戶端)上安裝了一堆項目(〜20),我想將它們推回VisualSVN服務器,該服務器現在是空的。從客戶端副本恢復VisualSVN服務器
我知道這可以通過手動添加項目文件來完成,但由於我不想包含每個文件(即編譯的文件),所以這會花費時間。任何建議將不勝感激。
我在Windows VM框上運行VisualSVN。虛擬機崩潰並損壞了映像。恢復較舊的映像(2007年)後,我們發現我們的數據備份無法正常運行。因此,我在我的筆記本電腦(客戶端)上安裝了一堆項目(〜20),我想將它們推回VisualSVN服務器,該服務器現在是空的。從客戶端副本恢復VisualSVN服務器
我知道這可以通過手動添加項目文件來完成,但由於我不想包含每個文件(即編譯的文件),所以這會花費時間。任何建議將不勝感激。
不幸的是,我沒有你,但一個方式完全自動化的解決方案,以找出它使用與命令行工具的列表命令哪些文件在存儲庫的版本:
svn.exe list -R
該命令將遞歸列出當前目錄中SVN版本化的所有文件。一旦你有了這個列表,你可以將它們複製到另一個目錄並批量提交到一個新的存儲庫。
將該命令與一些Powershell魔法相結合可能會使得重建庫的任務變得儘可能無痛。
更新:
我花了一些時間使用PowerShell玩,想通了,你怎麼能做到這一點。例如,我將解釋原始存儲庫目錄爲C:\ source_repos \,新存儲庫目錄爲C:\ dest_repos \。
cd C:\source_repos\
echo File > filelist.csv
svn.exe list -R >> filelist.csv
第二個命令與含有字「文件」的第一行創建filelist.csv。第三個命令運行svn list命令並重定向輸出以附加到filelist.csv。此時filelist.csv在第一行應該有「File」,後面跟着在你的svn目錄中版本化的每個文件。
# Assumptions/Notes:
# - No crazy file names with "\" in them!
# - A file named filelist.csv was created by running:
# svn.exe list -R >> filelist.csv
# and is in the base directory of the source repository.
# - The first line of filelist.csv is "File" without quotes, this is
# important for the Import-Csv command
# - If you get an error about permissions when you try to run the script,
# use the command "Set-ExecutionPolicy RemoteSigned" in the powershell
# Source & destination repository directories
$src = "C:\source_repos\"
$dest = "C:\dest_repos\"
# Get current directory
$origdir = Get-Location
# Goto source repository directory
Set-Location $src
# Check if destination repository directory exists, if not create it
if (![IO.Directory]::Exists($dest)) {
[IO.Directory]::CreateDirectory($dest)
}
# Import filelist.csv created with these commands at a command prompt:
# cd C:\source_repos
# echo File > filelist.csv
# svn.exe list -R >> filelist.csv
$filelist = Import-Csv filelist.csv
# Go through each line in the filelist
foreach ($line in $filelist) {
# Concatenate the filename with the source and destination directories
$srcfile = [String]::Concat($src, $line.File)
$destfile = [String]::Concat($dest, $line.File)
# If the destination file is a directory and it doesn't exist create it
# Otherwise copy the source file to the destination.
if ($destfile.EndsWith("\")) {
if (![IO.Directory]::Exists($destfile)) {
[IO.Directory]::CreateDirectory($destfile)
}
} else {
Copy-Item $srcfile $destfile
}
}
# Go back to the original directory
Set-Location $origdir
您將需要修改$src
和$dest
變量每次運行。
Set-ExecutionPolicy RemoteSigned
讓本地腳本沒有簽名即可運行。
C:\dest_repos\
和
svn add
的所有文件轉移到新的存儲庫,並將它們轉換爲
svn commit
。
如果遇到什麼,我試圖解釋,或者遇到任何奇怪的錯誤,有任何問題,讓我知道。我對劇本進行了膚淺的測試,但很可能我忘記了一些邊緣案例。
好運讓您的存儲庫恢復!
@Kevin,你是否曾經能夠在不手動提交特定文件的情況下恢復svn服務器? – lostriebo 2010-03-26 02:10:17