backup restore working correctly
parent
099c29e7d4
commit
41762fb07e
@ -0,0 +1,2 @@
|
|||||||
|
---
|
||||||
|
# defaults file for docker_archive_volume_restore
|
||||||
@ -0,0 +1,2 @@
|
|||||||
|
---
|
||||||
|
# handlers file for docker_archive_volume_restore
|
||||||
@ -0,0 +1,2 @@
|
|||||||
|
---
|
||||||
|
# tasks file for docker_archive_volume_restore
|
||||||
@ -0,0 +1,2 @@
|
|||||||
|
---
|
||||||
|
# vars file for docker_archive_volume_restore
|
||||||
@ -0,0 +1,52 @@
|
|||||||
|
galaxy_info:
|
||||||
|
author: your name
|
||||||
|
description: your role description
|
||||||
|
company: your company (optional)
|
||||||
|
|
||||||
|
# If the issue tracker for your role is not on github, uncomment the
|
||||||
|
# next line and provide a value
|
||||||
|
# issue_tracker_url: http://example.com/issue/tracker
|
||||||
|
|
||||||
|
# Choose a valid license ID from https://spdx.org - some suggested licenses:
|
||||||
|
# - BSD-3-Clause (default)
|
||||||
|
# - MIT
|
||||||
|
# - GPL-2.0-or-later
|
||||||
|
# - GPL-3.0-only
|
||||||
|
# - Apache-2.0
|
||||||
|
# - CC-BY-4.0
|
||||||
|
license: license (GPL-2.0-or-later, MIT, etc)
|
||||||
|
|
||||||
|
min_ansible_version: 2.1
|
||||||
|
|
||||||
|
# If this a Container Enabled role, provide the minimum Ansible Container version.
|
||||||
|
# min_ansible_container_version:
|
||||||
|
|
||||||
|
#
|
||||||
|
# Provide a list of supported platforms, and for each platform a list of versions.
|
||||||
|
# If you don't wish to enumerate all versions for a particular platform, use 'all'.
|
||||||
|
# To view available platforms and versions (or releases), visit:
|
||||||
|
# https://galaxy.ansible.com/api/v1/platforms/
|
||||||
|
#
|
||||||
|
# platforms:
|
||||||
|
# - name: Fedora
|
||||||
|
# versions:
|
||||||
|
# - all
|
||||||
|
# - 25
|
||||||
|
# - name: SomePlatform
|
||||||
|
# versions:
|
||||||
|
# - all
|
||||||
|
# - 1.0
|
||||||
|
# - 7
|
||||||
|
# - 99.99
|
||||||
|
|
||||||
|
galaxy_tags: []
|
||||||
|
# List tags for your role here, one per line. A tag is a keyword that describes
|
||||||
|
# and categorizes the role. Users find roles by searching for tags. Be sure to
|
||||||
|
# remove the '[]' above, if you add tags to this list.
|
||||||
|
#
|
||||||
|
# NOTE: A tag is limited to a single word comprised of alphanumeric characters.
|
||||||
|
# Maximum 20 tags per role.
|
||||||
|
|
||||||
|
dependencies: []
|
||||||
|
# List your role dependencies here, one per line. Be sure to remove the '[]' above,
|
||||||
|
# if you add dependencies to this list.
|
||||||
@ -0,0 +1,5 @@
|
|||||||
|
---
|
||||||
|
# defaults file for docker_s3_volume_restore
|
||||||
|
docker_volume_s3_restores:
|
||||||
|
- volume_name: "linkding_data"
|
||||||
|
s3_key: "linkding_data/linkding_data-2022-09-01T21:32:54Z.tar.gz"
|
||||||
@ -0,0 +1,2 @@
|
|||||||
|
---
|
||||||
|
# handlers file for docker_s3_volume_restore
|
||||||
@ -0,0 +1,52 @@
|
|||||||
|
galaxy_info:
|
||||||
|
author: your name
|
||||||
|
description: your role description
|
||||||
|
company: your company (optional)
|
||||||
|
|
||||||
|
# If the issue tracker for your role is not on github, uncomment the
|
||||||
|
# next line and provide a value
|
||||||
|
# issue_tracker_url: http://example.com/issue/tracker
|
||||||
|
|
||||||
|
# Choose a valid license ID from https://spdx.org - some suggested licenses:
|
||||||
|
# - BSD-3-Clause (default)
|
||||||
|
# - MIT
|
||||||
|
# - GPL-2.0-or-later
|
||||||
|
# - GPL-3.0-only
|
||||||
|
# - Apache-2.0
|
||||||
|
# - CC-BY-4.0
|
||||||
|
license: license (GPL-2.0-or-later, MIT, etc)
|
||||||
|
|
||||||
|
min_ansible_version: 2.1
|
||||||
|
|
||||||
|
# If this a Container Enabled role, provide the minimum Ansible Container version.
|
||||||
|
# min_ansible_container_version:
|
||||||
|
|
||||||
|
#
|
||||||
|
# Provide a list of supported platforms, and for each platform a list of versions.
|
||||||
|
# If you don't wish to enumerate all versions for a particular platform, use 'all'.
|
||||||
|
# To view available platforms and versions (or releases), visit:
|
||||||
|
# https://galaxy.ansible.com/api/v1/platforms/
|
||||||
|
#
|
||||||
|
# platforms:
|
||||||
|
# - name: Fedora
|
||||||
|
# versions:
|
||||||
|
# - all
|
||||||
|
# - 25
|
||||||
|
# - name: SomePlatform
|
||||||
|
# versions:
|
||||||
|
# - all
|
||||||
|
# - 1.0
|
||||||
|
# - 7
|
||||||
|
# - 99.99
|
||||||
|
|
||||||
|
galaxy_tags: []
|
||||||
|
# List tags for your role here, one per line. A tag is a keyword that describes
|
||||||
|
# and categorizes the role. Users find roles by searching for tags. Be sure to
|
||||||
|
# remove the '[]' above, if you add tags to this list.
|
||||||
|
#
|
||||||
|
# NOTE: A tag is limited to a single word comprised of alphanumeric characters.
|
||||||
|
# Maximum 20 tags per role.
|
||||||
|
|
||||||
|
dependencies: []
|
||||||
|
# List your role dependencies here, one per line. Be sure to remove the '[]' above,
|
||||||
|
# if you add dependencies to this list.
|
||||||
@ -0,0 +1,54 @@
|
|||||||
|
---
|
||||||
|
# https://docs.ansible.com/ansible/latest/collections/community/docker/docker_container_module.html#ansible-collections-community-docker-docker-container-module
|
||||||
|
# https://docs.docker.com/storage/volumes/#backup-restore-or-migrate-data-volumes
|
||||||
|
#
|
||||||
|
- name: Download archive from S3
|
||||||
|
amazon.aws.aws_s3:
|
||||||
|
bucket: "{{ aws_s3.bucket }}"
|
||||||
|
object: "{{ item.s3_key }}"
|
||||||
|
aws_access_key: "{{ aws_s3.aws_access_key }}"
|
||||||
|
aws_secret_key: "{{ aws_s3.aws_secret_key }}"
|
||||||
|
region: "{{ aws_s3.region }}"
|
||||||
|
s3_url: "https://{{ aws_s3.s3_url }}"
|
||||||
|
mode: get
|
||||||
|
dest: "/tmp/{{ item.s3_key }}"
|
||||||
|
register: get_out
|
||||||
|
with_items: "{{ docker_volume_s3_restores }}"
|
||||||
|
|
||||||
|
- debug: msg="{{ get_out }}"
|
||||||
|
|
||||||
|
- name: Ensure Volume
|
||||||
|
docker_volume:
|
||||||
|
name: "{{ item.volume_name }}"
|
||||||
|
state: present
|
||||||
|
with_items: "{{ docker_volume_s3_restores }}"
|
||||||
|
|
||||||
|
# TODO: skip if the volume was just created
|
||||||
|
- name: Remove contents of volumes
|
||||||
|
community.docker.docker_container:
|
||||||
|
name: "restore-container-{{ item.volume_name }}-{{ 10 | random }}"
|
||||||
|
image: ubuntu
|
||||||
|
command: "rm -rf ./*"
|
||||||
|
auto_remove: true
|
||||||
|
detach: false # block until this container exists.
|
||||||
|
state: started
|
||||||
|
# start inside the directory we want to wipe
|
||||||
|
working_dir: "/data"
|
||||||
|
volumes:
|
||||||
|
- "{{ item.volume_name }}:/data"
|
||||||
|
with_items: "{{ docker_volume_s3_restores }}"
|
||||||
|
|
||||||
|
- name: Restore contents of volumes
|
||||||
|
community.docker.docker_container:
|
||||||
|
name: "restore-container-{{ item.volume_name }}-{{ 10 | random }}"
|
||||||
|
image: ubuntu
|
||||||
|
# extract the tar into the volume.
|
||||||
|
command: "tar xvf /tmp/{{ item.s3_key }} -C /data --strip-components 1"
|
||||||
|
auto_remove: true
|
||||||
|
detach: false # block until this container exists.
|
||||||
|
state: started
|
||||||
|
volumes:
|
||||||
|
- "{{ item.volume_name }}:/data"
|
||||||
|
- /tmp:/tmp
|
||||||
|
with_items: "{{ docker_volume_s3_restores }}"
|
||||||
|
|
||||||
@ -0,0 +1,2 @@
|
|||||||
|
---
|
||||||
|
# vars file for docker_s3_volume_restore
|
||||||
Loading…
Reference in New Issue