nashchelsy Posted July 6, 2019 Share Posted July 6, 2019 I am writing a list of commands to run via SSH to backup my files monthly. I am wanting to run a command to change the SMB security of a share from Public to Secure before I start, then another command to do the opposite when completed. Instead of having to load up the Web UI and doing it that way. Is there a way to do that? Quote Link to comment
nashchelsy Posted July 7, 2019 Author Share Posted July 7, 2019 I think I figured it out. I found where the config files for each share is located: /boot/config/shares/SHARENAME.cfg All I did was changed the SMB permission on the WEB UI to each of the three and made a copy of the config each time to a folder to have all three permission types for that share. Then I run commands to append the config file with .BAK, then copy one of the three that I copied to where the config files are housed, and name the copied file to what the .BAK one was named. I also added a line at the beginning to delete any .BAK that was present for some reason to prevent corruption issues. Pre Backup script:rm -f '/boot/config/shares/SHARENAME.cfg.BAK' mv '/boot/config/shares/Cloud-Files.cfg' '/boot/config/shares/Cloud-Files.cfg.BAK' cp '/mnt/disks/PATH-TO-FILE/SHARENAME.cfg-DESIREDPERMISSION.bak' '/boot/config/shares/SHARENAME.cfg' Once backups are completed, I delete the config file that was copied over, then truncate .BAK from the original file name to restore it back into place. Post backup scriptrm -f '/boot/config/shares/SHARENAME.cfg' mv '/boot/config/shares/SHARENAME.cfg.BAK' '/boot/config/shares/SHARENAME.cfg' Hope this helps anyone who goes searching for wanting to do anything similar to this. Keep in mind, if you change any settings for the share, you will want to replace your copies of the config file or you may cause problems with your share(s). Quote Link to comment
BRiT Posted July 7, 2019 Share Posted July 7, 2019 Question: What's the point of switching from Public to Secure? Did you restrict users as well when setting it to Secure? If not, then every user still has the same access, so what does it get you? Quote Link to comment
nashchelsy Posted July 7, 2019 Author Share Posted July 7, 2019 It makes all the files in the share read-only to any guest user who tries to access it. That way none of the files can be modified while the backed up is being conducted. But if you needed to access a file(s) for whatever reason, you can still do so. You could also do Private instead, to stop guests from accessing the share completely. In my use case, all our devices access shares as guest. So changing a share to Secure makes it read-only. 1 Quote Link to comment
Squid Posted July 7, 2019 Share Posted July 7, 2019 Wouldn't you also have to restart the smb daemon to pick up the changes in the .cfg files? Quote Link to comment
nashchelsy Posted July 7, 2019 Author Share Posted July 7, 2019 I thought I would have to, but it automatically picked up the changes. Quote Link to comment
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.