<

File Share Archiving Solution

Published on
6,259 Points
259 Views
Last Modified:
Editors:
Shaun Vermaak
My name is Shaun Vermaak and I have always been fascinated with technology and how we use it to enhance our lives and business.
Archiving data from file servers is essential in preventing stale data from clogging up space and old folders overcomplicating the structure.

Introduction


This article outlines an uncomplicated Powershell script for archiving data from a file server. This process should be configured by a server administrator and typically would run as a scheduled task to ensure automated archiving.


The function dynamically creates the archive date based on the current date and archive age then leverages Robocopy with a few parameters to move these files to the archive location. The date created, date modifies and date accessed is interrogated so that it ensures only the correct files are archived.


It is best if this archive location has some sort of compression, duplication or is a cheaper storage.


The intention of the article is not to replace the need for a commercial data classification and archiving solution, but provide a functional archiving solution if you do have or cannot afford such a system.


The Powershell function


Simply run this to import the Powershell function.


function ArchiveData($a, $b, $c)
{
    # Build dynamic date for archiving
    $archiveDate = (Get-Date).AddDays(-$($c)).ToString("yyyyMMdd")

    # Run robocopy move command that ensures permission stays the same
    robocopy "$($a)" "$($b)" /W:1 /R:1 /MOV /COPYALL /b /minage:$archiveDate /minlad:$archiveDate /s /xf Thumbs.db desktop.ini /xd $RECYCLE.BIN """System Volume Information"""
}


Examples


# Example 1
# Archive data older, unmodified and not accessed for 1 year 
# from D:\CorporateData\DepartmentA to D:\ArchivedData\DepartmentA
ArchiveData "D:\CorporateData\DepartmentA" "E:\ArchivedData\DepartmentA" "365"

# Example 2
# Archive data older, unmodified and not accessed for 100 days
# from D:\CorporateData\DepartmentB to D:\ArchivedData\DepartmentB
ArchiveData "D:\CorporateData\DepartmentB" "E:\ArchivedData\DepartmentB" "100"

# Example 3
# Archive data older, unmodified and not accessed for 30 days
# from D:\CorporateData\DepartmentC to D:\ArchivedData\DepartmentC
ArchiveData "D:\CorporateData\DepartmentC" "E:\ArchivedData\DepartmentC" "30"


Drive Mapping


After setting this up, you may choose to map an additional drive map to this archive data. When I configured it, I set this to read-only. This means, users can retrieve data from their archive data drive mapping, but not actually save to it.



If a user wants to work on an archived file, there are two options:

  • Open the file and save to a new location. A user will typically get a message saying that file is read-only.
  • Copy the file to a new location before opening it


Navigating to the desired archived file is also familiar to the end user, because the folder structure is maintained in the archive folder.


Conclusion


I hope you found this tutorial useful. You are encouraged to ask questions, report any bugs or make any other comments about it below.

 

Note: If you need further "Support" about this topic, please consider using the Ask a Question feature of Experts Exchange. I monitor questions asked and would be pleased to provide any additional support required in questions asked in this manner, along with other EE experts...  

 

Please do not forget to press the "Thumbs Up" button if you think this article is helpful and valuable for EE members.


It also provides me with positive feedback. Thank you!

0
Ask questions about what you read
If you have a question about something within an article, you can receive help directly from the article author. Experts Exchange article authors are available to answer questions and further the discussion.
Get 7 days free