Browse Source

create rsync mirror

belliash 7 years ago
parent
commit
0345600e53
1 changed files with 17 additions and 0 deletions
  1. 17
    0
      libraries/repositories

+ 17
- 0
libraries/repositories View File

@@ -30,6 +30,9 @@ function mirrorRepository() {
30 30
 		[Gg][Ii][Tt])
31 31
 			mirrorGit "${1}" "${3}" "${4}" && return 0
32 32
 			;;
33
+		[Rr][Ss][Yy][Nn][Cc])
34
+			mirrorRsync "${1}" "${3}" "${4}" && return 0
35
+			;;
33 36
 		*)
34 37
 			printWarn "Tried to mirror data using unsupported protocol (${2})!"
35 38
 			;;
@@ -37,6 +40,20 @@ function mirrorRepository() {
37 40
 	return 1
38 41
 }
39 42
 
43
+#-------------------------------------------------------------------------------
44
+# Creates a local mirror of specified RSYNC repository
45
+# Parameters: %dest_directory% %address% [%username%]
46
+#-------------------------------------------------------------------------------
47
+function mirrorRsync() {
48
+	local DIRECTORY="${1}"
49
+	local ADDRESS="${2}"
50
+	local USER="${3:-root}"
51
+	run "su ${USER} -s \"/bin/sh\" -c \"rsync --compress --devices --delete \
52
+		--links --perms --recursive --stats --timeout=${FETCHTIMEOUT} --times \
53
+		${ADDRESS} ${DIRECTORY}\""
54
+	return ${?}
55
+}
56
+
40 57
 #-------------------------------------------------------------------------------
41 58
 # Prepares SSH Wrappers for use with unknown hosts (requires key authentication)
42 59
 #-------------------------------------------------------------------------------

Loading…
Cancel
Save