In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-16 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >
Share
Shulou(Shulou.com)06/03 Report--
Background information:
Our data is stored in three locations, local, in the same city and in different places. Backup data will be placed locally, and then routinely synchronized to two places in the same city and different places through DFS. Because DFS is bidirectionally synchronized, if you delete and update files in one place, the three places will be updated synchronously to be consistent.
Due to the limitation of the amount of data, I can't save the data on the server indefinitely, so I delete the old backup regularly. However, the local hard disk of my remote server is relatively large, so I want to save the historical data on the remote server to the maximum extent.
Solution:
File Server Resource Manager's File Managerment Task function can filter files based on their creation date, modification date, or custom classification attributes, and execute custom action. For the custom action here, we use the powershell script.
The powershell script performs a mklink / H operation on the source file in another directory against the filtered file (create a hard link, the advantage of which is that if the file in the DFS directory is deleted, the actual file will not be deleted, because there is also a hard link that references the actual file data, the hard link will be faster than Copy, and the IO will be very small).
File Server Resource Manager has its own reporting function, so it is possible to generate reports on manipulated files.
Create a classification attribute IsHardLinkCreated, which we use to filter files that have not been hardlink (the powershell script sets this property after the hardlink file).
Do the following file contents in c:\ scripts\ makelink.ps1
Param ([string] $FileSource, [string] $FolderDestination) # Capture source folder name and filename$SourceFileName = (Get-Item $FileSource). Name$SourceFolder = (Get-Item $FileSource). DirectoryName# DestinationPath $DestinationPath = $FolderDestination + "\" + $SourceFolder.Substring (3, $SourceFolder.Length-3) # Check DestinationPath, create if doesn't exist$CheckedPath = Get-Item $DestinationPath-ErrorAction SilentlyContinueif ($CheckedPath-eq $null) {New-Item-Path$DestinationPath-ItemType Directory | Out-Null} $destFile=$DestinationPath + "\" + $SourceFileName# test whether dest file exist If exist delete it. If (test-path $destFile) {Remove-Item-Path $destFile-Force} # Move original file# Move-Item-Path $FileSource-Destination $DestinationPath-Force# Create Hard link to origin file in destation folder$expr = Invoke-Expression-Command ("cmd / c mklink / H `"+ $destFile +"` "`" + $FileSource + "`") # Please create Classification properties in File server resource manager named IsHardLinkCreated first$cls = New-Object-com Fsrm.FsrmClassificationManager$cls.setFileProperty ($FileSource, "IsHardLinkCreated", 1) $cls=$nothing
Create a powershell script for File Management Tasks. C:\ scripts\ CreateFSRMTask.ps1
$Command = "C:\ Windows\ System32\ WindowsPowerShell\ v1.0\ PowerShell.exe" $CommandParameters = "`" C:\ scripts\ MakeLink.ps1-FileSource'[Source File Path]'- FolderDestination'E:\ Expired'` "$Action = New-FSRMFmjAction-Type Custom-Command $Command-CommandParameters $CommandParameters-SecurityLevel LocalSystem-WorkingDirectory" C:\ Windows\ System32\ WindowsPowerShell\ v1.0\ "$Condition = New-FsrmFmjCondition-Property" File.DateCreated "- Condition LessThan-Value" Date.Now "- DateOffset-5 $condition2=New-FsrmFmjCondition-Property "IsHardLinkCreated"-Condition NotExist$Schedule = New-FsrmScheduledTask-Time (Get-Date)-Weekly Sunday Monday,Tuesday,Wednesday,Thursday,Friday,SaturdayNew-FsrmFileManagementJob-Name "Make Hard Link of old files"-Namespace "E:\ DR_FromSZ"-Action $Action-Condition $Condition,$condition2-Schedule $Schedule
In addition, documents that have already done hardlink will mark the classification.
At this time, even if the source files of the DFS directory are deleted, the files under the Expired subdirectory of hardlink still exist.
Reference Information:
Https://blogs.technet.microsoft.com/filecab/2009/05/11/customizing-file-management-tasks/
Https://msdn.microsoft.com/en-us/library/windows/desktop/microsoft.storage.fsrmclassificationmanagerclass.setfileproperty(v=vs.85).aspx
Summary:
If the source file is deleted after the hardlink is created, and then a file with the same name is created in the source location, the target file will not be updated. If you want to create the hardlink again, you need to delete the destination first.
Because this powershell custom task I feel is executed sequentially, and the powershell script is called once for each file, so the efficiency is not very high, but it should not be a big problem for large files after backup (because most systems only have a few large backup files a day), if it is a lot of small files, the execution time is estimated to be slow.
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
Chntpw cracked the windows login password
© 2024 shulou.com SLNews company. All rights reserved.