DFRS has gone mad. Copying old files back - windows

My Issue
Our DFRs has gone mad and was having issues. It started copying back older versions of files from the destination to the source server.
Users have been updating files in the source server since last nights backup.
I am not sure what has been copied back though.
What I want to do is check the timestamp of files located in \SourceServer\Folder1 (and sub folders) and \TargetServer\Folder1 (and sub folders) and copy the latest version of all files to a separate Folder (say \SourceServer\Folder2)
Then I can restore the other files from last nights backup.
I have seen a way to use Powershell Compare-Object but only using a -referenceObject and a -differenceObject
All help is greatly appreciated.
Thanks in advance

You could use robocopy for that task. Run the following on SourceServer:
robocopy C:\path\to\Folder1 C:\path\to\Folder2 /e /copyall /dcopy:t /xj
robocopy \\TargetServer\Folder1 C:\path\to\Folder2 /e /copyall /dcopy:t /xj /xo
For general troubleshooting of DFS-R see here and here.

Related

rsync copy for a lots of different types of extensions

I'm trying to copy all of the mac files to usb external drive.
The purpose is, I need to copy specific types of file for internal investigation.
The Equivalent Robocopy command on Windows will be like this
Robocopy C:\ D:\Company\Dept.\username /S /DCOPY:T /TEE /R:1 /W:1 /NP /FP /V /TS /NDL
/BYTES /Log:D:\Company_Dept_userame.Log *.doc *.ppt *.xls *.docx *.pptx *.xlsx *.pdf
*.gul *.hst *.db *.dbf *.dzw *.dzi *.dbs *.mdb *.accdb *.pst *.eml *.msg *.edb *.dbx
*.ost *.mbox *.zip *.ace *.arj *.cab *.egg *.7z *.enc *.alz /XD Dirs "Documents and Settings" "Application Data"
it's pretty simple, copy the target file types from the entire OS disk to the external drive and make a log for this file copy.
But, for MacOS, I couldnt't make it using Rsync or using the CP. it just doesn't work for me making file path errors and I couldn't find any answers I could use neither.
Can anyone please help me to solve this issue?
Manual copying is such a pain.
Thank you,
Steve
I didnt want to post an answer to my question but just wanted share and hope there shouldn't be no more stupid like me.
I found the reason. I was running the source path as absolute path. I needed to cd to the root, which is Macintosh HD by
cd /
and then run the rsync command.
In my case, I'm copying all of my OS disk specifying a lots of extensions to the external disk so I ticked -aPcx which means
archive,skip checksum, exclude other disks.
especially 'x' option is important otherwise you'll get a copy of USB disk itself to the destination folder.
rsync -aPcx --prune-empty-dirs --log-file=/Volumes/SSD/Company_Dept_username.log --include=*/ --include=*.{hwp,doc,ppt,xls,docx,pptx,xlsx,pdf,gul,hst,db,dbf,dzw,dzi,dbs,mdb,accdb,pst,eml,msg,edb,dbx,ost,mbox,zip,ace,arj,cab,egg,7z,enc,alz} --exclude=* . /Volumes/SSD/Company/Dept/username

Trying to find a way to keep up to date MIR'ed directory of 7 days worth of info

I am trying to use Robocopy (Win10) to maintain a directory of 7 days worth of music that will 'age out', with the 8th prior day being deleted. I run this script nightly.
I have tried this, simply:
robocopy c:\music c:\music7 /MIR /MAXAGE:7 /S
Initial copy works great; what happens though is files that are 8 days old (or older) are not 'purged' from music7 directory on the 8th day. Am I missing a parameter in robocopy to cull those?
You can repro this also by running the first command:
robocopy c:\music c:\music7 /MIR /MAXAGE:7
and then re-running altering the MAXAGE to lower
robocopy c:\music c:\music7 /MIR /MAXAGE:2
and note that days 3-7 content are not removed.
I think you have a misconception about the purge logic (/purge) implied by the /mir option:
Only files that no longer exist in the source directory are also removed from the destination directory, which is unrelated to the /maxage:<N> option.
/maxage:<N> only restricts which of the existing source files are copied, by when they were last modified.
It does not mean that older files are automatically removed from the destination directory.
Therefore, assuming that you want to keep older files around in the source folder and only purge them from the destination folder:
Run robocopy c:\music c:\music7 /mir /maxage:7, as before, which will copy only the last 7 days' worth of file to the destination folder.
As an aside: no need for option /s (copy subdirs., except empty ones), because /mir implies /e (copy subdirs., including empty ones)
Then use a different tool / shell, such as PowerShell, to remove older files from the destination folder:
$cutOffDate = (Get-Date).Date.AddDays(-7)
Get-ChildItem -File -Recurse -LiteralPath c:\Music7 |
Where-Object { $_.LastWriteTime -lt $cutOffDate } |
Remove-Item -WhatIf
-WhatIf previews what will be deleted; remove it to perform actual deletion.
Thanks very much for the comments. After additional research I was able to get what I was after staying in CMD using the ForFiles command in conjunction with Robocopy in a batch file.
Similar to these lines:
ForFiles /p "c:\music7" /d -7 /c "cmd /c del #path /Q /S"
ForFiles /p "c:\music7" /d -7 /c "cmd /c rd #path /Q"
Robocopy c:\music c:\music7 /MIR /MAXAGE:6
Things can get a little quirky since I can have some directories whose dates appear to be modified earlier or later than their files under them, so I can't just do a destructive RD /S; robocopy will add the files back on its run.
PS - For those curious, this methodology allows me to effectively emulate time based autoplaylists for Groove which doesn't support it natively like WMP or Zune did. I can push the 7 days worth of songs into OneDrive\Music and filter on that in the player clients to play that subset of my collection. Now I have a way to task scheduler automate the purge older than 7 days content. Thanks again.
In powershell after your robocopy or a separate process
Get-ChildItem -file -path C:\music ($_.CreationTime -le (Get-Date).AddDays(-8)) | remove-item

Robocopy copy files source to destination date range

I am trying to copy the folders and files created between the date range. But this following command looks like copying everything from the source ignoring the date range. What could be wrong?
robocopy c:\source c:\destination /E /dcopy:t /MAXAGE:20100101 /MINAGE:20110101
The /maxage and /minage switches in robocopy seem to refer to the modified date. It is not obvious from the documentation but if you try for yourself you can easily verify that. There are no switches for the creation date so I believe the only solution here is powershell if the difference in performance is acceptable to you.

Robocopy: /move parameter not working correctly

I'm using a robocopy batch script to move files from one server to another,
but I need it to delete the files on the original server after it is done
(which should happen when you use /move).
The copying works fine, but the files and folders aren't deleted afterwards.
Can anyone tell me what might be going wrong?
Command:
robocopy "\\Srv04\data\logs" "F:\Logs" /move /S /minage:8
thanks,
Gotcha:- Please note that using ROBOCOPY with the /MOVE command other than permission problems won’t remove source directories and files if those items already exists at the target because they will be skipped.
You can get around this by quoting a new target destination.
Question solved: It was a permission problem

Robocopy CLI syntax won't work

I just recently saw that xcopy is deprecated and that Robocopy is recommended.
I tried moving files with it, but couldn't get it to work.
I tried moving files from C:\Downloads\Temp to F:\Temp
Both folders had no files directly under them. Downloads\Temp has about 20 folders, some of which have subfolders, which are eventually filled with files.
With the following syntax, it didn't work:
robocopy C:\Downloads\Temp F:\Temp /move
So I tried giving a wildcard for files:
robocopy C:\Downloads\Temp F:\Temp * /move
Didn't work either. I ended up doing it with xcopy, no problem.
Can someone tell me what I did wrong here?
I'm on Windows Vista Enterprise SP1, as administrator(CMD was also run as administrator)
With the following syntax, it didn't work:
robocopy C:\Downloads\Temp F:\Temp /move
Yes - this says move all files from c:\downloads\temp to f:\temp - only files directly in those directories.
You need the /S switch to say "recursively down the directory stack":
robocopy C:\Downloads\Temp F:\Temp /S /move
Marc

Resources