diff --git a/infrastructure/server-setup/backups.yml b/infrastructure/server-setup/backups.yml index 1d5b49f86..66661f13f 100644 --- a/infrastructure/server-setup/backups.yml +++ b/infrastructure/server-setup/backups.yml @@ -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 @@ -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 diff --git a/infrastructure/server-setup/group_vars/all.yml b/infrastructure/server-setup/group_vars/all.yml index 1529c0347..cf2927713 100644 --- a/infrastructure/server-setup/group_vars/all.yml +++ b/infrastructure/server-setup/group_vars/all.yml @@ -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' diff --git a/infrastructure/server-setup/production.yml b/infrastructure/server-setup/production.yml index 3e2acb4d2..f66f57101 100644 --- a/infrastructure/server-setup/production.yml +++ b/infrastructure/server-setup/production.yml @@ -57,6 +57,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 diff --git a/infrastructure/server-setup/staging.yml b/infrastructure/server-setup/staging.yml index fd004f448..b466e96d5 100644 --- a/infrastructure/server-setup/staging.yml +++ b/infrastructure/server-setup/staging.yml @@ -69,6 +69,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 diff --git a/infrastructure/server-setup/tasks/backups/crontab.yml b/infrastructure/server-setup/tasks/backups/crontab.yml index c226c96b2..1370e3180 100644 --- a/infrastructure/server-setup/tasks/backups/crontab.yml +++ b/infrastructure/server-setup/tasks/backups/crontab.yml @@ -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' }}" ##