为了安全起见,是否足以备份perforce服务器目录下的所有文件?perforce备份问题
回答
简短回答:否
长答案:您需要了解有关Perforce数据的备份和恢复的详细信息,请参阅Manual。简而言之为不耐烦:
- P4验证// ...
(验证服务器的完整性) - P4管理检查站
(做一个检查点,确保这一步是成功的) - 备份检查点文件和旧的日志文件
(如果您运行的Perforce与日志文件,你应该) - 备份你的版本控制的文件
(这是实际数据,不要与Perforce服务器目录中的db。*文件混淆)。
但是请仔细阅读手册,特别是关于各种恢复方案。记住: 备份通常工作正常,它的恢复失败。
除了jhwist的p4手册的正确答案(permalink)之外,我还想补充一些我在使用Perforce几年以来学到的东西。
...
根据存储库中进行验证P4数据库可能需要几个小时的大小,这期间它会锁定没有人将能够执行任何查询。锁定P4数据库可能会对用户产生多种影响,例如:如果有人在此期间正在使用或尝试使用P4,则P4SCC插件(即用于Visual Studio集成)会旋转,最终用户将最终必须强迫戒烟重新获得控制权。
解
- 菌种P4D的上不同的端口(p4d_2)的第二实例
- 挂起/终止主实例(p4d_1)。
- 使用p4d_2执行
p4 verify //...
和检查点。 - 备份存储阵列上的物理版本文件。
- 杀死p4d_2。
- 重新启动p4d_1。
另外:由于这将是更可能是在晚上或周末运行自动过程不能强调不够,你需要仔细阅读检查点的日志文件,以确保它是成功的否则当您需要执行还原时,您将遇到困难(请阅读下一个要点)。备份不应该是一套既忘记的程序。
有关Perforce备份的更多信息,请参阅Perforce白皮书:High Availability And Disaster Recovery Solutions For Perforce。
HTH,
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
- 1. SQL备份问题
- 2. 使用p4admin GUI创建Perforce备份
- 3. 考虑备份的问题
- 4. SQL Server备份问题
- 5. MySQL备份/恢复问题
- 6. MS SQL SERVER备份问题
- 7. mysql的备份问题
- 8. Hudson-JIRA-Perforce集成问题
- 9. php备份sqlite3数据库问题
- 10. 恢复SQL Server备份的问题
- 11. Android:数据库备份问题
- 12. 恢复数据库备份问题
- 13. 问题在导入MySQL的备份
- 14. 问题涉及到备份按钮
- 15. 备份时间缩短问题
- 16. SQL Server备份排序问题
- 17. 通过PHP问题的SSH备份
- 18. 如何从Bitbucket备份问题列表?
- 19. 备份Oracle 10g时出现问题
- 20. MySQL数据库 - 备份问题
- 21. 如何从github备份问题/门票?
- 22. 备份脚本创建存档问题
- 23. 备份Magento主题
- 24. Perforce:将搁置文件从工作区移动到备份
- 25. 未备份备份
- 26. 詹金斯和Perforce密码问题
- 27. Asp.NET身份问题
- 28. SQL身份问题
- 29. Cassandra备份(快照)块级备份或元数据备份?
- 30. Android的adb备份无法连接问题
第3步是错误的,一旦你做出一个新的关卡,你不需要旧的日志文件。重新阅读文档。另外,根据理由,您可以跳过第1步和第2步,如果您不想创建新的检查点,只需备份当前的日志文件即可。 – cmcginty 2012-11-15 23:53:02
对于单个用户在备份运行时不打算提交任何内容的简单安装,是否有任何问题停止服务器(例如,p4 admin stop),复制数据库和软件仓库文件以及重新启动服务器? – Joe 2014-06-21 16:42:03