Automate Backup Of Files From Windows To S3 Bucket
In this guide , We will learn how to automatically backup files from the Windows Server to the S3 Bucket.
We going to automate a process using task scheduler to run the program everyday at 5 PM , The task is to sync all the files from a Folder in the Windows Server to S3 bucket using aws cli.
Using this tutorial , You can Manage S3 Buckets and Objects from aws cli
PreRequisites
The Windows operating system should have AWS CLI installed.
What Is Task Scheduler?
Task scheduler is used to Create , manage and to automate the tasks that the system wants to perform.
Lets go ahead and create a task using task scheduler and assign a program to it.
Creating Tasks Using Task Scheduler
To create a Basic tasks , Login to the Windows EC2 Instance and type Schedule tasks in the Search box.
Clicking that , Will open a New Window which is known as Task Scheduler.
In the Right Hand side , You will see the lists of Actions available , Such as Creating tasks , Importing tasks , Disabling task history , To display all running tasks.
Lets us first understand the usage of task scheduler.
Task scheduler is used to Create , manage and to automate the tasks that the system wants to perform.
You can view the lists of available tasks configured , By clicking Task Scheduler Library in the left pane.
There we can get the detailed information about each tasks , We can modify the tasks at any time as per the requirements.
To Create a new task , On the right side , Under Actions , Choose Create Basic Task
You will be asked to provide a name for the task.
Click Next , Here We have to mention , How often you want the task to be triggered or executed. For instance , Daily
You are provided with various triggers such as weekly , monthly , One time , When log on , When computer starts , Or when specific event is logged.
Click Next , Depending on the trigger you have chosen , You will be asked to provides the details such as Start Time , Recur every , etc.
I have configured the task scheduler to execute the task everyday at 11:55 PM.
Click Next
You should mention the action to be performed , Choose Start a program
Choose Next , And here you should provide a tasks in the form of program / script to the task scheduler.
To Create a script , Go to any folder in the Windows instance ,
Right Click , Click New , Text Document
Give a name for the file and the extension for the file should be .bat (which is known as batch file) , For example , test.bat
Which changing the extension of the file , It will ask for the confirmation , Click Yes
To add commands to the .bat file , Select & Right click the file , Choose Edit
It will open the file and You can add the commands here.
For this tutorial , As I said earlier , I am going to sync all the files from the folder in the Windows Server to S3 Bucket.
Here is the command I have used to sync the files to S3 bucket.
aws s3 sync C:\folder\. s3://bucket-name/
You should pass the exact values of folder and the bucket name.
After you have added the command , Save and close the file.
Now , Go back to the Task Scheduler
Click Browse , Choose the .bat file you have created.
Click Next , You will the get the summary of the task configured.
and Click Finish.
If you want to run and check the tasks , Choose Task Scheduler Library , Select the task you have created.
In the right side , You will get the Run option , It will start the task. This is the manual way of starting the task in the Task Scheduler.
To check the history of the task , By click History

At any point , If you want to change the properties of the task , Select the task , Right click and Choose properties.
If you want to modify Triggers , Select and Click Edit and make changes as required.
Or If you want to change the batch file itself , You can change it under Actions.
Conclusion
We have learnt how to automate backup of files from the Windows Servers to S3 bucket.
Hope you found it helpful , Thanks for reading this article.
Please do check out my other publications.