Rake tasks for importing and exporting users from csv files on Shares

IN THIS ARTICLE:

Rake tasks are scripts that allow you to retrieve, delete or update information on your Shares server using the command line. Rake tasks can perform actions on user accounts, shares and nodes. This article describes the rake tasks available for importing users into Shares from a csv file. For more general information on Shares rake tasks see this article (Shares rake tasks).

Importing users from a csv file

The syntax for the rake task is the following:

Rake tasks must be run from within the appropriate location in the shares folder:
  • Linux Shares 1.8 and later: /opt/aspera/shares/u/shares/bin
  • Linux Shares earlier than 1.8: /opt/aspera/shares/u/shares
  • Windows: C:\Shares\www
Windows
rake data:user:import -- [options]

Linux Shares 1.8+
./run rake data:user:import -- [options]

Linux Shares earlier than 1.8
bundle exec rake data:user:import -- [options]

The available options are the following:

option description                                                                                      
--path Path of the csv file users will be exported to (required).


The CSV file must have the information for each user per line in the following format:

Username, Email, First Name, Last Name, Password
Note that if you do not provide a password for your users, they will be assigned a randomly generated password and will need to reset it with the “Forgot Password” link at the log in screen.

Example

To create 2 new users janedoe and rhagrid, we create a text file called new_users.txt with the following contents:

janedoe Jane Doe jane@example.com s3cret123!
rhagrid Rubeus Hagrid rh@example.com unkn0wn543!

Then we run the rake command and pass in the path to the new_users.csv file:

rake data:user:import -- --path /tmp/new_users.csv

Exporting users to a csv file

The syntax for the rake task is the following:

Rake tasks must be run from within the appropriate location in the shares folder:
  • Linux Shares 1.8 and later: /opt/aspera/shares/u/shares/bin
  • Linux Shares earlier than 1.8: /opt/aspera/shares/u/shares
  • Windows: C:\Shares\www
Windows
rake data:user:export -- [options]

Shares 1.8+
./run rake data:user:export -- [options]

Shares earlier than 1.8
bundle exec rake data:user:export -- [options]

The available options are the following:

option description                                                                                      
--path Path of the csv file users will be exported to (required).
Note that the rake task will not export user passwords to the csv file. You will have to manually input them should you need them.

Example

To export users to the file /tmp/users_2015.csv, you would use the following:

rake data:user:export -- --path /tmp/users_2015.csv
Have more questions? Submit a request

0 Comments

Article is closed for comments.
Powered by Zendesk