-
Notifications
You must be signed in to change notification settings - Fork 85
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Added initial version of dump-restore script. #380
base: jena4-upgrade
Are you sure you want to change the base?
Changes from 5 commits
0f8df35
d6c514d
a9ede4c
399bd18
06578b4
daee759
9b498fb
6772b47
6748039
cfe9d48
5581fd3
d3d8126
3fbcb57
f095b44
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
@echo off | ||
|
||
set action=%1% | ||
set models=%2% | ||
set email=%3% | ||
set password=%4% | ||
|
||
set host=http://example:port | ||
set purge=true | ||
set restoration_files_path=. | ||
set dumped_files_path=%restoration_files_path% | ||
set app_name=vivo | ||
|
||
set session=%TEMP%\%RANDOM% | ||
mkdir "%session%" | ||
|
||
set url=%host%/%app_name%/authenticate | ||
|
||
set loginName=%email% | ||
set loginPassword=%password% | ||
set loginForm=Log in | ||
|
||
:: Log in and get session cookies | ||
curl --cookie-jar "%session%\cookies.txt" --create-dirs -d "loginName=%loginName%" -d "loginPassword=%loginPassword%" -d "loginForm=%loginForm%" %url% | ||
|
||
if "%action%" == "dump" ( | ||
echo Starting dump... | ||
|
||
curl --cookie "%session%\cookies.txt" "%host%/%app_name%/dumpRestore/dump/%models%.nq?which=%models%" -o "%dumped_files_path%\%models%.nq" | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Check return code (should be 200, not 302) There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I have added the necessary check, as you advised. |
||
|
||
echo Completed successfully. | ||
) else if "%action%" == "restore" ( | ||
echo Starting restoration process... | ||
|
||
set url=%host%/%app_name%/dumpRestore/restore | ||
|
||
curl --cookie "%session%\cookies.txt" -X POST -F "sourceFile=@%restoration_files_path%\%models%.nq" "%url%?which=%models%&purge=%purge%" > nul | ||
|
||
if %errorlevel% equ 0 ( | ||
echo Restored successfully. | ||
) else ( | ||
echo Something went wrong. | ||
) | ||
) | ||
|
||
rmdir /s /q "%session%" |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
#!/bin/bash | ||
|
||
action="$1" | ||
models="$2" | ||
email="$3" | ||
password="$4" | ||
|
||
host="http://example:port" # URL where the VIVO instance is hosted | ||
purge="true" # Will the restoration process purge the models before restoring | ||
restoration_files_path="." # Directory containing the files used for restoration | ||
dumped_files_path=$restoration_files_path # Directory containing the backed-up files | ||
app_name="vivo" # app-name parameter | ||
|
||
session=$(mktemp -d) | ||
|
||
url="$host/$app_name/authenticate" | ||
|
||
loginName="$email" | ||
loginPassword="$password" | ||
loginForm="Log in" | ||
|
||
# Log in and get session cookies | ||
curl --cookie-jar "$session/cookies.txt" -d "loginName=$loginName" -d "loginPassword=$loginPassword" -d "loginForm=$loginForm" $url | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think it should be --data-urlencode for login and password instead of -d as with -d "+" sign is interpreted as a space character There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I have improved URL encoding as you advised, thank you for debugging the problem for me. |
||
|
||
if [[ "$action" == "dump" ]]; then | ||
echo "Starting dump..." | ||
curl --cookie "$session/cookies.txt" "$host/$app_name/dumpRestore/dump/$models.nq?which=$models" -o "$dumped_files_path/$models.nq" | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Check return code (should be 200, not 302) There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I have added the necessary check, as you advised. |
||
echo "Completed successfully." | ||
elif [[ "$action" == "restore" ]]; then | ||
echo "Starting restoration process..." | ||
|
||
url="$host/$app_name/dumpRestore/restore" | ||
files=$(echo -n "$restoration_files_path/$models.nq") | ||
params=$(echo -n "which=$models&purge=$purge") | ||
|
||
curl --cookie "$session/cookies.txt" -X POST -F "sourceFile=@$files" "$url?$params" > /dev/null | ||
|
||
if [[ $? -eq 0 ]]; then | ||
echo "Restored successfully." | ||
else | ||
echo "Something went wrong." | ||
fi | ||
fi | ||
|
||
rm -rf "$session" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think if you try to use login with + sign it wouldn't work here too. See comment below.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It is still -d here. I haven't tested it on Windows, but maybe we should also use --data-urlencode here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You are right, I forgot to add it here for username and password. I will change it right now.