sce/roles/backup_nfs/tasks/per-container-restore.yml
Ivo C.S. Wingelaar 3934bffbd1
Add backup restoration logic to NFS role
Passing the `backup_nfs_restore` variable will restore that timestamp.
2024-10-13 20:12:26 +02:00

24 lines
853 B
YAML

---
- name: Ensure container is stopped
ansible.builtin.systemd_service:
name: container-{{ container }}.service
state: stopped
scope: user
register: container_state
- name: Import the volumes
containers.podman.podman_import:
volume: "{{ item }}"
src: "{{ backup_nfs_mountpoint }}/{{ container }}-{{ item }}-{{ backup_nfs_restore }}.tar"
loop: "{{ backup_nfs_containers['volumes'] }}"
# A container is not always running, so if it was stopped before
# the backup procedure even started, do not start it again.
# It's quite a hassle to have this behaviour with a handler, so
# we just suppress the linting error.
- name: Start container again if necessary # noqa: no-handler
ansible.builtin.systemd_service:
name: container-{{ container }}.service
state: started
scope: user
when: container_state is changed