= Enable data deduplication
:toc:
:icons:
:linkattrs:
:imagesdir: ../resources/images


== Summary

This section will enable data deduplication.


== Duration

NOTE: It will take approximately 20 minutes to complete this section.


== Step-by-step Guide

=== Enable data deduplication

IMPORTANT: Read through all steps below and watch the quick video before continuing.

image::enable-data-dedup.gif[align="left", width=600]


. *_Copy_* the script below into your favorite text editor.
+
[source,bash]
----
$WindowsRemotePowerShellEndpoint = "windows_remote_powershell_endpoint" # e.g. "amznfsx0123abcde.example.com"
enter-pssession -ComputerName ${WindowsRemotePowerShellEndpoint} -ConfigurationName FsxRemoteAdmin

----
+

. From the link:https://console.aws.amazon.com/fsx/[Amazon FSx] console, *_click_* the link to the *MAZ* file system and *_select_* the *Network & security* tab. *_Copy_* the *Windows Remote PowerShell Endpoint* of the file system to the clipboard (e.g. amznfsx0123abcde.example.com).

. Return to your favorite text editor and replace *"windows_remote_powershell_endpoint"* with the *Windows Remote PowerShell Endpoint* of *MAZ*. *_Copy_* the updated script.

. Go to the remote desktop session for your *FSx/W Workshop Windows Instance*.

. *_Click_* *Start* >> *Windows PowerShell*.

. *_Run_* the updated script in the *Windows PowerShell* window.

+
NOTE: Complete the next few steps using the remote PowerShell session to the FSx file server.
+

. Review the PowerShell function commands for data deduplication available using the *Amazon FSx CLI for remote management on PowerShell*.
* *_Run_* the command in the *Remote Windows PowerShell Session*.

+
[source,bash]
----
Get-Command *-FSxDedup*
----
+

. What commands are available?

. Enable data depduplication for the entire FSx file system.
* *_Run_* the command in the *Remote Windows PowerShell Session*.

+
[source,bash]
----
Enable-FSxDedup
----
+

. Examine your data deduplication environment using the commands in the table below.

+
|===
| *Command*
| Get-FSxDedupConfiguration

| Get-FSxDedupStatus

| Get-FSxDedupMetadata

| Get-FSxDedupSchedule

| Measure-FSxDedupFileMetadata -path "D:\share"

|===
+

* When is the next scheduled "Optimization" task?


=== Create new data deduplication optimization schedule

IMPORTANT: Read through all steps below and watch the quick video before continuing.

image::new-data-dedup-schedule.gif[align="left", width=600]

. Create a new data deduplication optimization schedule.

* *_Run_* the command in the *Remote Windows PowerShell Session*.

+
[source,bash]
----
New-FSxDedupSchedule
----
+

* Use the table values when prompted.

+
|===
| *Prompt* | *Value*
| Name
| DailyOptimization

| Type
| Optimization

|===
+

. What time will the optimization start?

. Examine the different options available to data deduplication jobs.
* *_Run_* the command in the *Remote Windows PowerShell Session*.

+
[source,bash]
----
Set-FSxDedupSchedule -?
----
+

. *_Copy_* the command below into your favorite text editor and update the *start_time* parameter with the current time plus 2 minutes. Look at the clock in bottom right corner of the remote desktop window. Add 2 minutes to this time and replace the *start_time* parameter with this value. (i.e. 5:32pm). This time is in UTC.

+
[source,bash]
----
Set-FSxDedupSchedule -Name DailyOptimization -Start start_time
----
+

* Run the updated command in the *Windows PowerShell* window.

* Wait for the time of the DailyOptimization scheduled job to pass (i.e. 1 minute after the start_time you entered above) and run the command below (Get-FSxDedupStatus) to check the status. Run the command a few more times over to next 5 minutes to periodically check on the status.

* Are some of the FSxDedupStatus values changing?

+
[source,bash]
----
Get-FSxDedupStatus
----
+

. How many files were optimized and how much space is saved?

* Find the corresponding Get-FSxDedupStatus output for the command attributes in the table below

+
|===
| *Attribute*
| LastOptimizationResult

| OptimizedFilesCount

| OptimizedFilesSavingsRate

| OptimizedFilesSize

| SavedSpace
|===

. Continue and wait until the optimization job completes (approx. 8-10 minutes), periodically executing the *Get-FSxDedupStatus* command. Job completion will be indicated by the *LastOptimizationResultMessage* value changing to *The operation completed successfully*.

== Next section

Click the button below to go to the next section.

image::enable-shadow-copies.png[link=../11-enable-shadow-copies/, align="left",width=420]




