create rsync mirror

This commit is contained in:
belliash 2012-01-21 15:35:21 +01:00
parent 9c4cce0f4e
commit 0345600e53
1 changed files with 17 additions and 0 deletions

View File

@ -30,6 +30,9 @@ function mirrorRepository() {
[Gg][Ii][Tt])
mirrorGit "${1}" "${3}" "${4}" && return 0
;;
[Rr][Ss][Yy][Nn][Cc])
mirrorRsync "${1}" "${3}" "${4}" && return 0
;;
*)
printWarn "Tried to mirror data using unsupported protocol (${2})!"
;;
@ -37,6 +40,20 @@ function mirrorRepository() {
return 1
}
#-------------------------------------------------------------------------------
# Creates a local mirror of specified RSYNC repository
# Parameters: %dest_directory% %address% [%username%]
#-------------------------------------------------------------------------------
function mirrorRsync() {
local DIRECTORY="${1}"
local ADDRESS="${2}"
local USER="${3:-root}"
run "su ${USER} -s \"/bin/sh\" -c \"rsync --compress --devices --delete \
--links --perms --recursive --stats --timeout=${FETCHTIMEOUT} --times \
${ADDRESS} ${DIRECTORY}\""
return ${?}
}
#-------------------------------------------------------------------------------
# Prepares SSH Wrappers for use with unknown hosts (requires key authentication)
#-------------------------------------------------------------------------------