<html><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; ">Wouldn't it be better to use conditional expressions from sh with a smaller footprint than rsync --list to check if the directory exists?<div>I think on something like:</div><div><span class="Apple-style-span" style="font-family: Times; "><pre>-d file
              True if file exists and is a directory.</pre><pre><span class="Apple-style-span" style="font-family: Helvetica; white-space: normal; ">(source: man sh)</span></pre><pre><font class="Apple-style-span" face="Helvetica"><span class="Apple-style-span" style="white-space: normal;">Cheers,</span></font></pre><pre><font class="Apple-style-span" face="Helvetica"><span class="Apple-style-span" style="white-space: normal;">Vitorio</span></font></pre></span><div><div>Le 18 mars 10 ŕ 17:30, Linux Expert a écrit :</div><br class="Apple-interchange-newline"><blockquote type="cite">Yes, it'll sync the source directory (now empty) to Server B, deleting everything due to the --delete option.<br><br>One solution I use is to place a check for the existence of a subdirectory just before the rsync command in the script.&nbsp; This was you can make rsync contingent on the existence of that subdirectory, possibly notifying you via email when it is not there.<br> <br>So if you had a subdirectory named "data" directly in the folder you're syncing, your script (bash) would have something like the following:<br><br><b>rsync --list server::folder/data 1&gt;/dev/null 2&gt;/dev/null<br> if [ $? eq 0 ] <br>&nbsp; then<br>&nbsp;&nbsp;&nbsp; <span lang="EN-US">rsync -a –delete server::folder &nbsp;/folder</span><br>&nbsp; else<br>&nbsp;&nbsp;&nbsp; mutt -nx -s "rsync skipped due to missing directory!" &lt;youremail&gt;<br>fi<br></b><br>The idea is that you first tell rsync to list all files under the folder/data directory.&nbsp; If that directory doesn't exist, the command will fail with a non-zero exit value.&nbsp; This is precisely what you check in the if conditional.&nbsp; Now your rsync will either sync properly with the assurance that the source folder is still there, or notify you via email.<br> <br>These commands, exit values, etc should all be tested on your server.&nbsp; You may not even have mutt installed, or an MTA (ie: Postfix) configured.&nbsp; Testing is key.<br><br><div class="gmail_quote">On Thu, Mar 18, 2010 at 8:46 AM, Christian Röder <span dir="ltr">&lt;<a href="mailto:cr@strassenfeger.tv">cr@strassenfeger.tv</a>&gt;</span> wrote:<br> <blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;"><div link="blue" vlink="purple" lang="DE"><div><p><span lang="EN-US">I was just pondering:</span></p><div><span lang="EN-US">&nbsp;</span><br class="webkit-block-placeholder"></div><p><span lang="EN-US">Lets look at Server A with one extra harddisc hdb, where hdb1 is mounted at /mnt/folder.</span></p><p><span lang="EN-US">/mnt/folder is the folder which should be mirrored on Server B.</span></p><p><span lang="EN-US">So Server B rsyncs </span></p><div><span lang="EN-US">&nbsp;</span><br class="webkit-block-placeholder"></div><p><span lang="EN-US">rsynch -a –delete server::folder &nbsp;/folder</span></p><div><span lang="EN-US">&nbsp;</span><br class="webkit-block-placeholder"></div><p><span lang="EN-US">from Server A and gets all the new files and deletes all the files, which doesn't exist on Server A's /mnt/folder anymore. </span></p><div><span lang="EN-US">&nbsp;</span><br class="webkit-block-placeholder"></div><p><span lang="EN-US">What would happen, if the harddisc hdb would fail?</span></p><p><span lang="EN-US">Will this happen?:</span></p><div><span lang="EN-US">&nbsp;</span><br class="webkit-block-placeholder"></div><p><span lang="EN-US">harddisc hdb failes</span></p><p><span lang="EN-US">hdb1 is not automatically mounted at /mnt/folder </span></p><p><span lang="EN-US">Server B rsyncs from Server A, but /mnt/folder is empty, so rsync deletes every file in the mirror folder on Server B?</span></p><div><span lang="EN-US">&nbsp;</span><br class="webkit-block-placeholder"></div><p><span lang="EN-US">Are my assumptions correct?</span></p><div><span lang="EN-US">&nbsp;</span><br class="webkit-block-placeholder"></div><p><span lang="EN-US">Thanks in advance, </span></p><div><span lang="EN-US">&nbsp;</span><br class="webkit-block-placeholder"></div><font color="#888888"><p> Christian</p><div>&nbsp;<br class="webkit-block-placeholder"></div></font></div></div><br>--<br> Please use reply-all for most replies to avoid omitting the mailing list.<br> To unsubscribe or change options: <a href="https://lists.samba.org/mailman/listinfo/rsync" target="_blank">https://lists.samba.org/mailman/listinfo/rsync</a><br> Before posting, read: <a href="http://www.catb.org/%7Eesr/faqs/smart-questions.html" target="_blank">http://www.catb.org/~esr/faqs/smart-questions.html</a><br></blockquote></div><br> -- <br>Please use reply-all for most replies to avoid omitting the mailing list.<br>To unsubscribe or change options: <a href="https://lists.samba.org/mailman/listinfo/rsync">https://lists.samba.org/mailman/listinfo/rsync</a><br>Before posting, read: <a href="http://www.catb.org/~esr/faqs/smart-questions.html">http://www.catb.org/~esr/faqs/smart-questions.html</a></blockquote></div><br></div></body></html>