Skip to content

Commit

Permalink
Merge branch 'master' of https://github.com/rspace-os/rspace-cli
Browse files Browse the repository at this point in the history
  • Loading branch information
otter606 committed Jul 12, 2021
2 parents f8ce66a + 6f4a83b commit 2b5b588
Showing 1 changed file with 33 additions and 1 deletion.
34 changes: 33 additions & 1 deletion docs/Cookbook.md
Original file line number Diff line number Diff line change
Expand Up @@ -206,4 +206,36 @@ rspace eln export 123 --scope user --wait -f quiet | \
xargs -I jobId rspace eln job jobId --download
```

This latter command could be used as an input to `cron`. What you do from here is up to you - send to a long-term archive or repository, send to collaborators etc.
This latter command could be used as an input to `cron`. What you do from here is up to you - send to a long-term archive or repository, send to collaborators etc.

## 8. Exporting many users's work

### Scenario

You have many users' work to export, perhaps to transfer to an archive or to transfer from another RSpace server

### Solution

First of all get the usernames and ids of user:

./rscli eln listUsers --maxResults 100 -f csv | grep -v '-' | cut -d ',' -f1,2 > users.csv

This gets users, filters out the relevant fields and saves them in a CSV file. (Note there is a limit of 100 users currently).

Now iterate over this list, export and download:

```
logFile=$(date "+%d-%m-%y-%T").log
outfileDir=/media/rspace/exports
echo "Logging progress to $logFile"
while read person; do
id=$(echo $person | awk -F "," '{print $1}')
user=$(echo $person | awk -F "," '{print $2}')
echo "exporting $user"
echo "exporting $user" >> $logFile
jobid=$(./rscli eln export $id --scope user --format xml --wait | tail -n +2 | cut -f1)
echo "downloading export from jobID $jobid"
./rscli eln job $jobid --download --outfile ${outfileDir}/${user}.zip
done < users.csv
echo "Completed"

0 comments on commit 2b5b588

Please sign in to comment.