Difference between revisions of "Linux3"

From SourceWiki
Jump to navigation Jump to search
 
Line 7: Line 7:
 
<pre>
 
<pre>
 
#!/bin/bash
 
#!/bin/bash
 +
 +
# An rsync script to, for example, synchronise an SVN checkout on your local machine
 +
# with a copy of your checkout, kept on a remote machine.  The files are transported
 +
# via SSH, so all the usual comments about using SSH keys etc. apply
  
 
# set up some env vars
 
# set up some env vars
 
RSYNC=/usr/bin/rsync
 
RSYNC=/usr/bin/rsync
 
REMOTE_HOST="full.domain.name.here"
 
REMOTE_HOST="full.domain.name.here"
 +
REMOTE_USER_NAME="known-as"
  
 
# see the rsync man page for an explanation of these
 
# see the rsync man page for an explanation of these
Line 18: Line 23:
 
REMOTE_SRC_DIR=/path/to/my/src/on/remote/machine
 
REMOTE_SRC_DIR=/path/to/my/src/on/remote/machine
  
# call rsync to _push_ you files to the remote host
+
# call rsync to PUSH your files to the remote host
$RSYNC $OPTS $LOCAL_SVN_CHECKOUT $REMOTE_HOST:$REMOTE_SRC_DIR
+
$RSYNC $OPTS $LOCAL_SVN_CHECKOUT $REMOTE_USER_NAME@$REMOTE_HOST:$REMOTE_SRC_DIR
  
 
exit 0
 
exit 0
 
</pre>
 
</pre>

Revision as of 12:32, 1 March 2010

More Advanced Examples

Introduction

rsync

#!/bin/bash

# An rsync script to, for example, synchronise an SVN checkout on your local machine
# with a copy of your checkout, kept on a remote machine.  The files are transported
# via SSH, so all the usual comments about using SSH keys etc. apply

# set up some env vars
RSYNC=/usr/bin/rsync
REMOTE_HOST="full.domain.name.here"
REMOTE_USER_NAME="known-as"

# see the rsync man page for an explanation of these
OPTS='-vzrltp --progress --stats --rsh=/usr/bin/ssh --delete --exclude ".svn" --exclude "*~"'

LOCAL_SVN_CHECKOUT=/path/to/my/svn/dir
REMOTE_SRC_DIR=/path/to/my/src/on/remote/machine

# call rsync to PUSH your files to the remote host
$RSYNC $OPTS $LOCAL_SVN_CHECKOUT $REMOTE_USER_NAME@$REMOTE_HOST:$REMOTE_SRC_DIR

exit 0