# Nightly backup of UAC definitions with the UC Compose extension. # Exports the objects to readable .uac.yaml files on an agent, one file per # area, then keeps the last 14 days. Needs the "UC Compose" Universal Extension. # # Before import: change the agent (linux-agent), the controller URL and the # credential (Controller API), and the backup folder (/backup/uac). version: 1 style: compact variables: uac_backup_dir: {value: /backup/uac, description: Where the nightly bundles go} tasks: BACKUP Export Tasks: type: Universal template: UC Compose agent: linux-agent summary: All tasks as one readable bundle. action: Export uc_url: https://your-controller.example.com uc_credentials: Controller API names: '*' object_type: task style: compact output_file: ${uac_backup_dir}/${_date('yyyy-MM-dd')}/tasks.uac.yaml BACKUP Export Triggers: type: Universal template: UC Compose agent: linux-agent summary: All triggers as one readable bundle. action: Export uc_url: https://your-controller.example.com uc_credentials: Controller API names: '*' object_type: trigger style: compact output_file: ${uac_backup_dir}/${_date('yyyy-MM-dd')}/triggers.uac.yaml BACKUP Export Calendars: type: Universal template: UC Compose agent: linux-agent summary: Calendars and custom days. action: Export uc_url: https://your-controller.example.com uc_credentials: Controller API names: '*' object_type: calendar style: compact output_file: ${uac_backup_dir}/${_date('yyyy-MM-dd')}/calendars.uac.yaml BACKUP Clean Old Files: type: Unix agent: linux-agent command: find "${uac_backup_dir}" -mindepth 1 -maxdepth 1 -type d -mtime +14 -print -exec rm -rf {} + BACKUP Notify Failure: type: Unix agent: linux-agent command: logger -t uac-backup "UAC nightly backup failed; check ${ops_task_name}" BACKUP Nightly: type: Workflow summary: Export tasks, triggers and calendars, then remove backups older than 14 days. tasks: BACKUP Export Tasks: BACKUP Export Triggers: BACKUP Export Calendars: BACKUP Clean Old Files: after: [BACKUP Export Tasks, BACKUP Export Triggers, BACKUP Export Calendars] BACKUP Notify Failure: after: [{BACKUP Export Tasks: failure}, {BACKUP Export Triggers: failure}, {BACKUP Export Calendars: failure}] condition: any triggers: BACKUP Every Night: type: Cron tasks: [BACKUP Nightly] minutes: '30' hours: '1' dayOfMonth: '*' month: '*' dayOfWeek: '*'