I've got an IT problem I could use some assistance with. I work at a large organization with many users (1000+). We're currently on a mixed Server 2012 R2/2008/Windows 7 environment. The situation is this:

Leadership has mandated that important documents on the computers my department supports should be backed up to the network drives that are provisioned for each user. This mostly involves documents, critical Word and Excel files, AutoCAD files, and the like.

Due to space constraints on the servers and the size of the organization, we're not currently using redirected files or backing up all user data to a central location. The idea some years ago was for the network drives to function like a Dropbox folder might, with the users self-policing what content was uploaded based on what they felt was most important to them. Leadership became concerned that this wasn't happening, however, and that many people weren't using the drives at all, and that's where the mandate came in. Lots of users still aren't complying, though.

I've been asked to find a way to determine which users are backing up properly and which are not, to the extent that it's possible to do so. Although I primarily work with Windows, I know much more about Unix-like scripting for this sort of thing than I do about PowerShell or VBS. I've proposed implementing an rsync-based solution like cwrsync to just force syncing based on a set of detailed rules, but leadership is more interested in just finding out who's not complying so they can get the users to do it themselves. Their concern is that once we open the floodgates with a broad backup policy, the servers might get rapidly overloaded, even if we attempt to limit the size of files backed up through the rules.

So the idea is to find a script or program which can compare the files on the computers and the shares for each user and tell us what's missing from one or the other. I've found some really basic PowerShell commands that do that, but only for file names--so information like sizes, dates, and types isn't included. Processing all of this data is also challenging, so it would be nice to find something that gives me a robust output that I can easily sort through.

Any ideas about where I can look?

  • You can't force people to save their documents to a share drive. Even if you do they can remove the file from the share, and put it in a location, only they can access. The use of roaming profiles might help, at least then, all files within their profile are in a central location which can be managed by staff dedicated to backing it up. – Ramhound Mar 15 '16 at 19:43
  • @Ramhound I would tend to agree, but that's the way the higher-ups have decided to go. Roaming profiles have been discussed as a potential solution, but again, that would probably require a really significant investment in storage capacity that they aren't ready to make right now. We have a lot of capacity, but the organization is just so huge that we'd have to build in a lot more to make a centralized solution work. – user571190 Mar 15 '16 at 19:48
  • So write a small program that runs as a service, that daily does a recursive search for documents, that you want placed on the share drive that exist on the user's profile. Have the service create the network share drive folder, and check if the file already exists, the program wouldn't be tough to write. – Ramhound Mar 15 '16 at 20:22
  • They don't want to backup everything automatically because it would require too much storage space. But they want everyone to voluntarily backup everything manually. Will it take up less space if people meet the goal manually? If the idea is that people don't need to backup everything, so their intelligent selection will save space, and only they know what to backup, what are you going to do with the massive compliance data? If you knew what needs backup, you could write scripts. So basically, you've been assigned to irritate people? – fixer1234 Mar 16 '16 at 3:42

The Compare-Object command in PowerShell would be a good place to start.

Something like this:

$ref = Get-ChildItem C:\users\user\folder
$dif = Get-ChildItem \\Share\Folder

Compare-Object -referenceobject $ref -differenceobject $dif

should give you an output like this:

InputObject SideIndicator
----------- -------------
TEST3.txt   =>           
TEST1.txt   <=           

This would show that the difference object location (the remote share) has TEST3.txt, but the reference object (the local folder) does not and the reference object location has TEST1.txt but the difference object location does not.

In this test there was a file called TEST2.txt in both locations and it does not show in the results.


The CMD command FC can be used to do this two ways:

1) FC _usersFilePath_\* _shareFilepath_\* > compare.txt This will compare the files and output the results to a txt file

2) A batch file: (Will do the same as above but without checking the contents of the files)

cd _usersFilePath_
tree /d > usersFiles.txt
cd _shareFilePath_
tree /d > shareFiles.txt
fc usersFiles.txt shareFiles.txt > compare.txt

Source: https://stackoverflow.com/a/6877352/5540644

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy