feat(ai-workspace): add backup/restore/migration role and playbook
This commit is contained in:
parent
b36a1c44e5
commit
1ac560e482
11
roles/vhosts/ai-workspace/defaults/main.yml
Normal file
11
roles/vhosts/ai-workspace/defaults/main.yml
Normal file
@ -0,0 +1,11 @@
|
||||
---
|
||||
# Backup/Restore/Migration Defaults
|
||||
migrate_source_host: "{{ ansible_host | default('localhost') }}"
|
||||
migrate_source_user: "ubuntu"
|
||||
migrate_litellm_db: "litellm"
|
||||
migrate_litellm_db_user: "litellm"
|
||||
migrate_litellm_db_host: "127.0.0.1"
|
||||
|
||||
# Migration paths
|
||||
openclaw_data_dir: "~/.openclaw"
|
||||
xworkspace_state_dir: "~/.local/state/xworkspace"
|
||||
7
roles/vhosts/ai-workspace/meta/main.yml
Normal file
7
roles/vhosts/ai-workspace/meta/main.yml
Normal file
@ -0,0 +1,7 @@
|
||||
---
|
||||
dependencies:
|
||||
- role: roles/agent_skills
|
||||
- role: roles/vhosts/gateway_openclaw
|
||||
- role: roles/vhosts/xworkmate_bridge
|
||||
- role: roles/vhosts/acp_server_hermes
|
||||
- role: roles/vhosts/qmd
|
||||
48
roles/vhosts/ai-workspace/tasks/migrate.yml
Normal file
48
roles/vhosts/ai-workspace/tasks/migrate.yml
Normal file
@ -0,0 +1,48 @@
|
||||
---
|
||||
- name: Ensure local data directories exist
|
||||
ansible.builtin.file:
|
||||
path: "{{ item }}"
|
||||
state: directory
|
||||
mode: '0755'
|
||||
loop:
|
||||
- "{{ openclaw_data_dir }}/plugin-skills"
|
||||
- "{{ openclaw_data_dir }}/skill-workshop"
|
||||
- "{{ openclaw_data_dir }}/agents/main/sessions"
|
||||
|
||||
- name: Sync skills and plugins
|
||||
ansible.posix.synchronize:
|
||||
src: "{{ migrate_source_user }}@{{ migrate_source_host }}:{{ item }}"
|
||||
dest: "{{ item | dirname }}/"
|
||||
mode: pull
|
||||
archive: yes
|
||||
checksum: yes
|
||||
use_ssh_args: yes
|
||||
loop:
|
||||
- "{{ openclaw_data_dir }}/plugin-skills/"
|
||||
- "{{ openclaw_data_dir }}/skill-workshop/"
|
||||
|
||||
- name: Sync temporary sessions
|
||||
ansible.posix.synchronize:
|
||||
src: "{{ migrate_source_user }}@{{ migrate_source_host }}:{{ openclaw_data_dir }}/agents/main/sessions/"
|
||||
dest: "{{ openclaw_data_dir }}/agents/main/sessions/"
|
||||
mode: pull
|
||||
archive: yes
|
||||
checksum: yes
|
||||
use_ssh_args: yes
|
||||
|
||||
- name: Migrate QMD memory (merge)
|
||||
ansible.builtin.command: >
|
||||
qmd sync --host {{ migrate_source_user }}@{{ migrate_source_host }}
|
||||
--remote-qmd-user {{ migrate_source_user }} --update --embed
|
||||
register: qmd_sync_result
|
||||
changed_when: "'Sync completed' in qmd_sync_result.stdout or qmd_sync_result.rc == 0"
|
||||
ignore_errors: yes
|
||||
|
||||
- name: Migrate LiteLLM database
|
||||
ansible.builtin.shell: >
|
||||
ssh -o StrictHostKeyChecking=no {{ migrate_source_user }}@{{ migrate_source_host }}
|
||||
"pg_dump -U {{ migrate_litellm_db_user }} -h {{ migrate_litellm_db_host }} -Fc {{ migrate_litellm_db }}" |
|
||||
pg_restore -U {{ migrate_litellm_db_user }} -h {{ migrate_litellm_db_host }} -d {{ migrate_litellm_db }} -1 --clean
|
||||
register: pg_migrate_result
|
||||
changed_when: pg_migrate_result.rc == 0
|
||||
ignore_errors: yes
|
||||
11
setup-ai-workspace-migration.yml
Normal file
11
setup-ai-workspace-migration.yml
Normal file
@ -0,0 +1,11 @@
|
||||
---
|
||||
- name: Migrate AI Workspace Data
|
||||
hosts: localhost
|
||||
connection: local
|
||||
become: no
|
||||
gather_facts: false
|
||||
tasks:
|
||||
- name: Run AI Workspace Migration Tasks
|
||||
ansible.builtin.include_role:
|
||||
name: roles/vhosts/ai-workspace
|
||||
tasks_from: migrate.yml
|
||||
Loading…
Reference in New Issue
Block a user