3.14 Example Scripts Using CLI Commands

This section provides example scripts for Dynamic File Services.

3.14.1 Creating a Pair and Policy

This example uses the Dynamic File Services CLI to set up one pair named myPair with a primary path of e:\Primary and a secondary path of f:\Secondary. It creates three policies and associates them to the pair:

  • The GRAPHICS policy moves graphic files to the secondary path. It is scheduled to run daily at midnight.

  • The OLD FILES policy moves files that have not been modified within two weeks to the secondary path. It is scheduled to run weekly on Saturday at midnight.

  • The MODIFIED FILES policy moves files modified during the past day from the secondary to the primary. It is scheduled to run hourly.

ECHO Create Dynamic File Services Setup of one pair and three policies

ECHO Create the pair named myPair

DswCli.exe -pair -add -name=myPair -primaryPath=e:\Primary 
-secondaryPath=f:\Secondary -description="Pair linking user home directories and old storage" -serverName=192.168.1.3 -port=8999 -userName=Administrator 
-password=myPassword

ECHO Create the policy named GRAPHICS to secondary

DswCli.exe -policy -add -name="GRAPHICS to secondary" -fileExtension=JPG,JPEG,BMP,GIF,PNG,RAW -daily="00:00" -primaryToSecondary 
-description="Moves all graphic files to secondary storage. Runs daily at midnight." -serverName=192.168.1.3 -port=8999 -userName=Administrator 
-password=myPassword

ECHO Associate the policy to myPair

DswCli.exe -associate -policyId="GRAPHICS to secondary" -pairId=myPair 
-serverName=192.168.1.3 -port=8999 -userName=Administrator 
-password=myPassword

ECHO Create the policy named OLD FILES to secondary

DswCli.exe -policy -add -name="OLD FILES to secondary" -lastModified="gt2w" 
-primaryToSecondary -description="Moves files that have not been modified for over two weeks to secondary. Runs weekly on Saturday morning at midnight" -weekly="05@00:00" -serverName=192.168.1.3 
-port=8999 -userName=Administrator -password=myPassword

ECHO Associate the policy to myPair

DswCli.exe -associate -policyId="OLD FILES to secondary" -pairId=myPair 
-serverName=192.168.1.3 -port=8999 -userName=Administrator 
-password=myPassword

ECHO Create the policy named MODIFIED FILES to primary

DswCli.exe -policy -add -name="MODIFIED FILES to primary" -lastModified="lt1d" -primaryToSecondary -description="Moves files that were modified within the last day to the primary. Runs hourly every day." -hourly 
-serverName=192.168.1.3 -port=8999 -userName=Administrator 
-password=myPassword

ECHO Associate the policy to myPair

DswCli.exe -associate -policyId="MODIFED FILES to primary" -pairId=myPair 
-serverName=192.168.1.3 -port=8999 -userName=Administrator 
-password=myPassword

3.14.2 Running the Policies Manually

The following command uses a Dynamic File Services CLI command to run the three policies manually for the pair named myPair:

ECHO Manually run all policies

DswCli.exe -execute -policyIdList="GRAPHICS FILES to secondary","MODIFIED FILES to primary","OLD FILES to secondary" -pairId=myPair -serverName=192.168.1.3 
-port=8999 -userName=Administrator -password=myPassword

3.14.3 Deleting the Policies

The following example uses the Dynamic File Services CLI to delete the three policies. The policies’ associations to the pair are also deleted.

ECHO Delete the policies

DswCli.exe -policy -delete -policyId="GRAPHICS to secondary" 
-serverName=192.168.1.3 -port=8999 -userName=Administrator 
-password=myPassword

DswCli.exe -policy -delete -policyId="OLD FILES to secondary" 
-serverName=192.168.1.3 -port=8999 -userName=Administrator 
-password=myPassword

DswCli.exe -policy -delete -policyId="MODIFIED FILES to primary" 
-serverName=192.168.1.3 -port=8999 -userName=Administrator 
-password=myPassword

3.14.4 Deleting the Pair Relationship

The following example uses the Dynamic File Services CLI to delete the link between the primary path and secondary path. No files are deleted.

DswCli.exe -pair -delete -pairId="myPair" -serverName=192.168.1.3 
-port=8999 -userName=Administrator -password=myPassword