vicalloy / outline-docker-compose

Install a self-hosted Outline wiki instance in a couple of minutes
BSD 3-Clause "New" or "Revised" License
738 stars 120 forks source link

Backing up data? #77

Closed greglg45 closed 5 months ago

greglg45 commented 6 months ago

Thanks for this handy script. can you give us the procedure to save correctly the data of the outline application pls.

Have Fun

stanrc85 commented 5 months ago

I wrote up this script (borrowed mostly from another user) to create exports in both JSON and md file formats and download them with the API. Generate a bearer token in the app and then add it to a ".bearer" file in the same directory

bearer=$(cat "$input")

url="outline.url"

printf "Create exports\n"
generate_md=$(curl -s -X POST -H "authorization: Bearer $bearer" -H "content-type: application/json" -H "accept: application/json" -d '{"format": "outline-markdown"}' https://$url/api/collections.export_all)
generate_json=$(curl -s -X POST -H "authorization: Bearer $bearer" -H "content-type: application/json" -H "accept: application/json" -d '{"format": "json"}' https://$url/api/collections.export_all)

printf "Pull IDs\n"
md_id=$(echo "$generate_md" | jq -r '.data.fileOperation.id')
json_id=$(echo "$generate_json" | jq -r '.data.fileOperation.id')

printf "Wait"
for i in {1..10}; do
    printf "."
    sleep 30
done
printf "\nDownload exports"
curl -L -o markdown-export.zip -X GET -H "authorization: Bearer $bearer" -H "content-type: application/json" "https://$url/api/fileOperations.redirect?id=$md_id"
curl -L -o json-export.zip -X GET -H "authorization: Bearer $bearer" -H "content-type: application/json" "https://$url/api/fileOperations.redirect?id=$json_id"
greglg45 commented 5 months ago

very nice ! thansks