Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Some fixes to backup scripts and staging configuration for daily backups #982

Merged
merged 3 commits into from
Apr 29, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion infrastructure/server-setup/backups.yml
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@

- name: Copy rotate_backups.sh file to external_backup_server_user's home directory
copy:
src: infrastructure/backups/rotate_backups.sh
src: ../backups/rotate_backups.sh
dest: '{{ external_backup_server_user_home }}/rotate_backups.sh'
owner: '{{ external_backup_server_user }}'
mode: 0755
Expand All @@ -155,3 +155,5 @@
hour: '0'
job: 'bash {{ external_backup_server_user_home }}/rotate_backups.sh --backup_dir={{ external_backup_server_remote_directory }} --amount_to_keep={{ amount_of_backups_to_keep }} >> /var/log/opencrvs-rotate-backups.log 2>&1'
state: "{{ 'present' if (amount_of_backups_to_keep) else 'absent' }}"
tags:
- backups
1 change: 0 additions & 1 deletion infrastructure/server-setup/group_vars/all.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,5 +10,4 @@ ansible_python_interpreter: /usr/bin/python3
encrypt_data: False
swap_file_path: /swapfile
swap_file_size_mb: 8000
external_backup_server_remote_directory: /home/backup/backups
external_backup_server_user: 'backup'
5 changes: 2 additions & 3 deletions infrastructure/server-setup/production.yml
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,5 @@ backups:
hosts:
farajaland-qa:
ansible_host: '165.22.110.53'
vars:
# @todo how many days to store backups for?
amount_of_backups_to_keep: 3
# @todo how many days to store backups for?
amount_of_backups_to_keep: 3
5 changes: 2 additions & 3 deletions infrastructure/server-setup/staging.yml
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,5 @@ backups:
hosts:
farajaland-qa:
ansible_host: '165.22.110.53'
vars:
# @todo how many days to store backups for?
amount_of_backups_to_keep: 3
# @todo how many days to store backups for?
amount_of_backups_to_keep: 3
9 changes: 8 additions & 1 deletion infrastructure/server-setup/tasks/backups/crontab.yml
Original file line number Diff line number Diff line change
@@ -1,10 +1,17 @@
- name: Copy backups.sh file to external_backup_server_user's home directory
copy:
src: ../backups/backup.sh
dest: '{{ crontab_user_home }}/backup.sh'
owner: 'root'
mode: 0755

- name: 'Setup crontab to backup the opencrvs data'
cron:
user: '{{ crontab_user }}'
name: 'backup opencrvs'
minute: '0'
hour: '0'
job: 'cd / && bash /opt/opencrvs/infrastructure/backups/backup.sh --passphrase={{ backup_encryption_passphrase }} --ssh_user={{ external_backup_server_user }} --ssh_host={{ external_backup_server_ip }} --ssh_port={{ external_backup_server_ssh_port }} --remote_dir={{ external_backup_server_remote_directory }} --replicas=1 >> /var/log/opencrvs-backup.log 2>&1'
job: 'bash {{ crontab_user_home }}/backup.sh --passphrase={{ backup_encryption_passphrase }} --ssh_user={{ external_backup_server_user }} --ssh_host={{ external_backup_server_ip }} --ssh_port={{ external_backup_server_ssh_port }} --remote_dir={{ external_backup_server_remote_directory }} --replicas=1 >> /var/log/opencrvs-backup.log 2>&1'
state: "{{ 'present' if (external_backup_server_ip is defined and backup_encryption_passphrase and (enable_backups | default(false))) else 'absent' }}"

##
Expand Down
Loading