Linux3

From SourceWiki
Jump to navigation Jump to search

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