USAGE for sdp_sync.sh v2.1.8:
sdp_sync.sh [-H <host1>[,<host2>,...]] [-i <instance>] [-s] [-m] [-c] [-r] [-e|-E] [-L <log>] [-si] [-v<n>] [-n|-N] [-D]
or
sdp_sync.sh [-h|-man|-V]
DESCRIPTION:
This script keeps Perforce Server Deployment Package (SDP) scripts in
sync on all SDP hosts, as defined by the SDP_SYNC_HOSTS setting in the
file.
Also, if used with the '-c' flag, verifies that versioned cron files
match those on each system.
This script is intended to be called by a cron job the master server.
It then does ssh calls to the remaining SDP hosts.
Each target host is expect to have a P4CONFIG file named
/p4/.p4config.SDP that defines Perforce environment settings that
point to Perforce workspaces that enable versioning of the SDP on that
host. For pure read-only replicas, the P4PORT value in that P4CONFIG
file must point to the master server. Forwarding replicas and Edge
Servers can point P4PORT to the master server or locally.
The worskpaces must be configured for each host. Typically they
reference paths in the Perforce server that are common across
all SDP servers, e.g. to populate the /p4/common/bin folder.
Other paths are host-specific, like the /p4/<n>/bin folders
that indicate which instances are active on the machine as well
as which type of servers are active for each instance (p4d,
p4p, p4broker, etc.).
This depends on ssh keys being setup such that the Perforce login
(as defined by OSUSER in /p4/common/bin/p4_vars) can ssh without a password
to all SDP hosts. (To simplify failover, the backup servers should
also be able to ssh to each other without a password; security
implications should be considered here.)
OPTIONS:
-H <host1>[,<host2>,...]
Specify a comma-delimited list of hosts to push to. By default,
the SDP_SYNC_HOSTS value defined in the config file
determines the list of hosts to push to.
-i <n>
Specify the SDP instance tag (e.g 1 for /p4/1, abc for /p4/abc) for
the SDP instance that contains the SDP. The default is to use
the $SDP_INSTANCE variable if defined, or else '1'.
-s Specify that a 'p4 status' check should be done in directories
specified by the SDP_STATUS_DIRS variable defined in .
-m Use with '-s' to specify that the '-m' flag to 'p4 status' should
be used for a faster check (without MD5 digest comparison). If
'-m' is specified without '-s', the '-s' is implied.
-c Specifies that the crontab for the OSUSER (perforce) on each machine
should be compared against the the versioned cron file in:
/p4/common/etc/cron.d
In that directory, the cron files are named crontab.<user>.<hostname>
The cron check is done for all hosts defined in the ALL_SDP_HOSTS
setting in .
-r
Specify this option to remove old sdp_sync.*.log files. If this option
is specified, log files named /p4/<n>/logs/sdp_sync.*.log (where '<n>'
is the SDP instance name) that are older than the number of journal
rotations indicated by the KEEPLOGS setting in /p4/common/bin/p4_vars are removed.
The old log removal occurs only upon successful completion.
-e Send email to MAILTO value defined in /p4/common/bin/p4_vars in event
of failure only.
-E Send email to MAILTO value defined in /p4/common/bin/p4_vars.
-v<n> Set verbosity 1-5 (-v1 = quiet, -v5 = highest).
-L <log>
Specify the path to a log file, or the special value 'off' to disable
logging. By default, all output (stdout and stderr) goes to a log
file named sdp_sync.<datestame>.log in /p4/hms/logs.
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'.
-n No-Op. Prints commands instead of running them.
-N No-Op. Similar to '-n', but this command does execute the 'ssh' calls to
get to the remote host, but then does 'p4 sync -n' rather than' 'p4 sync'
on the remote host.
-D Set extreme debugging verbosity.
HELP OPTIONS:
-h Display short help message
-man Display man-style help message
-V Dispay version info for this script and its libraries.
FILES:
The SDP environment file /p4/common/bin/p4_vars defines various
SDP settings, and is used by several SDP scripts.
The host config file defines the SDP_SYNC_HOSTS and
other values.
EXAMPLES:
Recommended crontab usage for SDP Instance 1:
/p4/common/bin/sdp_sync.sh -i 1 -si -s -c -r -e < /dev/null > /dev/null 2>&1
The redirect to /dev/null is to avoid any output that
would generate a duplicate email from cron. Output is not lost;
it is written to a timestampped log file:
/p4/hms/logs/sdp_sync.<timestamp>.log
SEE ALSO:
See this related script:
/p4/common/bin/global_replica_status.sh
| # | Change | User | Description | Committed | |
|---|---|---|---|---|---|
| #4 | 26649 | Robert Cowham |
More SDP Doc tidy up. Removed some command summary files. |
||
| #3 | 23404 | C. Thomas Tyler |
Added command summary file for global_replica_status.sh script. Updated command summary file for sdp_sync.sh script. Doc only, no functional changes. |
||
| #2 | 22626 | C. Thomas Tyler | Updated doc to match latest script for sdp_sync.sh. | ||
| #1 | 22622 | C. Thomas Tyler |
Renamed crontab templates files to be template.* rather than *.template. This is an 'optimize for lazy' tweak, since if we use a prefix, then the actual crontab files named of the form crontab.$USER.${HOSTNAME%%.*} won't have command line completion conficts with the templates. Added a ReadMe.md file describing the suggested (and with HMS required) naming convention for crontab files. Added a command summary doc for the sdp_sync.sh script that manages crontab files in a tight ship deployment. The reference to this file from the ReadMe.md file won't work now with this change in the dev branch, but will work once promoted to main. |