Advertisement
ZX_CV

backup.yaml

Apr 28th, 2024
849
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
YAML 0.84 KB | None | 0 0
  1. backup.yaml
  2.  
  3. ---
  4. - name: Backup Mikrotik Devices
  5.   hosts: routers
  6.   connection: paramiko
  7.   gather_facts: no
  8.   tasks:
  9.     - name: Set current time
  10.       set_fact:
  11.         time: "{{ lookup('pipe','date \"+%Y-%m-%d-%H-%M\"') }}"
  12.  
  13.     - name: Starting ROS System Backup filename .backup
  14.       community.routeros.command:
  15.         commands: "/system backup save name {{ inventory_hostname }}"
  16.  
  17.     - name: Starting ROS Configuration Backup filename .rsc
  18.       community.routeros.command:
  19.         commands: "/export file={{ inventory_hostname }}"
  20.  
  21.     - name: Download backup files from the network device using SFTP
  22.       ansible.netcommon.net_get:
  23.         src: "{{ item }}"
  24.         dest: "/etc/ansible/backup/{{ item }}"
  25.         protocol: sftp
  26.       loop:
  27.        - "{{ inventory_hostname }}.backup"
  28.         - "{{ inventory_hostname }}.rsc"
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement