diff --git a/_data/docs.yml b/_data/docs.yml index 1f433ba..95e09dd 100644 --- a/_data/docs.yml +++ b/_data/docs.yml @@ -15,4 +15,5 @@ - /manual/examples - title: Appendices docs: + - /faq - /appendices/devdocs diff --git a/faq/index.md b/faq/index.md new file mode 100644 index 0000000..9656a7c --- /dev/null +++ b/faq/index.md @@ -0,0 +1,6 @@ +--- +layout: default +title: Frequently Asked Questions +short: FAQ +--- + * [How can I call a script after each rsync operation?](postscript) diff --git a/faq/postscript/index.md b/faq/postscript/index.md new file mode 100644 index 0000000..03df36f --- /dev/null +++ b/faq/postscript/index.md @@ -0,0 +1,40 @@ +--- +layout: default +title: FAQ: How can I call a script after each rsync operation? +--- +The issue with this quite frequent request is, by itself it complicates error handling a lot. What should Lsyncd do, when the script fails that it ought to run after each rsync call? If it should recall the post script it would require a new state for each rsync event which would complicate Lsyncd code quite a bit. + +The easiest way to get around this, is by replacing the rsync binary Lsyncd calls by a script from you, that calls rsync and does whatever you want to do, when rsync completes. The only thing to take care is that Lsyncd communicates with rsync using stdin/out/err-pipes and thus better not interfere with these. + +Also take care the script properly forwards the exit code rsync returned. + +This is an example bash script to wrap around rsync: + +{% highlight shell %} +#!/bin/bash +/usr/bin/rsync "$@" +result=$? +( + if [ $result -eq 0 ]; then + echo "my commands"; + fi +) >/dev/null 2>/dev/null