Backup job

for security, is it enough to back up all the files in the perforce server directory?

+4
source share
3 answers

Short answer: No
The long answer: Everything you need to know about backing up and restoring Perforce data is described in Manual . In a nutshell for the impatient:

  • p4 check // ...
    (Check the integrity of your server)
  • p4 admin checkpoint
    (Make a breakpoint, make sure this step is successful)
  • backup checkpoint file and old log file
    (if you run Perforce with the log files you need)
  • backup files with versions
    (that the actual data should not be confused with the db. * files in the Perforce server directory.)

But please read the manual, especially about the various recovery scenarios. Remember: Backups usually work fine, this restore fails.

+6
source

In addition to jhwist correctly from the p4 ( permalink ) manual, I would like to add a few things that I learned while using Perforce for several years.

...

Depending on the size of your repository performing a check in the p4 database, it may take several hours, during which it will be blocked , and no one will be able to fulfill any requests. Blocking a P4 database can have several flow effects for your users, for example: if someone uses or tries to use P4 during this time, the P4SCC plug-in (i.e., for integration with visual studio) will rotate and the user ultimately must be forced to quit smoking in order to regain control.

Decision

  • Create a second P4D instance on another port (p4d_2)
  • Suspend / terminate the main instance (p4d_1).
  • Run p4 verify //... and the checkpoint with p4d_2.
  • Backing up physical version files in a storage array.
  • Kill p4d_2.
  • Reboot p4d_1.

Also:. Since this will be more than likely, an automated process that runs at night or on weekends may not emphasize that you need to read the checkpoint log file carefully to make sure it was successful , otherwise you will be in a difficult place when you need to complete recovery (read the next paragraph). Backup should not be a given and forgotten procedure.

For more information about Perforce backups, see the Perforce document: High Availability and Disaster Recovery Solutions for Perforce .

Hth,

+4
source

FWIW I used an additional backup strategy on my own development workstation. I have a perl script that runs every night and finds all the files that I checked from Perforce from a specific list of workspaces. This file list is then backed up as part of my usual workstation backup procedure. The perl script to find the files that have been extracted seems rather complicated to me. I did not write it and am not very familiar with Perl.

If anyone is interested, I can post the script here, as I call it.

Please note that this script was developed before Perforce came out with a “shelving” capability. It might be better for me now to have a script that “replenishes” my work every night (either in addition to my current backup strategy, or instead of it).

Here is the script:

 # 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 root. That 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; } 

For start:

 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 
0
source

Source: https://habr.com/ru/post/1332111/


All Articles