-
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?
Added initial version of dump-restore script. #380
Conversation
I tried to dump data in linux environment, but it didn't work for me. curl 7.61.1 (x86_64-redhat-linux-gnu) libcurl/7.61.1 OpenSSL/1.1.1k zlib/1.2.11 brotli/1.0.6 libidn2/2.2.0 libpsl/0.20.2 (+libidn2/2.2.0) libssh/0.9.6/openssl/zlib nghttp2/1.33.0 |
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 comment
The 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 comment
The 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.
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% |
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.
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 comment
The reason will be displayed to describe this comment to others. Learn more.
Check return code (should be 200, not 302)
If return code is 302 then most likely authorization failed.
I would also check size of returned file. It shouldn't be empty.
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 have added the necessary check, as you advised.
|
||
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 comment
The reason will be displayed to describe this comment to others. Learn more.
Check return code (should be 200, not 302)
If return code is 302 then most likely authorization failed.
I would also check size of returned file. It shouldn't be empty.
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 have added the necessary check, as you advised.
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 login/password escaping should be fixed.
We should also check if dump failed and print some messages to inform user.
I have improved the URL encoding and added necessary checks, as @litvinovg advised. |
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.
@ivanmrsulja can we apply similar approach as Tomcat is using with setenv.sh (setenv.bat) file, meaning dumpRestore.bat and dumpRestore.sh might be renamed to vivo-admin.bat and vivo-admin.sh, and there might be additional files example.setenv.sh and example.setenv.bat? All scripts parameters might be specified in those setenv.sh/bat files except action. The files might stay at the script directory in the VIVO code base, but can be copied to VIVO_HOME/bin by using this file - https://github.com/vivo-project/Vitro/blob/main/home/src/main/assembly/home.xml
…figuring functionality on linux.
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.
@ivanmrsulja it works for me (Windows 10). I have tried to create dump of content graph and to restore. Thanks for the contribution.
What's new?
This functionality was only available through UI in admin panel, now, it is available through .sh and .bat script so that it can be setup as cron job with minimal configuration.
How should this be tested?
If you are willing to use the script the server has to be running. The CLI arguments are as follows:
bash dumpRestore.sh <action>
Action can be:
dump
orrestore
For script to work, you have to configure parameters in setenv script. Because these parameters rarely change, I figured that someone can just edit few lines of the setenv script so that the command doesn't get cluttered with a lot of arguments:
Interested parties
@chenejac @milospp