Reputation: 761
I'm wondering if there's a resource out there to make a copy of a whole directory. I know I could always use a bash resource and just do a 'cp', but I was wondering if there's an analog to the 'file' resource for directories.
bash resource solution
bash "backup org folder" do
code <<-EOL
mkdir /opt/tmp/copy
mv /opt/tmp/org/* /opt/tmp/copy
EOL
end
I found this: How to move/copy files locally with Chef But is 2 years old so I'm wondering if there's any new resource for this case.
Thanks.
Upvotes: 0
Views: 679
Reputation: 761
The only way I found to do this is using the bash resource but there are a few things you need to be careful with.
bash "backup testDir directory" do
user "jhon"
cwd "/opt/lnp"
environment ({'HOME' => '/home/jhon', 'USER' => 'jhon'})
code <<-EOL
{
mv /opt/lnp/testDir/* /opt/lnp/testDir.#{TODAY}
}
EOL
not_if { Dir['/opt/lnp/testDir/*'].empty? }
end
Upvotes: 0
Reputation: 84
No other way as per my knowledge. Either you have to use a bash resource as you have done or through a Ruby block
Upvotes: 1