{"id":1136,"date":"2026-10-06T21:35:16","date_gmt":"2026-10-07T04:35:16","guid":{"rendered":"https:\/\/strawhousepig.net\/wordpress\/?p=1136"},"modified":"2026-10-06T21:40:15","modified_gmt":"2026-10-07T04:40:15","slug":"syncing-local-directory-to-remote","status":"publish","type":"post","link":"https:\/\/strawhousepig.net\/wordpress\/2026\/10\/06\/syncing-local-directory-to-remote\/","title":{"rendered":"Syncing local directory to remote"},"content":{"rendered":"\n<p>This is my script I run manually after importing the contents of my digital camera (and a camcorder). It uses <code>find<\/code> to&#8230;well find files newer than the last time it was run. Also, only runnable as superuser.<\/p>\n\n\n\n<p>It also &#8216;prunes&#8217; the target of files that aren&#8217;t necessary, like the local photo organizer&#8217;s db (<a href=\"https:\/\/shotwell-project.org\/\">Shotwell<\/a>, if you&#8217;re curious) using <code>rm<\/code> on a list from what was to be an exclude list for <code>rsync<\/code>, which turned out to slow things down dramatically. Though that was in place before using <code>find<\/code> to only send new files over.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>#!\/usr\/bin\/bash\n\n# Mount point.\nmp=\"\/mnt\/Example\"\n# Local storage.\nlstor=\"\/home\/user\/Pictures\/Cameras\/\"\n# Remote storage.\nrstor=\"\/\/example.local\/photo\/cameras\"\n# Credentials for above.\ncreds=\"\/home\/user\/.smb\/user@Example.local\"\n# Exclusions, but see note below.\nexcl=\"\/home\/user\/.local\/bin\/rsync-cameras-exclude.txt\"\n# Meant to be used with rsync option --exclude-from but that causes massive slow down.\n# Going to rm the list afterward instead. Although doesn't seem to be working...\n\n\n&#91; ! -d $mp ] &amp;&amp; mkdir $mp\n\n# Additional rsync options from stdin to this script.\naddopt=\"\"\nif &#91; $1 ]; then addopt=\" $1\"; fi\n\nmount -t cifs -o credentials=$creds $rstor $mp &amp;&amp; \\\n# So after adding a dozen years worth of pics and vids this takes over \n# 30 minutes every time it is run. Leaving as a reminder of a simpler time...\n#\/usr\/bin\/rsync -a$addopt --info=progress2 $lstor $mp\n\ncd $lstor &amp;&amp; \\\nfind . -newer '.\/last-rsync' | \/usr\/bin\/rsync -a$addopt --info=progress2 --files-from=- $lstor $mp &amp;&amp; \\\ndate &gt; .\/last-rsync\n\nif &#91; -f $excl ]; then\nfor i in `cat $excl`; do rm -rf '$mp$i'; done\nfi\n\numount $mp<\/code><\/pre>\n","protected":false},"excerpt":{"rendered":"<p>This is my script I run manually after importing the contents of my digital camera (and a camcorder). It uses find to&#8230;well find files newer than the last time it was run. Also, only runnable as superuser. It also &#8216;prunes&#8217; the target of files that aren&#8217;t necessary, like the local photo organizer&#8217;s db (Shotwell, if [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[2],"tags":[18,33,34],"class_list":["post-1136","post","type-post","status-publish","format-standard","hentry","category-code","tag-gnulinux","tag-script","tag-shell-script"],"_links":{"self":[{"href":"https:\/\/strawhousepig.net\/wordpress\/wp-json\/wp\/v2\/posts\/1136","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/strawhousepig.net\/wordpress\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/strawhousepig.net\/wordpress\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/strawhousepig.net\/wordpress\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/strawhousepig.net\/wordpress\/wp-json\/wp\/v2\/comments?post=1136"}],"version-history":[{"count":4,"href":"https:\/\/strawhousepig.net\/wordpress\/wp-json\/wp\/v2\/posts\/1136\/revisions"}],"predecessor-version":[{"id":1140,"href":"https:\/\/strawhousepig.net\/wordpress\/wp-json\/wp\/v2\/posts\/1136\/revisions\/1140"}],"wp:attachment":[{"href":"https:\/\/strawhousepig.net\/wordpress\/wp-json\/wp\/v2\/media?parent=1136"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/strawhousepig.net\/wordpress\/wp-json\/wp\/v2\/categories?post=1136"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/strawhousepig.net\/wordpress\/wp-json\/wp\/v2\/tags?post=1136"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}