2010-12-14 73 views

回答

6

簡短回答:否
長答案:您需要了解有關Perforce數據的備份和恢復的詳細信息,請參閱Manual。簡而言之爲不耐煩:

  1. P4驗證// ...
    (驗證服務器的完整性)
  2. P4管理檢查站
    (做一個檢查點,確保這一步是成功的)
  3. 備份檢查點文件和舊的日誌文件
    (如果您運行的Perforce與日誌文件,你應該)
  4. 備份你的版本控制的文件
    (這是實際數據,不要與Perforce服務器目錄中的db。*文件混淆)。

但是請仔細閱讀手冊,特別是關於各種恢復方案。記住: 備份通常工作正常,它的恢復失敗。

+0

第3步是錯誤的,一旦你做出一個新的關卡,你不需要舊的日誌文件。重新閱讀文檔。另外,根據理由,您可以跳過第1步和第2步,如果您不想創建新的檢查點,只需備份當前的日誌文件即可。 – cmcginty 2012-11-15 23:53:02

+0

對於單個用戶在備份運行時不打算提交任何內容的簡單安裝,是否有任何問題停止服務器(例如,p4 admin stop),複製數據庫和軟件倉庫文件以及重新啓動服務器? – Joe 2014-06-21 16:42:03

4

除了jhwist的p4手冊的正確答案(permalink)之外,我還想補充一些我在使用Perforce幾年以來學到的東西。

...

根據存儲庫中進行驗證P4數據庫可能需要幾個小時的大小,這期間它會鎖定沒有人將能夠執行任何查詢。鎖定P4數據庫可能會對用戶產生多種影響,例如:如果有人在此期間正在使用或嘗試使用P4,則P4SCC插件(即用於Visual Studio集成)會旋轉,最終用戶將最終必須強迫戒菸重新獲得控制權。

  1. 菌種P4D的上不同的端口(p4d_2)的第二實例
  2. 掛起/終止主實例(p4d_1)。
  3. 使用p4d_2執行p4 verify //...和檢查點。
  4. 備份存儲陣列上的物理版本文件。
  5. 殺死p4d_2。
  6. 重新啓動p4d_1。

另外:由於這將是更可能是在晚上或週末運行自動過程不能強調不夠,你需要仔細閱讀檢查點的日誌文件,以確保它是成功的否則當您需要執行還原時,您將遇到困難(請閱讀下一個要點)。備份不應該是一套既忘記的程序。

有關Perforce備份的更多信息,請參閱Perforce白皮書:High Availability And Disaster Recovery Solutions For Perforce

HTH,

0

FWIW我在自己的開發工作站上使用了額外的備份策略。我有一個perl腳本,每晚運行一次,並從給定的工作區列表中查找所有已從Perforce中檢出的文件。該文件列表隨後將作爲我的常規工作站備份程序的一部分進行備份。用於查找檢出文件的Perl腳本對我來說看起來相當棘手。我沒有寫它,也不是特別熟悉Perl。

如果有人有興趣,我可以在這裏發表腳本以及我怎麼稱呼它。

請注意,此腳本是在Perforce推出其「擱置」功能之前開發的。現在我可能會更好地擁有一個腳本,每天晚上「擱置」我的工作(除了當前的備份策略或代替它)。

下面是腳本:

# This script copies any files that are opened for any action (other than 
# delete) in the specified client workspace to another specified directory. 
# The directory structure of the workspace is duplicated in the target 
# directory. Furthermore, a file is not copied if it already exists in the 
# target directory unless the file in the workspace is newer than the one 
# in the target directory. 

# Note: This script looks at *all* pending changelists in the specified 
# workspace. 
# Note: This script uses the client specification Root to get the local 
# pathname of the files. So if you are using a substituted drive for the 
# client root, it must be properly substituted before running this script. 

# Argument 1: Client workspace name 
# Argument 2: Target directory (full path) 

use File::Path; 
# use File::Copy; 
use File::Basename; 
use Win32; 

if ($#ARGV != 1) { 
    die("usage: $0 client_name target_directory\n"); 
} 

my $client = shift(@ARGV); 
my $target_dir = shift(@ARGV); 
my @opened_files =(); 
my $client_root = ""; 
my $files_copied = 0; 

# I need to know the root directory of the client, so that I can derive the 
# local pathname of the file. Strange that "p4 -ztag opened" doesn't give 
# me the local pathname; I would have expected it to. 

open(CLIENT_SPEC, "p4 -c $client client -o|") 
     || die("Cannot retrieve client specification: $!"); 
while (<CLIENT_SPEC>) { 
    my ($tag, $value) = split(/\s/, $_, 2); 
    if ($tag eq "Root:") { 
     $value = chop_line($value); 
     $client_root = $value; 
    } 
} 
close(CLIENT_SPEC); 
if ($client_root eq "") { 
    die("Unable to determine root of client $client\n"); 
} elsif (substr($client_root, -1) ne "\\") { 
    $client_root = $client_root . "\\"; 
} 

# Use the -ztag option so that we can get the client file path as well as 
# the depot path. 

open(OPENED_FILES, "p4 -c $client -ztag opened|") 
     || die("Cannot get list of opened files: $!"); 
while (<OPENED_FILES>) { 
    # What we do is to get the client path and append it onto the 
    # @opened_files array. Then when we get the action, if it is a delete, 
    # we pop the last entry back off the array. This assumes that the tags 
    # come out with clientFile before action. 

    $_ = chop_line($_); 
    my ($prefix, $tag, $value) = split(/\s/, $_, 3); 
    if ($tag eq "clientFile") { 
     push(@opened_files, $value); 
    } 
    if (($tag eq "action") && ($value eq "delete")) { 
     pop(@opened_files); 
    } 
} 
close(OPENED_FILES); 

# Okay, now we have the list of opened files. Process each file to 
# copy it to the destination. 

foreach $client_path (@opened_files) { 

    # Trim off the client name and replace it with the client root 
    # directory. Also replace forward slashes with backslashes. 

    $client_path = substr($client_path, length($client) + 3); 
    $client_path =~ s/\//\\/g; 
    my $local_path = $client_root . $client_path; 

    # Okay, now $client_path is the partial pathname starting at the 
    # client's root. That's the path we also want to use starting at the 
    # target path for the destination. 

    my $dest_path = $target_dir . "\\" . $client_path; 
    my $copy_it = 0; 

    if (-e $dest_path) { 
     # Target exists. Is the local path newer? 
     my @target_stat = stat($dest_path); 
     my @local_stat = stat($local_path); 

     if ($local_stat[9] > $target_stat[9]) { 
      $copy_it = 1; 
     } 
    } else { 
     # Target does not exist, definitely copy it. But we may have to 
     # create some directories. Use File::Path to do that. 

     my ($basename, $dest_dir) = fileparse($dest_path); 
     if (! (-e $dest_dir)) { 
      mkpath($dest_dir) || die("Cannot create directory $dest_dir\n"); 
     } 
     $copy_it = 1; 
    } 

    if ($copy_it) { 
     Win32::CopyFile($local_path, $dest_path, 1) 
       || warn("Could not copy file $local_path: $!\n"); 
     $files_copied++; 
    } 
} 
print("$files_copied files copied.\n"); 

exit(0); 

################ Subroutines ######################################### 

# chop_line removes any trailing carriage-returns or newlines from its 
# argument and returns the possibly-modified string. 

sub chop_line { 
    my $string = shift; 

    $string =~ s/[\r\n]*\z//; 
    return $string; 
} 

運行:

REM Make sure that we are pointing to the current Perforce server 
P4 set -s P4PORT=MyPerforceServer:ThePortThatPerforceIsOn 


p4 set p4client=MyPerforceWorkspace 

REM Copy checked out files to a local directory that will be backed up 
.\p4backup.pl MyPerforceWorkspace c:\PerforceBackups\MyPerforceWorkspace_backup