From 171e9dfee11c287a2e07e2730cdf92cc797e2cec Mon Sep 17 00:00:00 2001 From: Markus Kahl Date: Wed, 28 Dec 2022 13:56:33 +0100 Subject: [PATCH] script for uploading backups to OpenProject directly on server via curl --- .../enterprise-cloud-faq/README.md | 3 ++ .../enterprise-cloud-faq/op-file-upload.sh | 46 +++++++++++++++++++ 2 files changed, 49 insertions(+) create mode 100644 docs/enterprise-guide/enterprise-cloud-guide/enterprise-cloud-faq/op-file-upload.sh diff --git a/docs/enterprise-guide/enterprise-cloud-guide/enterprise-cloud-faq/README.md b/docs/enterprise-guide/enterprise-cloud-guide/enterprise-cloud-faq/README.md index e09d9e6aa1f..d6783942b83 100644 --- a/docs/enterprise-guide/enterprise-cloud-guide/enterprise-cloud-faq/README.md +++ b/docs/enterprise-guide/enterprise-cloud-guide/enterprise-cloud-faq/README.md @@ -68,8 +68,11 @@ To import your community instance into our cloud environment, please send us the For a package-based installation, you can create both as root user on your environment as follows: `openproject run backup` This creates the attachment and PostgreSQL-dump or MySQL-dump under /var/db/openproject/backup. If you are still running OpenProject under MySQL, your dump will be converted to PostgreSQL before importing, we will do this for you. More information about the backup tool can be found [here](../../../installation-and-operations/operation/backing-up/). + Please upload these documents as an attachment to a work package within your new OpenProject Enterprise cloud environment and send us the link to this work package via email. +If you are having trouble accessing the files on your server with your browser, you can upload them directly from the server using [this script](./op-file-upload.sh). Simply download it and run it (`bash op-file-upload.sh`) to find out more. + ## How can I export the documents loaded on OpenProject? Currently, there is unfortunately no option to export all the documents in OpenProject at once. We could manually export the entire database (including the attachments) for you. Due to the manual effort, we would however need to charge a service fee for this. Please contact sales@openproject.com. diff --git a/docs/enterprise-guide/enterprise-cloud-guide/enterprise-cloud-faq/op-file-upload.sh b/docs/enterprise-guide/enterprise-cloud-guide/enterprise-cloud-faq/op-file-upload.sh new file mode 100644 index 00000000000..1facd873dee --- /dev/null +++ b/docs/enterprise-guide/enterprise-cloud-guide/enterprise-cloud-faq/op-file-upload.sh @@ -0,0 +1,46 @@ +#!/bin/bash + +DOMAIN=$1 +API_KEY=$2 +WP_ID=$3 +FILE_PATH=$4 + +if [ -z "$DOMAIN" ] || [ -z "$API_KEY" ] || [ -z "$WP_ID" ] || [ -z "FILE_PATH" ]; then + echo + echo "Usage: " + echo + echo " bash op-file-upload.sh " + echo + echo "Example: " + echo + echo " bash op-file-upload.sh my.openproject.com 1d58c380e10b211b9535f47e1fd8c34fa2a93187c87b3561dc33454888cca882 1141 /home/me/Pictures/logo.png" + echo + echo "This will upload the file 'logo.png' as an attachment to the work package with the ID 1141." + echo "You have to create the work package beforehand using your browser (e.g. https://my.openproject.com/work_packages/new)" + echo + echo "You can create an API key on the OpenProject console (\`sudo openproject run console\`) like this: " + echo + echo " puts Token::API.create!(user: User.find_by(login: 'm.user@openproject.com')).plain_value; exit" + echo + echo "Where \"m.user@openproject.com\" would be your user's login in your OpenProject environment." + echo "Alternatively you can simply create the API key using your browser under My Account -> Access Tokens -> API." + + exit 1 +fi + +if [ ! -f "$FILE_PATH" ]; then + echo "Could not find file '$FILE_PATH'" + exit 1 +fi + +FILE_NAME=`basename $FILE_PATH` +CONTENT_TYPE=`file --mime-type $FILE_PATH | cut -d: -f2 | tr -d ' '` + +curl "https://$DOMAIN/api/v3/work_packages/$WP_ID/attachments" \ + -u "apikey:$API_KEY" \ + -H 'accept: application/json, text/plain, */*' \ + -F "metadata={\"fileName\":\"$FILE_NAME\",\"contentType\":\"$CONTENT_TYPE\"}" \ + -F "file=@$FILE_PATH" \ + > .op-file-upload-output.json + +cat .op-file-upload-output.json