Learn how easy it is to sync an existing GitHub or Google Code repo to a SourceForge project! See Demo


Managing files by date... (removing old)

  • Pat Niemeyer
    Pat Niemeyer


    I am using s3cmd in a simple nightly backup and I'd like to find an easy way to insure that I don't keep more than N archives on S3.  I see that when I list the bucket they currently appear in date order and I could script something against that.  However it makes me nervous since I see no guarantee that that order will be maintained.

    I realize that I could use the sync strategy and more easily maintain the files by date locally (e.g. find -mtime +) but I'd prefer to stay a bit more hands-off.

    So, my questions are:

    1) Is the ordering of files by date in the listing guaranteed to stay that way?

    2) If not #1, could we get an ls -t option or equivalent?

    3) Is there some trivial way I can list files on S3 older than a certain date?

    4) Should I shut up about this and submit code for this myself? :)


    • Michal Ludvig
      Michal Ludvig

      Hi Pat,

      1) Bucket listing is ordered by file names. If your file names include timestamp the listing will be also ordered by date, but that's just a side effect.

      2) Quite possibly. Or better something like --sort-by={name,date,size}

      3) Nope.

      4) Please :-) Since this is nowhere near the top of my priority list you'd have to wait a while before it gets implemented.

      On the other hand - why don't you simply parse the 's3cmd ls' output to find out the filenames that are older than a given timestamp? Parsing a date into, say, unix timestamp is trivial. Let me know if you need any help with that.