AWS CLI Sync command from local machine to AWS S3 Storage

Example of AWS CLI sync command with AWS S3 Storage

AWS CLI to use the sync process of local folder to AWS S3 storage.

C:\hello>dir
 Volume in drive C is Windows
 Volume Serial Number is 7804-EB2C

 Directory of C:\hello

09-03-2023  10:09    <DIR>          .
07-03-2023  22:18                 3 1.txt
09-03-2023  10:09                 7 2.txt
               2 File(s)             10 bytes
               1 Dir(s)  74,147,778,560 bytes free

C:\hello>aws s3 sync . s3://testbackupsqlserver2023/
upload: .\2.txt to s3://testbackupsqlserver2023/2.txt
upload: .\1.txt to s3://testbackupsqlserver2023/1.txt

Note:

First Case: On move/rename the 2.txt to 3.txt It will not remove the 2.txt file on S3 storage. It will only upload the renamed file to S3 storage but keep old one as it is.

C:\hello>move 2.txt 3.txt
        1 file(s) moved.

C:\hello>aws s3 sync . s3://testbackupsqlserver2023/
upload: .\3.txt to s3://testbackupsqlserver2023/3.txt

C:\hello>aws s3 ls s3://testbackupsqlserver2023/
2023-03-09 10:16:36          6 1.txt
2023-03-09 10:11:26          7 2.txt
2023-03-09 10:12:01          7 3.txt

Second case: If i updated the existing file then sync command will update the S3 storage also with updated file.

C:\hello>notepad 1.txt

C:\hello>aws s3 sync . s3://testbackupsqlserver2023/
upload: .\1.txt to s3://testbackupsqlserver2023/1.txt

Third Case: If i delete file from the folder at local machine but sync command does not delete at s3 storage:

C:\hello>del 3.txt

C:\hello>dir
 Volume in drive C is Windows
 Volume Serial Number is 7804-EB2C

 Directory of C:\hello

09-03-2023  10:21    <DIR>          .
09-03-2023  10:16                 6 1.txt
               1 File(s)              6 bytes
               1 Dir(s)  74,169,737,216 bytes free

C:\hello>aws s3 sync . s3://testbackupsqlserver2023/

C:\hello>aws s3 ls s3://testbackupsqlserver2023/
2023-03-09 10:16:36          6 1.txt
2023-03-09 10:11:26          7 2.txt
2023-03-09 10:12:01          7 3.txt
Advertisement

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.