[SOLVED] Copy directory recursively

Sorry for the stupid question but i can't find resource for copy recursive files.
I want to copy files from /opt/source to /tmp/backup.
I tried remote_directory "#{node['backup']['analysis']}" do
source '/tmp/backup'
owner 'root'
group 'root'
mode '0755'
action :create
recursive true
But i've got error "Chef::Exceptions::FileNotFound
cookbook centos7 has no directory files/default//tmp
Please help.

The remote_directory resource is used to transfer a directory from a cookbook to a node. It will not recursively transfer file from one location on a node to another.

The usual way to do this is with a bash resource or a ruby block.

Here is a bash block example.

bash "backup source folder" do
code <<-EOL
mkdir /tmp/backup
cp -rp /opt/source /tmp/backup/


You can create the directory in the bash resource or use a chef resource to create the directory. The resource is idempotent whereas the bash command is not.

I thought it will be much more easy with a resource for copying multiple files.
Now I know there is no such thing...
Thanks for your help!

you could use the execute resource