First go to the chef cookbook location and create below directories
cd cookbooks
mkdir -p backupfolder/recipes
create the cookbook backupfolder.rb
execute 'Backup Directory' do
command 'tar -cvf /opt/sw/backup_$(date +"%Y%m%d%H%M%S%3N").tar /opt/sw/conf /opt/sw/apps'
action :run
end
the above code will take backup of conf folder and apps folder into a single tar file with datetime stamp.
To run the chef client we use the below command
chef-client -zr recipe[backupfolder::backupfolder]
No comments:
Post a Comment