On Tue, Aug 22, 2023 at 12:59:18AM -0400, Karl Vogel wrote:
   me% cat try
   #!/bin/sh
   export PATH=/usr/local/bin:/bin:/usr/bin
   ssh -q -c aes128-...@openssh.com -i $HOME/.ssh/bkup_ed25519 \
       bkup "logger -t autopull git pull whatever"
   exit 0

I am grateful for the recommendations.  The backup works as expected
if I keep a terminal window open and logged via SSH into the remote
host, and execute ``git pull''.  But I still have not managed to get
the git hook script running.

I decided to document the system and to give the document a title so
that it can be found by others trying to put together a similar
system.  Kindly suggest improvements in the title or the content.

-------

USE OF GIT POST-COMMIT HOOK TO AUTOMATE SSH PULL OF A GIT REPOSITORY
FOR DOCUMENT BACKUP

(1) This is a git system running on a pair of Debian computers (LOCAL
and REMOTE) and serving a single user.  All git activity involves only
the MASTER branch; there is no branching or merging.  Routine
operations consist of COMMITS to the production repository on the
local host and PULLS into the backup repository on the remote host.
Passwordless SSH is used for data transfer.

(2) The primary purpose of the git system is archival and backup of
text documents, which are composed in LaTeX markup.  As a document
takes shape during composition, from time to time it is committed.  A
secondary purpose of the git system is to allow reference or
regression to an earlier stage in the development of a particular
document.

(3) SSH is configured for passwordless login to the remote host by the
local host.

(4) The PRODUCTION repository is
``192.168.1.85:/home/rlh/git.production''.

(5) The BACKUP repository is ``192.168.1.35:/home/rlh/git.backup''.

(6) The backup repository was cloned (non-bare) from the production
repository.  The git remote was assigned the alias ``backup''.

(7) A git hook script on the local host named ``post-commit'' calls
SSH on the backup host to pull the latest document version from the
production repository.  The script, the path of which is,
``.git/hooks/post-commit'', follows.  Note that the shebang line
specifies ``bash'', which is appropriate for a Debian/GNU Linux
system:

#!/bin/bash
# post-commit
# 2023.08.24 2200gmt

ssh backup "git pull"
exit 0

Reply via email to