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.
Open the Amazon DataSync console at https://console.amazonaws.cn/datasync/
. In the left navigation pane, expand Data transfer, then choose Tasks, and then choose Create task.
-
Configure your task's source and destination locations.
For more information, see Where can I transfer my data with Amazon DataSync?
-
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.
-
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 *)
" }' -
For the
--source-location-arn
parameter, specify the Amazon Resource Name (ARN) of the location that you're transferring data from. -
For the
--destination-location-arn
parameter, specify the ARN of the location that you're transferring data to. -
For the
--schedule
parameter, specify a cron expression for your schedule.In the example, the expression
sets a task schedule that runs every Sunday and Wednesday at 12:00 PM UTC.cron(0 12 ? * SUN,WED *)
-
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 task schedule automatically for the following reasons:
-
Your task fails repeatedly with the same error.
-
You disable an Amazon Web Services Region that your task is using.
Open the Amazon DataSync console at https://console.amazonaws.cn/datasync/
. -
In the left navigation pane, expand Data transfer, and then choose Tasks.
-
Choose the task that you want to pause the schedule for, and then choose Edit.
-
For Schedule, turn off Enable schedule. Choose Save changes.
-
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" }' -
For the
--task-arn
parameter, specify the ARN of the task that you want to pause the schedule for. -
For the
--schedule
parameter, do the following:-
For
ScheduleExpression
, specify a cron expression for your schedule.In the example, the expression
sets a task schedule that runs every Sunday and Wednesday at 12:00 PM UTC.cron(0 12 ? * SUN,WED *)
-
For
Status
, specifyDISABLED
to pause the task schedule.
-
-
Run the
update-task
command. -
To resume the schedule, run the same
update-task
command withStatus
set toENABLED
.
Checking the status of a DataSync task schedule
You can see whether your DataSync task schedule is enabled.
Open the Amazon DataSync console at https://console.amazonaws.cn/datasync/
. -
In the left navigation pane, expand Data transfer, and then choose Tasks.
-
In the Schedule column, check whether the task's schedule is enabled or disabled.
-
Copy the following
describe-task
command:aws datasync describe-task \ --task-arn arn:aws:datasync:
us-east-1
:123456789012
:task/task-12345678abcdefgh
-
For the
--task-arn
parameter, specify the ARN of the task that you want information about. -
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." }, ... }