Search

Friends

Atomspheric CO2 (PPM)

Archives

Blather

Uptime verified by Wormly.com

12 April 2012

s3cmd sync –follow-symlinks

I had trouble getting s3cmd to do Amazon S3 synchronisation with symlinked backup files. It seemed to be comparing the local link file with the destination file instead of comparing the file that is linked to. Probably this isn't what you want because the symlink size will never match the destination file size, so it will always upload the file.

For s3cmd version 1.0.1 I changed this on line 684 in the s3cmd file:

# sr = os.stat_result(os.lstat(full_name))
sr = os.stat_result(os.stat(full_name))

Swapping Python's os.lstat() (which doesn't follow symlinks) for os.stat() (which does follow them) means that it will compare the "correct" file sizes. This method is only used to calculate file size and modification time, so it should be OK. So far I haven't noticed other side effects, but we will see. My hope is that --follow-symlinks was added later, and they didn't think to change this line.

Note: I'm guessing this change will break (or at least complicate) using s3cmd when you don't want to follow symlinks.

Comments

No comments yet.

Leave a comment

Markdown

0.654 seconds