I'm trying to write a simple backup script in Ruby that copies a folder to a specific directory with a timestamp in its name. My code is (simplified):
require 'Fileutils.rb'
time = Time.now
FileUtils.cp_r "C:/somefolder", "D:/somefolder_backup_#{time}"
But I keep getting
`fu_mkdir': Unknown error - mkdir failed (SystemCallError)
The same happens if I simply want to create a folder with the current time in it:
FileUtils.mkdir "C:/somefolder_#{time}"
It doesn't seem to be a privileges issue, if I leave out the #{time}-thing it works perfectly.
Any advices are appreciated.
My guess is that there is a character in your time string that Windows doesn't allow in a directory name (your code works fine for me on my Ubuntu machine). Try formatting your time so that it's just numeric, and that'll probably work:
require 'Fileutils.rb'
time = Time.now.strftime("%Y%m%d%H%M%S")
FileUtils.cp_r "C:/somefolder", "D:/somefolder_backup_#{time}"