Added initial version of dump-restore script.#380
Added initial version of dump-restore script.#380ivanmrsulja wants to merge 14 commits intovivo-project:jena4-upgradefrom
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.
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.
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.
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.
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.
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.
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.
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.
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.
I have added the necessary check, as you advised.
litvinovg
left a comment
There was a problem hiding this comment.
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. |
chenejac
left a comment
There was a problem hiding this comment.
@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.
chenejac
left a comment
There was a problem hiding this comment.
@ivanmrsulja it works for me (Windows 10). I have tried to create dump of content graph and to restore. Thanks for the contribution.
|
In case this is accepted, this solution should be included in https://wiki.lyrasis.org/display/VIVODOC115x/Backup+and+Restore, right? |
Right. This PR will be considered to be merged once jena is upgraded to 5 (or at least 4), hopefully in VIVO 1.16.x |
bkampe
left a comment
There was a problem hiding this comment.
Installed and tested. Works like expected.
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:
dumporrestoreFor 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