Ruby Fileutils.cp_r Permission Denied when :preserve => true

Posted by slawley on Stack Overflow See other posts from Stack Overflow or by slawley
Published on 2010-05-25T21:30:34Z Indexed on 2010/05/25 23:51 UTC
Read the original article Hit count: 318

Filed under:
|
|

Hello,

I am trying to implement a poor-man's backup/mirroring script and am having some trouble.

I am on Windows-XP, using Ruby's FileUtils module to recursively copy files.

So long as I don't set the :preserve flag to true, everything works fine.

Works:

FileUtils.cp_r('Source_dir', 'Dest_dir', :verbose => true)

Doesn't work:

FileUtils.cp_r('Source_dir', 'Dest_dir', :verbose => true, :preserve => true)

I have full permissions on the Dest_dir as it's on the desktop of my local machine and I just created it. I can copy and delete files and folders, but apparently changing, or maintaining the file attributes with :preserve isn't working. I haven't had a chance to try this on a Mac or linux box, but from reading around online the :preserve flag is a normal stumbling block to come up against in a Windows environment.

In a similar line of questioning, what is the default behavior for FileUtils.cp_r when it encounters an existing file at the destination directory? Simply overwrite and replace everything in Destination with whatever is in Source, or can I skip a file with conflicts and just log it for resolution later? (If this should be a separate question, just let me know and I'll make it one.)

Thanks,

Spencer

© Stack Overflow or respective owner

Related posts about Windows

Related posts about ruby