USAGE for prsync_depots.sh v5.0.0: prsync_depots.sh [-c ] [-si] [-n] [-d|-D] or prsync_depots.sh [-h|-man] DESCRIPTION: This script is useful for copying depot directories across two p4d servers, e.g. to aid it backing up or migrating data. It is intended to be executed on the target server, and it uses a series of parallel rsync commands to pull from the source server. It requires that SSH keys be setup such that passwordless ssh is enabled from the target server into the source server, so that 'ssh' and 'rsync' commands are not prompted for a password. This script uses 2 configuration files, a static configuration file and a 'max procs' configuration file. STATIC CONFIG FILE: The static configuration file defines settings that are loaded at startup, and cannot change once the process starts. The following sample file illustrates settings: === BEGIN Sample Static Config File # This is a config file for prsync_depots.sh # # Set SourceHost to the source server name. SSH keys must enable passwordless # ssh and rsync commands to the specified machine from the machine where # prsync_depots.sh is executed. SourceHost=syd-helix-04 # Set SourceBasePath to the directory containing depot directories exist on # the source server. This is typically the same folder returned by the # command: p4 configure show server.depot.root SourceBasePath=/p4/1/depots # Set TargetBasePath to the directory depot directories are to be copied to # on the target server. This often has the same value as the SourceBasePath. TargetBasePath=/p4/1/depots # Set a working directory. The directory that contains the working directory # must exist or be able to be created with 'mkdir -p'. This directory is # removed at the end of successful processing, and so typically has a tempoary # name ending something like: $$.$RANDOM WorkingDir=/p4/1/tmp/rsync.$$.$RANDOM # Set DepotListFile to a file containing a list of named directories to copy # in order. If this is not set (i.e. if the value to the right of the equal # sign is empty), then all directories reported by 'ls -A' in the # SourceBasePath on the SourceHost machine will be copied and processed in # the order returned by 'ls -A'. DepotListFile= === END Sample Static Config File MAX PROCS CONFIG FILE: The 'max procs' config file is created when this script starts. The file is: It is a one-line, file, and looks something like this: MAX_RSYNC_PROCS=8 This defines the max rsync processes that can be running, and is a form of throttle control. It can be adjusted up or down by carefully editing the file even while the script is running. Simply change the number on the right side of the '=' in the line to change the value of MAX_RSYNC_PROCS. If increased during processing, more threads will be added quickly (after about 10 seconds). If decreased during processing, it may take a while for in-flight rsyncs to finish before the process count gets down to the desired level. This script will (by design) not distinguish 'rsync' commands launched from this script with any other rsync processing that may be occuring, so other (perhaps manual) rsyncs can keep this script from launching rsync threads, delaying its progress, but also avoiding overloading the machine. In any case, that absolute max processes that can be launched is 2 less than the number of processors (but never less than a max of 4). The number of processors is determined with: grep -c processor /proc/cpuinfo OPTIONS: -c Specify the path to the config file. The default config file -L Specify the path to a log file, or the special value 'off' to disable logging. By default, all output (stdout and stderr) goes to NOTE: This script is self-logging. That is, output displayed on the screen is simultaneously captured in the log file. Do not run this script with redirection operators like '> log' or '2>&1', and do not use 'tee.' -si Operate silently. All output (stdout and stderr) is redirected to the log only; no output appears on the terminal. This cannot be used with '-L off'. This is useful when running from cron, as it prevents automatic email from being sent by cron directly, as cron does when a script called from cron generates output. Some preflight checks that occur early in processing, before logging is initiated, may be displayed to the output even if '-si' -is used. -n No-Op. Prints data-affecting commands instead of running them. This is effectively a dry-run. This will verify SSH access to the remote server. -d Set debugging verbosity; enable debug messages. -D Set extreme bash 'set -x' debugging verbosity. -D also implies -d. CONFIG FILE: A config file is required. It must define the following settings: HELP OPTIONS: -h Display short help message -man Display man-style help message EXAMPLES: Typical usage specifying a config file: prsync_depots.sh -c /path/to/prsync_depots.cfg