{"id":588,"date":"2020-07-24T21:29:59","date_gmt":"2020-07-24T20:29:59","guid":{"rendered":"https:\/\/lengers.com\/?p=588"},"modified":"2021-01-02T11:04:22","modified_gmt":"2021-01-02T10:04:22","slug":"script-to-copy-synology-nas-smb-shares-on-macos-x-to-s3-glacier-storage-for-backup","status":"publish","type":"post","link":"https:\/\/www.lengers.com\/?p=588","title":{"rendered":"Script to copy Synology NAS SMB shares on MacOS X to S3 Glacier storage for backup"},"content":{"rendered":"\n<p class=\"wp-block-paragraph\"><\/p>\n\n\n\n<p class=\"wp-block-paragraph\">My soon to be retired Synology NAS needed a AWS S3 place to store the data. To do this I created an S3 bucket via the AWS console and you have to replace the &#8220;bucketname&#8221; with you actual bucket name.<br>In the &#8220;for&#8221; line there is a list of SMB shares that get mounted you have to replace that with your share name. &#8220;foto2015&#8230;.&#8221; in my case.<br>In ~\/Desktop there needs to be enough space to store the zip file temporarily for the whole SMB share.  I use the &#8220;zip -0&#8221; as the vast majority of my files are not compressable any way (it means do not attempt to compress). <br>Run the script with &#8220;sudo .\/Scriptname&#8221;. Make sure the script is executable (chmod u+x scriptname). Depending on your LAN and ISP speed and the size of your NAS SMB shares this can take many many hours. You need to have the AWS command line installed and setup with the Access Key etc. Try &#8220;aws s3 ls&#8221; to see if this works and you can see the S3 bucket you are trying to use. Hope this helps someone!<\/p>\n\n\n <script async src=\"\/\/pagead2.googlesyndication.com\/pagead\/js\/adsbygoogle.js\"><\/script>\r\n<!-- lengers.com-728x90 -->\r\n<ins class=\"adsbygoogle\"\r\n     style=\"display:inline-block;width:728px;height:90px\"\r\n     data-ad-client=\"ca-pub-8335976178265682\"\r\n     data-ad-slot=\"7888284778\"><\/ins>\r\n<script>\r\n(adsbygoogle = window.adsbygoogle || []).push({});\r\n<\/script>\n\n\n<h1 class=\"wp-block-heading\">The script<\/h1>\n\n\n\n<pre class=\"wp-block-preformatted\"><code>#!\/bin\/bash<\/code>\n# List all your shares in here<code>\nfor i in foto2015 foto2016 foto2017 foto2018 foto2019 foto2020\ndo\necho \"Start $i\"<\/code>\n#Mount the share, it will open a finder window<code>\nopen smb:\/\/username:password@10.10.10.2\/$i\nsleep 5<\/code>\n# zip the file to a local zip file from the mounted share<code>\n\/usr\/bin\/zip -0 -r ~\/Desktop\/$i.zip \/Volumes\/$i\nsleep 10<\/code>\n# copy the zip file to the s3 bucket with storage class glacier<code>\naws s3 cp ~\/Desktop\/$i.zip s3:\/\/bucketname --storage-class GLACIER\nsleep 10\numount \/Volumes\/$i\nrm ~\/Desktop\/$i.zip\nsleep 10\ndone<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\"> <script async src=\"\/\/pagead2.googlesyndication.com\/pagead\/js\/adsbygoogle.js\"><\/script>\r\n<!-- lengers.com-728x90 -->\r\n<ins class=\"adsbygoogle\"\r\n     style=\"display:inline-block;width:728px;height:90px\"\r\n     data-ad-client=\"ca-pub-8335976178265682\"\r\n     data-ad-slot=\"7888284778\"><\/ins>\r\n<script>\r\n(adsbygoogle = window.adsbygoogle || []).push({});\r\n<\/script><\/p>\n","protected":false},"excerpt":{"rendered":"<p>My soon to be retired Synology NAS needed a AWS S3 place to store the data. To do this I created an S3 bucket via the AWS console and you have to replace the &#8220;bucketname&#8221; with you actual bucket name.In the &#8220;for&#8221; line there is a list of SMB shares that get mounted you have [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_kad_blocks_custom_css":"","_kad_blocks_head_custom_js":"","_kad_blocks_body_custom_js":"","_kad_blocks_footer_custom_js":"","footnotes":""},"categories":[55],"tags":[78,83,81,80,76,82,79,77],"class_list":["post-588","post","type-post","status-publish","format-standard","hentry","category-computing","tag-backup","tag-copy","tag-glacier","tag-macos-x","tag-s3","tag-script","tag-smb","tag-synology","entry"],"featured_image_src_large":false,"author_info":{"display_name":"Remco","author_link":"https:\/\/www.lengers.com\/?author=1"},"comment_info":0,"category_info":[{"term_id":55,"name":"IT","slug":"computing","term_group":0,"term_taxonomy_id":55,"taxonomy":"category","description":"","parent":0,"count":11,"filter":"raw","cat_ID":55,"category_count":11,"category_description":"","cat_name":"IT","category_nicename":"computing","category_parent":0}],"tag_info":[{"term_id":78,"name":"Backup","slug":"backup","term_group":0,"term_taxonomy_id":78,"taxonomy":"post_tag","description":"","parent":0,"count":1,"filter":"raw"},{"term_id":83,"name":"copy","slug":"copy","term_group":0,"term_taxonomy_id":83,"taxonomy":"post_tag","description":"","parent":0,"count":1,"filter":"raw"},{"term_id":81,"name":"Glacier","slug":"glacier","term_group":0,"term_taxonomy_id":81,"taxonomy":"post_tag","description":"","parent":0,"count":1,"filter":"raw"},{"term_id":80,"name":"MacOS X","slug":"macos-x","term_group":0,"term_taxonomy_id":80,"taxonomy":"post_tag","description":"","parent":0,"count":1,"filter":"raw"},{"term_id":76,"name":"S3","slug":"s3","term_group":0,"term_taxonomy_id":76,"taxonomy":"post_tag","description":"","parent":0,"count":1,"filter":"raw"},{"term_id":82,"name":"Script","slug":"script","term_group":0,"term_taxonomy_id":82,"taxonomy":"post_tag","description":"","parent":0,"count":1,"filter":"raw"},{"term_id":79,"name":"SMB","slug":"smb","term_group":0,"term_taxonomy_id":79,"taxonomy":"post_tag","description":"","parent":0,"count":1,"filter":"raw"},{"term_id":77,"name":"Synology","slug":"synology","term_group":0,"term_taxonomy_id":77,"taxonomy":"post_tag","description":"","parent":0,"count":1,"filter":"raw"}],"taxonomy_info":{"category":[{"value":55,"label":"IT"}],"post_tag":[{"value":78,"label":"Backup"},{"value":83,"label":"copy"},{"value":81,"label":"Glacier"},{"value":80,"label":"MacOS X"},{"value":76,"label":"S3"},{"value":82,"label":"Script"},{"value":79,"label":"SMB"},{"value":77,"label":"Synology"}]},"_links":{"self":[{"href":"https:\/\/www.lengers.com\/index.php?rest_route=\/wp\/v2\/posts\/588","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.lengers.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.lengers.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.lengers.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.lengers.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=588"}],"version-history":[{"count":6,"href":"https:\/\/www.lengers.com\/index.php?rest_route=\/wp\/v2\/posts\/588\/revisions"}],"predecessor-version":[{"id":598,"href":"https:\/\/www.lengers.com\/index.php?rest_route=\/wp\/v2\/posts\/588\/revisions\/598"}],"wp:attachment":[{"href":"https:\/\/www.lengers.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=588"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.lengers.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=588"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.lengers.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=588"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}