From 986b51933450b562729287fa471ecc2556db339d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C5=82=20Matczuk?= Date: Fri, 25 Jun 2021 16:02:08 +0200 Subject: [PATCH] restore_scylla_manager_backup: move to Scylla Manager repo Code is migrated to https://github.com/scylladb/scylla-manager/tree/master/ansible/restore that is now publicly available. --- .../restore_scylla_manager_backup/.gitignore | 2 - .../restore_scylla_manager_backup/README.md | 73 ----------- .../hosts.example | 6 - .../restore.yaml | 118 ------------------ .../vars.yaml.example | 16 --- 5 files changed, 215 deletions(-) delete mode 100644 example-playbooks/restore_scylla_manager_backup/.gitignore delete mode 100644 example-playbooks/restore_scylla_manager_backup/README.md delete mode 100644 example-playbooks/restore_scylla_manager_backup/hosts.example delete mode 100644 example-playbooks/restore_scylla_manager_backup/restore.yaml delete mode 100644 example-playbooks/restore_scylla_manager_backup/vars.yaml.example diff --git a/example-playbooks/restore_scylla_manager_backup/.gitignore b/example-playbooks/restore_scylla_manager_backup/.gitignore deleted file mode 100644 index f7ee49d0..00000000 --- a/example-playbooks/restore_scylla_manager_backup/.gitignore +++ /dev/null @@ -1,2 +0,0 @@ -hosts -vars.yaml \ No newline at end of file diff --git a/example-playbooks/restore_scylla_manager_backup/README.md b/example-playbooks/restore_scylla_manager_backup/README.md deleted file mode 100644 index e559611a..00000000 --- a/example-playbooks/restore_scylla_manager_backup/README.md +++ /dev/null @@ -1,73 +0,0 @@ -# Restore Scylla Manager backup - -This is an ansible playbook that lets you clone a cluster from a Scylla Manager backup. -It requires Scylla Manager 2.4 or newer. - -## Prerequisites - -1. New cluster with the same number of nodes as the source cluster. -1. Scylla Manager Agent installed on all the nodes. -1. Access to the backup location from all the nodes. - -## Parameters - -All restore parameters shall be put to `vars.yaml` file. -Copy `vars.yaml.example` as `vars.yaml` and change parameters to match your clusters. - -### IP to host ID mapping - -SSH to one of the nodes and execute the following command: - -```bash -scylla-manager-agent download-files -L --list-nodes -``` - -it gives you information about all the clusters and nodes available in the backup location. - -Example output: - -``` -Cluster: prod (a9dcc6e1-17dc-4520-9e03-0a92011c823c) -AWS_EU_CENTRAL_1: -- 18.198.164.180 (7e68421b-acb1-44a7-a1a8-af7eaf1bb482) -- 3.122.35.120 (adc0a3ce-dade-4672-981e-26f91a3d35cb) -- 3.127.175.215 (2a575244-3e3c-44a1-a526-da4394f9525e) -- 3.65.85.108 (82f0f486-370d-4cfd-90ac-46464c8012cb) -- 3.66.209.145 (9ee92c19-5f78-4865-a287-980218963d96) -- 3.66.44.239 (aff05f79-7c69-4ecf-a827-5ea790a0fdc6) - -Cluster: test (da5721cd-e2eb-4d10-a3a7-f729b8f72abf) -AWS_EU_CENTRAL_1: -- 3.123.55.215 (4001206a-3377-40cb-abd4-d38aad5dec41) -- 3.127.1.189 (c6466011-02f9-49dd-8951-c32028dfc6f1) -- 3.64.219.214 (bc39bb07-7a21-41cd-b576-51d44c1a694a) -``` - -For each node IP in the new cluster you need to assign a host ID (UUID in the listing above). -The mapping must be put into `host_id` variable in `vars.yaml` file. - -### Snapshot tag - -To list available snapshot tags for a node use `--list-snapshots` flag. - -```bash -scylla-manager-agent download-files -L --list-snapshots -n -``` - -You can filter snapshot tags containing a specific keyspaces or tables by using glob patterns. -The parameter `-K, --keyspace ` lets you do that. -It works the same way as in scheduling backups or repairs with Scylla Manager. - -The snapshot ID must be put into `snapshot_tag` variable in `vars.yaml` file. - -## Inventory - -Put public IP addresses of all nodes to `hosts` file. - -## Running - -Rut the playbook: - -```bash -ansible-playbook -i hosts -e @vars.yaml restore.yaml -``` diff --git a/example-playbooks/restore_scylla_manager_backup/hosts.example b/example-playbooks/restore_scylla_manager_backup/hosts.example deleted file mode 100644 index 0c5580a9..00000000 --- a/example-playbooks/restore_scylla_manager_backup/hosts.example +++ /dev/null @@ -1,6 +0,0 @@ -3.65.230.34 -3.66.75.209 -3.65.102.133 -3.125.251.43 -3.66.176.252 -3.66.25.100 \ No newline at end of file diff --git a/example-playbooks/restore_scylla_manager_backup/restore.yaml b/example-playbooks/restore_scylla_manager_backup/restore.yaml deleted file mode 100644 index 330644bf..00000000 --- a/example-playbooks/restore_scylla_manager_backup/restore.yaml +++ /dev/null @@ -1,118 +0,0 @@ ---- - -- name: Restore - hosts: all - become: true - gather_facts: false - tasks: - - name: Stop Scylla service - service: - name: scylla-server - state: stopped - - - name: Remove Scylla directories - file: - path: "/var/lib/scylla/{{ item }}" - state: absent - loop: - - data - - commitlog - - hints - - view_hints - - - name: Recreate Scylla directories - file: - path: "/var/lib/scylla/{{ item }}" - state: directory - owner: scylla - group: scylla - mode: 0755 - loop: - - data - - commitlog - - hints - - view_hints - - - name: Get initial token - shell: | - scylla-manager-agent download-files -L {{ backup_location }} -n {{ host_id[inventory_hostname] }} -T {{ snapshot_tag }} --dump-tokens - register: _initial_token - - - name: Set initial_token in scylla.yaml - lineinfile: - path: /etc/scylla/scylla.yaml - regexp: '^(#\s*)?initial_token:' - line: "initial_token: {{ _initial_token.stdout }}" - create: yes - - - name: Get seeds list - shell: | - grep '\- seeds:' /etc/scylla/scylla.yaml | awk '{ print $NF }' | tr -d '"' | tr -d "'" - register: _seeds - - - name: Temporarily make each node a seed - lineinfile: - path: /etc/scylla/scylla.yaml - regexp: '^(\s+) - seeds:' - line: | - \g<1> - seeds: {{ groups.all | join(',') }} - backrefs: yes - - - name: Start Scylla service - service: - name: scylla-server - state: started - - - name: Wait for CQL port - wait_for: - port: 9042 - - - name: Stop Scylla service - service: - name: scylla-server - state: stopped - - - name: Temporarily make the first node a seed - lineinfile: - path: /etc/scylla/scylla.yaml - regexp: '^(\s+) - seeds:' - line: | - \g<1> - seeds: {{ groups.all[0] }} - backrefs: yes - - - name: Download data - shell: | - scylla-manager-agent download-files -L {{ backup_location }} -n {{ host_id[inventory_hostname] }} -T {{ snapshot_tag }} -d /var/lib/scylla/data/ - become_user: scylla - async: 604800 # a week 7*24*60*60 seconds - poll: 5 - - - name: Start Scylla service in the seed - service: - name: scylla-server - state: started - when: inventory_hostname == groups.all[0] - - - name: Start Scylla service - throttle: 1 - service: - name: scylla-server - state: started - - - name: Wait for CQL port - wait_for: - port: 9042 - - - name: Resore seeds list - lineinfile: - path: /etc/scylla/scylla.yaml - regexp: '^(\s+) - seeds:' - line: | - \g<1> - seeds: {{ _seeds.stdout }} - backrefs: yes - - - name: Restart Scylla service - throttle: 1 - service: - name: scylla-server - state: restarted diff --git a/example-playbooks/restore_scylla_manager_backup/vars.yaml.example b/example-playbooks/restore_scylla_manager_backup/vars.yaml.example deleted file mode 100644 index 8d6bf0ab..00000000 --- a/example-playbooks/restore_scylla_manager_backup/vars.yaml.example +++ /dev/null @@ -1,16 +0,0 @@ -# backup_location specifies the location parameter used in Scylla Manager -# when scheduling a backup of a cluster. -backup_location: s3:manager-test-demo1 - -# snapshot_tag specifies the Scylla Manager snapshot tag you want to restore. -snapshot_tag: sm_20210422133609UTC - -# host_id specifies a mapping from the clone cluster node IP to the source -# cluster host IDs. -host_id: - 3.65.230.34: 7e68421b-acb1-44a7-a1a8-af7eaf1bb482 - 3.66.75.209: adc0a3ce-dade-4672-981e-26f91a3d35cb - 3.65.102.133: 2a575244-3e3c-44a1-a526-da4394f9525e - 3.125.251.43: 82f0f486-370d-4cfd-90ac-46464c8012cb - 3.66.176.252: 9ee92c19-5f78-4865-a287-980218963d96 - 3.66.25.100: aff05f79-7c69-4ecf-a827-5ea790a0fdc6