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 “bucketname” with you actual bucket name.
In the “for” line there is a list of SMB shares that get mounted you have to replace that with your share name. “foto2015….” in my case.
In ~/Desktop there needs to be enough space to store the zip file temporarily for the whole SMB share. I use the “zip -0” as the vast majority of my files are not compressable any way (it means do not attempt to compress).
Run the script with “sudo ./Scriptname”. 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 “aws s3 ls” to see if this works and you can see the S3 bucket you are trying to use. Hope this helps someone!
The script
#!/bin/bash
# List all your shares in herefor i in foto2015 foto2016 foto2017 foto2018 foto2019 foto2020 do echo "Start $i"
#Mount the share, it will open a finder windowopen smb://username:password@10.10.10.2/$i sleep 5
# zip the file to a local zip file from the mounted share/usr/bin/zip -0 -r ~/Desktop/$i.zip /Volumes/$i sleep 10
# copy the zip file to the s3 bucket with storage class glacieraws s3 cp ~/Desktop/$i.zip s3://bucketname --storage-class GLACIER sleep 10 umount /Volumes/$i rm ~/Desktop/$i.zip sleep 10 done