summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRaphael Geissert <geissert@debian.org>2012-12-14 14:36:54 -0600
committerSimon Paillard <spaillard@debian.org>2013-05-01 01:23:16 +0200
commit8d734b614f2f6a33f71cc0758ac146804952b0c4 (patch)
treecd3621ee4a4da932ad2fc2ee253788ce81b0e655
parent3dd8920d9f8ca9b868f01fb136e9eb5d3bade338 (diff)
Add RSYNC_DELETE_METHOD option to make it easier to use --delete-delay
If RSYNC_OPTIONS2 hasn't been modified, this will result in --delete-delay being used if rsync 3.0.0 or greater is used. Signed-off-by: Raphael Geissert <geissert@debian.org>
-rwxr-xr-xbin/ftpsync24
-rw-r--r--etc/ftpsync.conf.sample8
2 files changed, 30 insertions, 2 deletions
diff --git a/bin/ftpsync b/bin/ftpsync
index da665e5..23d7eb0 100755
--- a/bin/ftpsync
+++ b/bin/ftpsync
@@ -290,12 +290,29 @@ RSYNC=${RSYNC:-rsync}
RSYNC_FILTER=${RSYNC_FILTER:-"--filter=protect_Archive-Update-in-Progress-${MIRRORNAME} --filter=protect_${TRACE} --filter=protect_Archive-Update-Required-${MIRRORNAME}"}
# limit I/O bandwidth. Value is KBytes per second, unset or 0 is unlimited
RSYNC_BW=${RSYNC_BW:-0}
+
+# Set the delete method to --delete-delay if protocol version is 30 or
+# greater (meaning rsync 3.0.0 or greater is used). Use --delete-after
+# otherwise.
+RSYNC_DELETE_METHOD=${RSYNC_DELETE_METHOD:-auto}
+if [ "xautox" = "x${RSYNC_DELETE_METHOD}x" ]; then
+ RSYNC_DELETE_METHOD=after
+
+ RSYNC_VERSION="$(${RSYNC} --version)"
+ if [[ $RSYNC_VERSION =~ (protocol[ ]+version[ ]+([0-9]+)) ]]; then
+ if [ 30 -le ${BASH_REMATCH[2]} ]; then
+ RSYNC_DELETE_METHOD=delay
+ fi
+ fi
+ unset RSYNC_VERSION
+fi
+
# Default rsync options for *every* rsync call
RSYNC_OPTIONS=${RSYNC_OPTIONS:-"-prltvHSB8192 --timeout 3600 --stats ${RSYNC_FILTER}"}
# Options we only use in the first pass, where we do not want packages/sources to fly in yet and don't want to delete files
RSYNC_OPTIONS1=${RSYNC_OPTIONS1:-"--exclude=Packages* --exclude=Sources* --exclude=Release* --exclude=InRelease --exclude=i18n/* --exclude=ls-lR*"}
# Options for the second pass, where we do want everything, including deletion of old and now unused files
-RSYNC_OPTIONS2=${RSYNC_OPTIONS2:-"--max-delete=40000 --delay-updates --delete --delete-after --delete-excluded"}
+RSYNC_OPTIONS2=${RSYNC_OPTIONS2:-"--max-delete=40000 --delay-updates --delete --delete-excluded"}
# Which rsync share to use on our upstream mirror?
RSYNC_PATH=${RSYNC_PATH:-"debian"}
@@ -307,6 +324,11 @@ RSYNC_EXTRA=${RSYNC_EXTRA:-""}
# 0 as unlimited, so this is safe.
RSYNC_OPTIONS="${RSYNC_EXTRA} --bwlimit=${RSYNC_BW} ${RSYNC_OPTIONS}"
+# Finally, make sure RSYNC_OPTIONS2 has either --delete-after or --deleter-delay
+if ! [[ ${RSYNC_OPTIONS2} =~ --delete-(after|delay) ]]; then
+ RSYNC_OPTIONS2+=" --delete-${RSYNC_DELETE_METHOD}"
+fi
+
# We have no default host to sync from, but will error out if its unset
RSYNC_HOST=${RSYNC_HOST:-""}
# Error out if we have no host to sync from
diff --git a/etc/ftpsync.conf.sample b/etc/ftpsync.conf.sample
index 4d96efb..3a8abe0 100644
--- a/etc/ftpsync.conf.sample
+++ b/etc/ftpsync.conf.sample
@@ -124,6 +124,12 @@
## limit I/O bandwidth. Value is KBytes per second, unset or 0 means unlimited
#RSYNC_BW=""
+## Method used to delete files: "delay" or "after". "delay" is
+## recommended and is the default if no value is set and rsync 3 is
+## detected. NOTE: for this to work, neither --delete-after nor
+## --delete-delay should be set in RSYNC_OPTIONS2 (below).
+#RSYNC_DELETE_METHOD=""
+
## BE VERY CAREFUL WHEN YOU CHANGE THE RSYNC_OPTIONS! BETTER DON'T!
## BE VERY CAREFUL WHEN YOU CHANGE THE RSYNC_OPTIONS! BETTER DON'T!
## BE VERY CAREFUL WHEN YOU CHANGE THE RSYNC_OPTIONS! BETTER DON'T!
@@ -144,7 +150,7 @@
## Options the second pass gets. Now we want the Packages/Source indices too
## and we also want to delete files. We also want to delete files that are
## excluded.
-#RSYNC_OPTIONS2="--max-delete=40000 --delay-updates --delete --delete-after --delete-excluded"
+#RSYNC_OPTIONS2="--max-delete=40000 --delay-updates --delete --delete-excluded"
## You may establish the connection via a web proxy by setting the environment
## variable RSYNC_PROXY to a hostname:port pair pointing to your web proxy. Note