aws-cli icon indicating copy to clipboard operation
aws-cli copied to clipboard

s3 sync --delete not deleting empty folders

Open jardakotesovec opened this issue 7 years ago • 74 comments

Follow up to #2533

We are using aws-cli on OS X to sync bucket to local folder. So if there is file within folder, it gets synced properly. Issue is when file gets deleted - empty folder locally remains, which overtime can result in many empty folders.

aws s3 sync --delete s3://bucket/folder .

jardakotesovec avatar Jun 28 '17 15:06 jardakotesovec

Marking as a feature request.

stealthycoin avatar Jun 28 '17 16:06 stealthycoin

+1

robertd avatar Sep 03 '17 13:09 robertd

+1

jeffbildz avatar Oct 05 '17 16:10 jeffbildz

+1

cyuste avatar Oct 14 '17 11:10 cyuste

+1

paulmaunders avatar Nov 02 '17 10:11 paulmaunders

I'm also experiencing this running the AWS command on CentOS.

We have an S3 bucket which contains daily db backups. We are using S3 lifecycle management on the bucket to expire each daily backup folder after 7 days.

We then have a CentOS server on GCP which is periodically syncing the bucket using the following command...

aws s3 sync s3://bucket-name /backups/s3/bucket-name --delete

The individual db backup files are being deleted, but the daily folders remain...

# du -h --max-depth=1
0       ./2017-10-10_2300
0       ./2017-10-11_2300
0       ./2017-10-12_2300
0       ./2017-10-13_2300
0       ./2017-10-14_2300
0       ./2017-10-15_2300
0       ./2017-10-16_2300
0       ./2017-10-17_2300
0       ./2017-10-18_2300
0       ./2017-10-19_2300
0       ./2017-10-20_2300
0       ./2017-10-21_2300
0       ./2017-10-22_2300
0       ./2017-10-23_2300
0       ./2017-10-24_2300
0       ./2017-10-25_2300
5.6G    ./2017-10-26_2300
5.6G    ./2017-10-27_2300
5.6G    ./2017-10-28_2300
5.6G    ./2017-10-29_2300
5.6G    ./2017-10-30_2300
5.6G    ./2017-10-31_2300
5.5G    ./2017-11-01_2300
39G     .

These folders no longer exist on S3....

[root@backups ~]# aws s3 ls bucket-name/mysql-backups/
                           PRE 2017-10-26_2300/
                           PRE 2017-10-27_2300/
                           PRE 2017-10-28_2300/
                           PRE 2017-10-29_2300/
                           PRE 2017-10-30_2300/
                           PRE 2017-10-31_2300/
                           PRE 2017-11-01_2300/

I would expect sync --delete to delete the folders too.

paulmaunders avatar Nov 02 '17 10:11 paulmaunders

+1

CameronGo avatar Nov 03 '17 19:11 CameronGo

+1

cbarensfeld avatar Nov 09 '17 19:11 cbarensfeld

+1

rrybalkin avatar Nov 16 '17 13:11 rrybalkin

+1

jusaho avatar Jan 16 '18 09:01 jusaho

+1

ntman4real avatar Jan 22 '18 20:01 ntman4real

Good Morning!

We're closing this issue here on GitHub, as part of our migration to UserVoice for feature requests involving the AWS CLI.

This will let us get the most important features to you, by making it easier to search for and show support for the features you care the most about, without diluting the conversation with bug reports.

As a quick UserVoice primer (if not already familiar): after an idea is posted, people can vote on the ideas, and the product team will be responding directly to the most popular suggestions.

We’ve imported existing feature requests from GitHub - Search for this issue there!

And don't worry, this issue will still exist on GitHub for posterity's sake. As it’s a text-only import of the original post into UserVoice, we’ll still be keeping in mind the comments and discussion that already exist here on the GitHub issue.

GitHub will remain the channel for reporting bugs.

Once again, this issue can now be found by searching for the title on: https://aws.uservoice.com/forums/598381-aws-command-line-interface

-The AWS SDKs & Tools Team

This entry can specifically be found on UserVoice at: https://aws.uservoice.com/forums/598381-aws-command-line-interface/suggestions/33168367-s3-sync-delete-not-deleting-empty-folders

ASayre avatar Feb 06 '18 10:02 ASayre

Based on community feedback, we have decided to return feature requests to GitHub issues.

jamesls avatar Apr 06 '18 20:04 jamesls

+1

walljcg avatar May 02 '18 09:05 walljcg

+1

pmspire avatar May 23 '18 13:05 pmspire

+1

jkeller-miovision avatar Jun 05 '18 15:06 jkeller-miovision

+1

mikebrickwall avatar Jun 19 '18 18:06 mikebrickwall

+1

thugbeatz avatar Jun 20 '18 10:06 thugbeatz

+1

myheartsgoon avatar Jun 26 '18 06:06 myheartsgoon

+1

serhiireva avatar Aug 13 '18 10:08 serhiireva

+1 And as a quick note to anyone else looking for a quick workaround, the following will delete any empty folders as a cleanup step: find . -type d -empty -delete

kellenarb avatar Aug 22 '18 13:08 kellenarb

+1

trimeloni avatar Aug 29 '18 21:08 trimeloni

Definitely +1

gladwynb avatar Sep 18 '18 18:09 gladwynb

The reverse it true as well: aws s3 sync --delete . s3://bucket/folder When syncing from a local filesystem to S3, any folders that were deleted locally are NOT deleted from S3 as we would expect.

Feldhacker avatar Sep 27 '18 16:09 Feldhacker

+1

gentaro-sakamoto avatar Jan 31 '19 14:01 gentaro-sakamoto

I hope this feature request will be considered.

aws s3 sync --delete . s3://bucket

For the command above, it does not make sense to leave empty "folders" in s3 bucket if we're going to follow what the definition of aws sync means. Looking at the description of aws sync cli it says:

Syncs directories and S3 prefixes. Recursively copies new and updated files from the source directory to the destination. Only creates folders in the destination if they contain one or more files.

I think the inconsistency lies on what does this line really means "Syncs directories and S3 prefixes.". To me I would expect the folder in S3 to be deleted if no file in that folder exist on the local directory.

hhcordero avatar Mar 27 '19 03:03 hhcordero

It is quite ridiculous that this basic feature has not been implemented yet until this day. Especially for paying customers.

kecsap avatar May 06 '19 06:05 kecsap

It is quite ridiculous that this basic feature has not been implemented yet until this day. Especially for paying customers.

I couldn't agree more!

jolleye avatar May 21 '19 01:05 jolleye

+1

vitorbezerra avatar May 31 '19 17:05 vitorbezerra

I am encountering this bug as well. This is not a feature request. It is clearly a bug.

My situation:

  1. Delete local directory: dist/test/
  2. Run aws s3 sync dist s3://bucket-name/ --acl public-read --delete

Expected result:

  • Directory test should be deleted from the bucket

Observed result:

  • Directory test still exists in the bucket as an empty directory. Any files that it previously contained have been deleted.

adamnellis avatar Jul 24 '19 12:07 adamnellis