Scheduling when your Amazon DataSync task runs - Amazon DataSync
Services or capabilities described in Amazon Web Services documentation might vary by Region. To see the differences applicable to the China Regions, see Getting Started with Amazon Web Services in China (PDF).

Scheduling when your Amazon DataSync task runs

You can set up an Amazon DataSync task schedule to periodically transfer data between storage locations.

A scheduled task runs at a frequency that you specify, with a minimum interval of 1 hour. For example, your task could run every Sunday and Wednesday at 12:00 PM UTC. Here's how you'd configure this schedule with a cron expression:

0 12 ? * SUN,WED *
Important

You can't use a cron expression for scheduling a task to run at an interval faster than 1 hour.

For information about cron expression syntax, see the Amazon EventBridge User Guide.

Creating a DataSync task schedule

You can schedule how frequently your task runs by using the DataSync console, Amazon CLI, or DataSync API.

The following instructions describe how to set up a schedule when creating a task. You can modify the schedule later when editing the task.

  1. Open the Amazon DataSync console at https://console.amazonaws.cn/datasync/.

  2. In the left navigation pane, expand Data transfer, then choose Tasks, and then choose Create task.

  3. Configure your task's source and destination locations.

    For more information, see Where can I transfer my data with Amazon DataSync?

  4. For schedule Frequency, do one of the following:

    • Choose Not scheduled if you don't want to schedule your task to run periodically.

    • Choose Hourly and choose the minute in the hour that the task should run. The task runs every hour on the specified minute.

    • Choose Daily and enter the UTC time that you want the task to run in the format HH:MM. This task runs every day at the specified time.

    • Choose Weekly and the day of the week and enter the UTC time the task should run in the format HH:MM. This task runs every week on the specified day at the specified time.

    • Choose Days of the week, choose the specific day or days, and enter the UTC time that the task should run in the format HH:MM. This task runs on the days and the time that you specified.

    • Choose Custom if you want to use a custom cron expression to run your task, with a minimum interval of 1 hour. Then enter your expression in the Cron expression box.

You can create a schedule for your DataSync task by using the --schedule parameter with the create-task, update-task, or start-task-execution command.

The following instructions describe how to do this with the create-task command.

  1. Copy the following create-task command:

    aws datasync create-task \ --source-location-arn arn:aws:datasync:us-east-1:123456789012:location/loc-12345678abcdefgh \ --destination-location-arn arn:aws:datasync:us-east-1:123456789012:location/loc-abcdefgh12345678 \ --schedule '{ "ScheduleExpression": "cron(0 12 ? * SUN,WED *)" }'
  2. For the --source-location-arn parameter, specify the Amazon Resource Name (ARN) of the location that you're transferring data from.

  3. For the --destination-location-arn parameter, specify the ARN of the location that you're transferring data to.

  4. For the --schedule parameter, specify a cron expression for your schedule.

    In the example, the expression cron(0 12 ? * SUN,WED *) sets a task schedule that runs every Sunday and Wednesday at 12:00 PM UTC.

  5. Run the create-task command to create your task with the schedule.

Pausing a DataSync task schedule

There can be situations where you need to pause your DataSync task schedule. For example, you might need to temporarily disable a recurring transfer to fix an issue with your task or perform maintenance on your storage system.

DataSync might disable your schedule automatically if your task fails repeatedly with the same error.

  1. Open the Amazon DataSync console at https://console.amazonaws.cn/datasync/.

  2. In the left navigation pane, expand Data transfer, and then choose Tasks.

  3. Choose the task that you want to pause the schedule for, and then choose Edit.

  4. For Schedule, turn off Enable schedule. Choose Save changes.

  1. Copy the following update-task command:

    aws datasync update-task \ --task-arn arn:aws:datasync:us-east-1:123456789012:task/task-12345678abcdefgh \ --schedule '{ "ScheduleExpression": "cron(0 12 ? * SUN,WED *)", "Status": "DISABLED" }'
  2. For the --task-arn parameter, specify the ARN of the task that you want to pause the schedule for.

  3. For the --schedule parameter, do the following:

    • For ScheduleExpression, specify a cron expression for your schedule.

      In the example, the expression cron(0 12 ? * SUN,WED *) sets a task schedule that runs every Sunday and Wednesday at 12:00 PM UTC.

    • For Status, specify DISABLED to pause the task schedule.

  4. Run the update-task command.

  5. To resume the schedule, run the same update-task command with Status set to ENABLED.

Checking the status of a DataSync task schedule

You can see whether your DataSync task schedule is enabled.

  1. Open the Amazon DataSync console at https://console.amazonaws.cn/datasync/.

  2. In the left navigation pane, expand Data transfer, and then choose Tasks.

  3. In the Schedule column, check whether the task's schedule is enabled or disabled.

  1. Copy the following describe-task command:

    aws datasync describe-task \ --task-arn arn:aws:datasync:us-east-1:123456789012:task/task-12345678abcdefgh
  2. For the --task-arn parameter, specify the ARN of the task that you want information about.

  3. Run the describe-task command.

You get a response that provides details about your task, including its schedule. (The following example focuses primarily on the task schedule configuration and doesn't show a full describe-task response.)

The example shows that the task's schedule is manually disabled. If the schedule is disabled by the DataSync SERVICE, you see an error message for DisabledReason to help you understand why the task keeps failing. For more information, see Troubleshooting issues with Amazon DataSync transfers.

{ "TaskArn": "arn:aws:datasync:us-east-1:123456789012:task/task-12345678abcdefgh", "Status": "AVAILABLE", "Schedule": { "ScheduleExpression": "cron(0 12 ? * SUN,WED *)", "Status": "DISABLED", "StatusUpdateTime": 1697736000, "DisabledBy": "USER", "DisabledReason": "Manually disabled by user." }, ... }