infra/roles/backup/tasks/main.yml
jack 634d50c25d
All checks were successful
CI/CD / syntax-check (push) Successful in 1m10s
CI/CD / deploy (push) Successful in 15m50s
chore(backup): change schedule from hourly to every 6 hours
Runs at 00:00, 06:00, 12:00, 18:00. Removes old hourly cron entry.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-03-23 15:30:55 +07:00

48 lines
1.3 KiB
YAML

---
- name: Install awscli (download static binary — works on Ubuntu 24.04)
ansible.builtin.shell: |
set -e
ARCH=$(uname -m)
if [ "$ARCH" = "x86_64" ]; then
URL="https://awscli.amazonaws.com/awscli-exe-linux-x86_64.zip"
else
URL="https://awscli.amazonaws.com/awscli-exe-linux-aarch64.zip"
fi
cd /tmp
curl -fsSL "$URL" -o awscliv2.zip
unzip -q -o awscliv2.zip
./aws/install --update -i /usr/local/aws-cli -b /usr/local/bin
rm -rf awscliv2.zip aws/
args:
creates: /usr/local/bin/aws
- name: Create backup directory
ansible.builtin.file:
path: "{{ backup_dir }}"
state: directory
owner: "{{ backup_user }}"
group: "{{ backup_user }}"
mode: "0750"
- name: Deploy backup script
ansible.builtin.template:
src: backup.sh.j2
dest: /usr/local/bin/backup-services
owner: root
group: root
mode: "0750"
- name: Remove old hourly backup cron (replaced by 6-hour schedule)
ansible.builtin.cron:
name: "Hourly services backup"
state: absent
user: root
- name: Schedule backup every 6 hours
ansible.builtin.cron:
name: "Services backup every 6 hours"
minute: "0"
hour: "0,6,12,18"
job: "/usr/local/bin/backup-services >> /var/log/backup-services.log 2>&1"
user: root
state: present