RoboCopy Access Denied Report - Linux
Jump to navigation
Jump to search
After inheriting a mess of a Windows domain I was promptly tasked with keeping copies of files on remote servers in the datacenter. The weird thing is that the Domain Admins group does not have full access to all files (This was not done on purpose, just a case of incompetence and Windows ACLs).
As robocopy would run from the datacenter reaching out to grab files I would have logs be kept. The logs would detail failed files and directories that were previously successful so I needed to keep an eye on them. Using a linux archive server that had read only access to the file server I was able to write up a quick script that would email me a list of all failed files. It's rough around the edges but it gets the job done.
#!/bin/bash ##This first line is not necessary if your network and server are good. My environment was pushed to it's limits and performance was really poor so having the files locally was a good idea. cp /directory/where/robocopy/logs/are/kept/* /working/directory/for/files grep -r -B 1 denied /working/directory/for/files/ > /tmp/deniedlist.txt sed -i 's|.*\\\\||' /tmp/deniedlist.txt sed -i '/.*workingdir/d' /tmp/deniedlist.txt sendmail email@address.send < /tmp/deniedlist.txt rm -f /tmp/deniedlist.txt rm -f /working/directory/for/files/*