{"id":1145,"date":"2010-12-02T22:05:30","date_gmt":"2010-12-02T22:05:30","guid":{"rendered":"http:\/\/www.haydnwilliams.com\/blog\/?p=1145"},"modified":"2022-04-11T21:44:25","modified_gmt":"2022-04-11T20:44:25","slug":"sync-folders-to-network-drive","status":"publish","type":"post","link":"https:\/\/www.haydnwilliams.com\/blog\/sync-folders-to-network-drive\/","title":{"rendered":"Sync folders to network drive"},"content":{"rendered":"<p>I finally found time last night to set up a script to sync my &#8220;Music&#8221; folder from the MacBook to our NAS drive. It actually turned out to be fairly simple, after browsing a couple of sites to refresh my memory about <a href=\"http:\/\/rsync.samba.org\/\" target=\"_blank\" rel=\"noopener\">rsync<\/a>. The script below will mount a network drive, sync a folder across to it, and then unmount it again:<\/p>\n<pre>#! \/bin\/bash\r\nmkdir \/Volumes\/music\r\nmount_smbfs \/\/nas_drive\/music \/Volumes\/music -o username=myusername,password=mypassword\r\nrsync --verbose --progress --stats --compress --recursive --times --perms --delete \\\r\n    \/Users\/me\/Music\/ \/Volumes\/music\/ &gt;&gt; ~\/Users\/me\/Desktop\/music_sync.log\r\numount \/Volumes\/music\/<\/pre>\n<p>Simple but effective. Remember that the line beginning &#8216;rsync&#8217; and the one below (beginning &#8216;\/Users&#8217;) are all part of the same command; I&#8217;ve just used a backslash at the end of the first line to continue the command on the next line for clarity on this blog.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>I finally found time last night to set up a&#46;&#46;&#46;<\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[4],"tags":[536,537,529,528,530,535,534,531,533,532,525,526,527,334],"class_list":["post-1145","post","type-post","status-publish","format-standard","hentry","category-it","tag-mount","tag-mount_smbfs","tag-nas","tag-network","tag-network-attached-storage","tag-network-drive","tag-rsync","tag-samba","tag-server","tag-smb","tag-sync","tag-synchronise","tag-synchronize","tag-terminal"],"_links":{"self":[{"href":"https:\/\/www.haydnwilliams.com\/blog\/wp-json\/wp\/v2\/posts\/1145","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.haydnwilliams.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.haydnwilliams.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.haydnwilliams.com\/blog\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/www.haydnwilliams.com\/blog\/wp-json\/wp\/v2\/comments?post=1145"}],"version-history":[{"count":0,"href":"https:\/\/www.haydnwilliams.com\/blog\/wp-json\/wp\/v2\/posts\/1145\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.haydnwilliams.com\/blog\/wp-json\/wp\/v2\/media?parent=1145"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.haydnwilliams.com\/blog\/wp-json\/wp\/v2\/categories?post=1145"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.haydnwilliams.com\/blog\/wp-json\/wp\/v2\/tags?post=1145"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}