簡體   English   中英

從客戶端副本還原VisualSVN服務器

[英]Restore VisualSVN server from client copy

我在Windows VM框中運行VisualSVN。 VM崩潰並損壞了映像。 還原較舊的映像(2007年)后,我們發現數據備份無法正常運行。 因此,我在筆記本電腦(客戶端)上有一堆項目(約20個),我想將它們推回VisualSVN服務器中,該服務器現在是空的。

我知道這可以通過簡單地手動添加項目文件來完成,但這會花費一些時間,因為我不想包含每個文件(即已編譯的文件)。 任何建議將不勝感激。

不幸的是,我沒有適合您的全自動解決方案,但是一種確定版本庫中文件版本的方法是使用帶有命令行工具的list命令:

svn.exe list -R

該命令將遞歸列出當前目錄中所有由SVN版本控制的文件。 獲得該列表后,您可以將它們復制到另一個目錄,然后將它們批量提交到新的存儲庫中。

將該命令與一些Powershell魔術結合起來,可能會使重新創建存儲庫的任務變得盡可能輕松。

更新:

我花了一些時間與Powershell一起玩,並弄清楚了如何做到這一點。 對於該示例,我將解釋原始存儲庫目錄為C:\\ source_repos \\,而新存儲庫目錄為C:\\ dest_repos \\。

  1. 打開命令提示符。 這可以通過附件開始菜單文件夾來完成,也可以通過在Vista / Win7中的搜索框中運行“ cmd”或在WinXP中運行“ ...”來完成。
  2. 在命令提示符下,運行以下命令:

     cd C:\\source_repos\\ echo File > filelist.csv svn.exe list -R >> filelist.csv 

    第二條命令創建filelist.csv,第一行包含單詞“ File”。 第三個命令運行svn list命令,並將輸出重定向到追加到filelist.csv。 此時,filelist.csv應該在第一行中帶有“文件”,然后是在svn目錄中版本化的每個文件,並逐行列出。

  3. 使用下面的代碼並將其粘貼到名為reposcopy.ps1的文件中:

     # 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變量。

  4. 打開Powershell(可以在Vista / Win7的附件或WinXP的Powershell中找到)。 轉到保存上述腳本的目錄並運行它。 如果收到錯誤消息“在此系統上禁用了腳本執行”,請運行

     Set-ExecutionPolicy RemoteSigned 

    在Powershell中,以使本地腳本無需簽名即可運行。

那應該做。 如果一切順利,您應該可以轉到C:\\dest_repos\\svn add所有文件svn add到新存儲庫中,然后svn commit它們。

如果您對我試圖解釋的內容有任何疑問或遇到任何奇怪的錯誤,請告訴我。 我對腳本進行了表面測試,但是很可能我忘記了一些極端情況。

祝您恢復存儲庫好運!

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM