This repository has been archived by the owner on Sep 12, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
3c64826
commit 69337c0
Showing
8 changed files
with
239 additions
and
90 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
FROM alpine:3.9 | ||
FROM alpine:3.10 | ||
MAINTAINER tess@ten7.com | ||
|
||
# Update the package list and install Ansible. | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,102 @@ | ||
--- | ||
- name: Create a temp directory to stage the backup | ||
tempfile: | ||
state: directory | ||
prefix: "s3-{{ _backup.bucket }}-{{ _backup_timestamp }}" | ||
register: _s3_temp_dir | ||
when: | ||
- _backup.cacheDir is not defined | ||
- name: Create a cache directory for the backup | ||
file: | ||
state: directory | ||
path: "{{ _backup.cacheDir }}" | ||
owner: "backup" | ||
group: "backup" | ||
mode: "u=rwx,g=rxw,o=rwx" | ||
when: | ||
- _backup.cacheDir is defined | ||
- name: Sync files from source S3 using awscli | ||
shell: > | ||
aws s3 sync | ||
{% for _exclude in _backup.excludes | default(_tractorbeam_default_files_excludes) %} | ||
--exclude "{{ _exclude }}"{{ '' }} | ||
{% endfor %} | ||
{% if _backup.delete | default(true) %} | ||
--delete | ||
{% endif %} | ||
{% if (flightdeck_debug | default(false)) != true %} | ||
--quiet | ||
{% elif lookup('env', 'ANSIBLE_VERBOSITY') == 4 %} | ||
--only-show-errors | ||
{% endif %} | ||
{% if _backup.srcEndpoint is defined %} | ||
--endpoint-url {{ _backup.srcEndpoint }} | ||
{% endif %} | ||
{% if _backup.srcRegion is defined %} | ||
--region {{ _backup.srcRegion }} | ||
{% endif %} | ||
s3://{{ _backup.srcBucket }}/{% if _backup.prefix is defined %}{{ _backup.prefix }}/{% endif %} | ||
{{ _backup.cacheDir | default(_s3_temp_dir.path) }} | ||
environment: | ||
AWS_ACCESS_KEY_ID: "\ | ||
{% if _backup.srcAccessKeyFile is defined %}\ | ||
{{ lookup('file', _backup.srcAccessKeyFile) }}\ | ||
{% else %}\ | ||
{{ _backup.srcAccessKey | default(omit) }}\ | ||
{% endif %}" | ||
AWS_SECRET_ACCESS_KEY: "\ | ||
{% if _backup.srcSecretKeyFile is defined %}\ | ||
{{ lookup('file', _backup.srcSecretKeyFile) }}\ | ||
{% else %}\ | ||
{{ _backup.srcSecretKey | default(omit) }}\ | ||
{% endif %}" | ||
register: _froms3_result | ||
until: _froms3_result.rc == 0 | ||
retries: "{{ _backup.retryCount | default(3) }}" | ||
delay: "{{ _backup.retryDelay | default(30) }}" | ||
- name: Sync directory to S3 using awscli | ||
shell: > | ||
aws s3 sync | ||
{% for _exclude in _backup.excludes | default(_tractorbeam_default_files_excludes) %} | ||
--exclude "{{ _exclude }}"{{ '' }} | ||
{% endfor %} | ||
{% if _backup.delete | default(true) %} | ||
--delete | ||
{% endif %} | ||
{% if (flightdeck_debug | default(false)) != true %} | ||
--quiet | ||
{% elif lookup('env', 'ANSIBLE_VERBOSITY') == 4 %} | ||
--only-show-errors | ||
{% endif %} | ||
{% if _backup.endpoint is defined %} | ||
--endpoint-url {{ _backup.endpoint }} | ||
{% endif %} | ||
{% if _backup.region is defined %} | ||
--region {{ _backup.region }} | ||
{% endif %} | ||
{{ _backup.cacheDir | default(_s3_temp_dir.path) }}/ | ||
s3://{{ _backup.bucket }}/{{ _backup.prefix }} | ||
environment: | ||
AWS_ACCESS_KEY_ID: "\ | ||
{% if _backup.accessKeyFile is defined %}\ | ||
{{ lookup('file', _backup.accessKeyFile) }}\ | ||
{% else %}\ | ||
{{ _backup.accessKey | default(omit) }}\ | ||
{% endif %}" | ||
AWS_SECRET_ACCESS_KEY: "\ | ||
{% if _backup.secretKeyFile is defined %}\ | ||
{{ lookup('file', _backup.secretKeyFile) }}\ | ||
{% else %}\ | ||
{{ _backup.secretKey | default(omit) }}\ | ||
{% endif %}" | ||
register: _tos3_result | ||
until: _tos3_result.rc == 0 | ||
retries: "{{ _backup.retryCount | default(3) }}" | ||
delay: "{{ _backup.retryDelay | default(30) }}" | ||
- name: delete stage directory | ||
file: | ||
path: "_s3_temp_dir.path" | ||
state: absent | ||
when: | ||
- _s3_temp_dir.path is defined | ||
- include_tasks: "healhcheck.yml" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,110 @@ | ||
--- | ||
- name: Create a temp directory to stage the backup | ||
tempfile: | ||
state: directory | ||
prefix: "s3-{{ _backup.bucket }}-{{ _backup_timestamp }}" | ||
register: _s3_temp_dir | ||
when: | ||
- _backup.cacheDir is not defined | ||
- name: Create a cache directory for the backup | ||
file: | ||
state: directory | ||
path: "{{ _backup.cacheDir }}" | ||
owner: "backup" | ||
group: "backup" | ||
mode: "u=rwx,g=rxw,o=rwx" | ||
when: | ||
- _backup.cacheDir is defined | ||
- name: Create the .boto file for the source sync | ||
copy: | ||
content: | | ||
[Credentials] | ||
aws_access_key_id = {{ _access_key }} | ||
aws_secret_access_key = {{ _secret_key }} | ||
{% if _backup.srcEndpoint is defined %} | ||
s3_host = {{ _backup.srcEndpoint | regex_replace('[A-z]*://', '') }} | ||
{% endif %} | ||
dest: "/home/backup/.boto" | ||
owner: "backup" | ||
group: "backup" | ||
mode: "u=rw,g=rw,o=" | ||
vars: | ||
_access_key: "\ | ||
{% if _backup.srcAccessKeyFile is defined %}\ | ||
{{ lookup('file', _backup.srcAccessKeyFile) }}\ | ||
{% else %}\ | ||
{{ _backup.srcAccessKey | default(omit) }}\ | ||
{% endif %}" | ||
_secret_key: "\ | ||
{% if _backup.srcSecretKeyFile is defined %}\ | ||
{{ lookup('file', _backup.srcSecretKeyFile) }}\ | ||
{% else %}\ | ||
{{ _backup.srcSecretKey | default(omit) }}\ | ||
{% endif %}" | ||
- name: Sync files from source S3 using gsutil | ||
shell: > | ||
gsutil -m rsync | ||
{% for _exclude in _backup.excludes | default([]) %} | ||
-x "{{ _exclude }}"{{ '' }} | ||
{% endfor %} | ||
{% if _backup.delete | default(true) %} | ||
-d | ||
{% endif %} | ||
-r | ||
-C | ||
s3://{{ _backup.srcBucket }}/{% if _backup.prefix is defined %}{{ _backup.prefix }}/{% endif %} | ||
{{ _backup.cacheDir | default(_s3_temp_dir.path) }}/ | ||
register: _froms3_result | ||
until: _froms3_result.rc == 0 | ||
retries: "{{ _backup.retryCount | default(3) }}" | ||
delay: "{{ _backup.retryDelay | default(30) }}" | ||
- name: Create the .boto file for the destination sync | ||
copy: | ||
content: | | ||
[Credentials] | ||
aws_access_key_id = {{ _access_key }} | ||
aws_secret_access_key = {{ _secret_key }} | ||
{% if _backup.endpoint is defined %} | ||
s3_host = {{ _backup.endpoint | regex_replace('[A-z]*://', '') }} | ||
{% endif %} | ||
dest: "/home/backup/.boto" | ||
owner: "backup" | ||
group: "backup" | ||
mode: "u=rw,g=rw,o=" | ||
vars: | ||
_access_key: "\ | ||
{% if _backup.accessKeyFile is defined %}\ | ||
{{ lookup('file', _backup.accessKeyFile) }}\ | ||
{% else %}\ | ||
{{ _backup.accessKey | default(omit) }}\ | ||
{% endif %}" | ||
_secret_key: "\ | ||
{% if _backup.secretKeyFile is defined %}\ | ||
{{ lookup('file', _backup.secretKeyFile) }}\ | ||
{% else %}\ | ||
{{ _backup.secretKey | default(omit) }}\ | ||
{% endif %}" | ||
- name: Sync directory to S3 using gsutil | ||
shell: > | ||
gsutil -m rsync | ||
{% for _exclude in _backup.excludes | default([]) %} | ||
-x "{{ _exclude }}"{{ '' }} | ||
{% endfor %} | ||
{% if _backup.delete | default(true) %} | ||
-d | ||
{% endif %} | ||
-r | ||
-C | ||
{{ _backup.cacheDir | default(_s3_temp_dir.path) }}/ | ||
s3://{{ _backup.bucket }}/{{ _backup.prefix }}/ | ||
register: _tos3_result | ||
until: _tos3_result.rc == 0 | ||
retries: "{{ _backup.retryCount | default(3) }}" | ||
delay: "{{ _backup.retryDelay | default(30) }}" | ||
- name: delete stage directory | ||
file: | ||
path: "_s3_temp_dir.path" | ||
state: absent | ||
when: | ||
- _s3_temp_dir.path is defined | ||
- include_tasks: "healhcheck.yml" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters