mark
mark

Reputation: 57

Taking backup of a file in remote location using ansible

I am trying to copy a file (example: /home/abc.jar) from controller machine(source system) to remote server. but before copying that file, I want to take the backup of the already existed file (/home/abc.jar) on the remote server to some directory (example /home/bck/abc.jar). then copy the new file ,

How can I write the playbook for this using ansible? Thank you :)

Upvotes: 2

Views: 6547

Answers (1)

clockworknet
clockworknet

Reputation: 3056

The docs are your friend:

Ansible Copy Module

Ansible Template Module

Both contain a 'backup' parameter which will automatically take a backup of a file prior to making changes.

Upvotes: 4

Related Questions