Skip to content

Commit 47a1c88

Browse files
authored
Add support for other s3 providers (#90)
* Add support for other s3 providers You can configure another s3 provider by supplying the node_backup_s3_provider, node_backup_s3_access_key_id, node_backup_s3_secret_access_key, node_backup_s3_endpoint and optionally node_backup_s3_region. To use this type of service, you have to set the backup type to s3-rclone. * Node backups - only use no_check_bucket on R2 Restrict the no_check_bucket to Cloudflare as the impact on other sites is unknown. Also bumps galaxy.yml
1 parent 1358ce6 commit 47a1c88

File tree

8 files changed

+36
-13
lines changed

8 files changed

+36
-13
lines changed

galaxy.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ namespace: paritytech
88
name: chain
99

1010
# The version of the collection. Must be compatible with semantic versioning
11-
version: 1.10.8
11+
version: 1.10.9
1212

1313
# The path to the Markdown (.md) readme file. This path is relative to the root of the collection
1414
readme: README.md

roles/node_backup/defaults/main.yml

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,14 @@ node_backup_r2_access_key_id: ""
66
node_backup_r2_secret_access_key: ""
77
node_backup_r2_api_url: ""
88

9+
# S3 Compatible configuration (defaults to filling with r2 configuration for backward compat)
10+
node_backup_s3_access_key_id: "{{ node_backup_r2_access_key_id }}"
11+
node_backup_s3_secret_access_key: "{{ node_backup_r2_secret_access_key }}"
12+
node_backup_s3_endpoint: "{{ node_backup_r2_api_url }}"
13+
node_backup_s3_region: ""
14+
# The rclone provider to use for the backup
15+
node_backup_s3_provider: Cloudflare
16+
917
node_backup_max_concurrent_requests: 50
1018

1119
node_backup_schedule:
@@ -31,7 +39,7 @@ node_backup_targets: []
3139
# # old way of backups. It takes more time to restore and backup
3240
# # it's true by default
3341
# tar: false
34-
# # type of backup. can be 'gcp-native', 'gcp-rclone' or 'r2-rclone'
42+
# # type of backup. can be 'gcp-native', 'gcp-rclone', 'r2-rclone' or 's3-rclone'
3543
# type: 'gcp-rclone'
3644
# # name of the bucket
3745
# bucket_name: "backup"

roles/node_backup/tasks/main.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
- path: "{{ _node_backup_log_path }}"
2424
user: root
2525
- path: "{{ _node_backup_venv_path }}"
26-
user: root
26+
user: "{{ node_backup_user }}"
2727
tags: [node-backup]
2828

2929
- name: node-backup | requirements

roles/node_backup/tasks/requirements.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@
3636
owner: root
3737
group: root
3838

39-
- name: node-backup | requirements | copy R2 config
39+
- name: node-backup | requirements | copy rclone config
4040
ansible.builtin.template:
4141
src: rclone/rclone.conf.j2
4242
dest: /root/.config/rclone/rclone.conf

roles/node_backup/tasks/tests.yml

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,12 @@
55
when: node_backup_targets | json_query('[].type') | intersect(_node_backup_r2_types) | length > 0 and ( node_backup_r2_access_key_id == '' or node_backup_r2_secret_access_key
66
== '' or node_backup_r2_api_url == '' )
77

8+
- name: node-backup | test | check s3 configuration
9+
ansible.builtin.fail:
10+
msg: If the S3 backups are used, 'node_backup_s3_access_key_id', 'node_backup_s3_secret_access_key', 'node_backup_s3_endpoint' amd 'node_backup_s3_provider' variables have to be specified
11+
when: node_backup_targets | json_query('[].type') | intersect(_node_backup_rclone_types) | length > 0 and ( node_backup_s3_access_key_id == '' or node_backup_s3_secret_access_key
12+
== '' or node_backup_s3_endpoint == '' or node_backup_s3_provider == '' )
13+
814
- name: node-backup | test | check variables
915
ansible.builtin.fail:
1016
msg: "'service_name', 'rpc_port', 'type' and 'bucket_name' fields have to be specified for each item in 'node_backup_targets'"
@@ -20,5 +26,5 @@
2026
- name: node-backup | test | check backup types
2127
ansible.builtin.fail:
2228
msg: "{{ item.type }} is not a valid backup type"
23-
when: item.type not in (_node_backup_gcp_types + _node_backup_r2_types)
29+
when: item.type not in (_node_backup_gcp_types + _node_backup_rclone_types)
2430
loop: "{{ node_backup_targets }}"

roles/node_backup/templates/rclone/rclone.conf.j2

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,20 @@
1-
{% if node_backup_targets | json_query('[].type') | intersect(_node_backup_r2_types) | length > 0 %}
2-
[R2backups]
1+
{% if node_backup_targets | json_query('[].type') | intersect(_node_backup_rclone_types) | length > 0 %}
2+
[S3backups]
33
type = s3
4-
provider = Cloudflare
5-
access_key_id = {{ node_backup_r2_access_key_id }}
6-
secret_access_key = {{ node_backup_r2_secret_access_key }}
7-
endpoint = {{ node_backup_r2_api_url }}
4+
provider = {{ node_backup_s3_provider }}
5+
access_key_id = {{ node_backup_s3_access_key_id }}
6+
secret_access_key = {{ node_backup_s3_secret_access_key }}
7+
endpoint = {{ node_backup_s3_endpoint }}
8+
{% if node_backup_s3_region != "" %}
9+
region = {{ node_backup_s3_region }}
10+
{% endif %}
811
acl = private
912
upload_cutoff = 1024M
1013
upload_concurrency = {{ node_backup_max_concurrent_requests }}
1114
chunk_size = 256M
15+
{% if node_backup_s3_provider == "Cloudflare" %}
16+
no_check_bucket = true
17+
{% endif %}
1218
{% endif %}
1319

1420
{% if node_backup_targets | json_query('[].type') | intersect(_node_backup_gcp_types) | length > 0 %}

roles/node_backup/templates/single-backup.sh.j2

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -128,7 +128,9 @@ echo -e "\n---\n$(date +%Y-%m-%d\ %H:%M:%S) Start the '{{ item.id }}' backup\n--
128128
{% if item.type == 'gcp-rclone' %}
129129
remote="GCPbackups"
130130
{% elif item.type == 'r2-rclone' %}
131-
remote="R2backups"
131+
remote="S3backups"
132+
{% elif item.type == 's3-rclone' %}
133+
remote="S3backups"
132134
{% else %}
133135
{{ "backup type must be defined."/0 }}
134136
{% endif %}

roles/node_backup/vars/main.yml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,9 @@ _node_backup_rclone_deb: https://downloads.rclone.org/v1.63.1/rclone-v1.63.1-lin
1010

1111
_node_backup_r2_types: [r2-rclone]
1212
_node_backup_gcp_types: [gcp-native, gcp-rclone]
13-
_node_backup_rclone_types: [gcp-rclone, r2-rclone]
13+
_node_backup_rclone_types: [gcp-rclone, r2-rclone, s3-rclone]
1414
_node_backup_storages:
15+
s3-rclone: s3
1516
r2-rclone: r2
1617
gcp-rclone: gcp
1718
gcp-native: gcp

0 commit comments

Comments
 (0)