In this tutorial, we will learn how to enable Amazon S3 automatic backup process on Windows Server. If you enable this feature, Amazon S3 will run a backup at every interval. You can specify the interval to daily or weekly or monthly. The first step of automating the backup system is by installing the Amazon AWS CLI. After installation is accomplished, you configure the default user profiles, access ID, and key.
Install Amazon AWS CLI
To install the Amazon AWS CLI, you have to refer the Amazon AWS page. In this page, you will know about the official AWS CLI docker image, and how to install, update, uninstall Amazon AWS CLI for Windows, macOS and Linux.
Configure Default User Profiles, Access ID, Key
Your next step is to configure the default user profiles, Access ID, and key. To do this, run the command as given below:
aws configure AWS Access Key ID [None]: <AccessID> AWS Secret Access Key [None]: secretkey Default region name [None]: us-east-1 Default output format [None]: json
Specify A Path Argument In S3 Commands
It is very important, that you specify a path argument in S3. You can accomplish by using either an S3 Uri, (Your S3 bucket’s URI) or use a localpath (the local directory, which is often the C drive).
localpath - C://Desktop/backups S3URI: - s3://yourbucket/yourkey
The complete S3 operation will look like this:
aws s3 s3command souce_file/folder destinationpath
The operation can move from localpath to 3URI, S3URI to S3URI, and S3URI to localpath.
Copying A File To Your Bucket
Let’s name the file as sample.txt, you can copy it to your bucket (let us name it samplebucket) by using the following command. Here, remember that if you have already configured the region in aws configure
aws s3 cp "C://Desktop/backups/sample.txt" s3://samplebucket
Backup All Data In Your Bucket
For the command to backup everything to your required bucket, the local file should not exist in the target bucket and prefix. Also, make sure the size of the S3 object is not same as that of the local file. Another very important point to note is that the recent modification of the S3 object must be older than the local file.
If you want to synchronize or backup all data in your bucket, named here, samplebucket , then use the following command.
aws s3 sync "C://Desktop/backups/" s3://sample-bucket