Hello Community,
im trying to automate a simple xar backup to transfer some pages to a offline backup xwiki instance.
Im using this to authenticate which works:
‘wget ‘https://user:password@hostname.com.donotresolve/xwiki/bin/view/Main/WebHome?basicauth=1’’
Doing the backup works with:
‘https://hostname.com.donotresolve/xwiki/bin/export/Space/Page?format=xar&pages=PAGE.%25’
I tried both togehter with:
wget ‘https://user:password@hostname.org/xwiki/bin/export/Space/Page?basicauth=1&format=xar&pages=PAGE.%25’ -O export.xar
which doesnt work.
Any idea how to combine basic auth with the export url?
Thank you
i figured it out:
Login to xwiki
curl -k -b cookies.txt -c cookies.txt -d
“j_username=xwiki_backup_user &j_password= xwiki_backup_user_password
&j_rememberme=true&submit=Log-in” “https:// xwiki_backup_server
:443/xwiki/bin/loginsubmit/XWiki/XWikiLogin”
download the xar:
curl -k --output "xwiki_backup_file "
-b cookies.txt -c cookies.txt "https:// xwiki_backup_server
/xwiki/bin/export/Space/Page?format=xar&pages=xwiki_backup_page "
1 Like
if somebody needs that in ansible, heres a simple playbook which does the login and stores the xar export
- name: Backup xWiki
hosts: localhost
gather_facts: true
vars_files:
-
“vars/main.yml”
tasks:
-
name: Login to Xwiki
ansible.builtin.uri:
url: “https://{{ xwiki_backup_server }}/xwiki/bin/loginsubmit/XWiki/XWikiLogin”
method: POST
url_password: “{{ xwiki_backup_user_password }}”
url_username: “{{ xwiki_backup_user }}”
status_code: 302
validate_certs: false
body_format: form-urlencoded
force_basic_auth: true
return_content: true
register: login
-
name: Download and store export
ansible.builtin.uri:
url: “https://{{ xwiki_backup_server }}/xwiki/bin/export/Space/Page?format=xar&pages={{ xwiki_backup_page }}”
method: GET
return_content: true
validate_certs: false
force_basic_auth: true
headers:
Cookie: “{{ login.set_cookie }}”
dest: ./
…