You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
35 lines
929 B
YAML
35 lines
929 B
YAML
### Example:
|
|
# ansible-playbook -v ansible/volume-restore.yml -e "container_name=linkding volume_suffix=data"
|
|
|
|
---
|
|
- hosts: servers
|
|
tasks:
|
|
- name: Find backup
|
|
find:
|
|
paths: /mnt/hdds/backups/
|
|
patterns: "{{container_name}}"
|
|
use_regex: true
|
|
recurse: true
|
|
register: files_matched
|
|
- name: Stop the container
|
|
docker_container:
|
|
name: "{{container_name}}"
|
|
state: stopped
|
|
- name: Restore Volume
|
|
environment:
|
|
ARCHIVE_NAME: "{{ files_matched.files[0].path }}"
|
|
VOLUME_TO_CREATE: "{{container_name}}_{{volume_suffix}}"
|
|
ansible.builtin.command: docker run --rm
|
|
-v /var/run/docker.sock:/var/run/docker.sock
|
|
ghcr.io/chatton/docker-volume-backup:master
|
|
restore-volume
|
|
--volume ${VOLUME_TO_CREATE}
|
|
--archive ${ARCHIVE_NAME}
|
|
- name: Start the container
|
|
docker_container:
|
|
name: "{{container_name}}"
|
|
state: started
|
|
|
|
|
|
|