cluster-file_transfer
Differences
This shows you the differences between two versions of the page.
| Both sides previous revisionPrevious revisionNext revision | Previous revision | ||
| cluster-file_transfer [2024/05/07 13:03] – gabriele | cluster-file_transfer [2026/09/03 12:58] (current) – gabriele | ||
|---|---|---|---|
| Line 4: | Line 4: | ||
| ====== Transferring files to/from psychp01 ====== | ====== Transferring files to/from psychp01 ====== | ||
| What's on this page:\\ | What's on this page:\\ | ||
| - | - Transferring data | + | - Transferring data internally (e.g., from your computer in the office) |
| + | - Transferring data externally (e.g., from a website or an external institution) | ||
| - Transferring code | - Transferring code | ||
| - File Transfer Clients | - File Transfer Clients | ||
| - | ===== Transferring data ===== | + | ===== 1. Transferring data internally |
| You need to upload your data into the folder that was created by the IT for you within the ''/ | You need to upload your data into the folder that was created by the IT for you within the ''/ | ||
| Line 17: | Line 18: | ||
| To know more about ''/ | To know more about ''/ | ||
| - | Please NOTE: theoretically, | + | Please NOTE: theoretically, |
| - | Transferring | + | ===== 2. Transferring |
| + | To transfer data from outside RHUL, you'd need to first move the data to a separate " | ||
| - | You can upload your scripts into a folder within your home directory on the cluster. The IT will have probably created | + | This " |
| - | / | ||
| - | Your folder name in the home directory has the same name as the username you use to access the cluster. This name was provided to you by the IT when you asked for access. Be aware that there might be deviations on how your folder name in the home directory has been created (especially if you were granted access to the cluster before 2024). If you have access to the cluster, just log in using ssh and type pwd to see your folder name in the home directory. Something like the line above will pop up on your command line. | + | ==== Example 1: ==== |
| - | The most secure way to transfer code is using File Transfer Clients | + | Suppose you need to download a dataset from a website that does not require a data sharing agreement and is a simple browser-based download, |
| + | - Open your remote desktop app. | ||
| + | - Enter the host name (the server " | ||
| + | - Enter your username: gabriele (for your it's the name Jonas gave you, most likely first letter of your name + your surname) | ||
| + | - Enter your password: **** (the one Jonas gave you to connect the first time, which need to be changed at first login) | ||
| + | - Once connected, click on the World icon on the bar at the bottom of the screen. This will open a Firefox webpage | ||
| + | - Search your dataset page like you'd do it normally on your browser | ||
| + | - Locate your dataset. | ||
| + | - If the size of your dataset is below 1TB, just click on the download link. The data will be stored in Downloads. | ||
| + | - If the dataset is bigger: | ||
| + | - In Firefox, open the menu (three lines, top right) and choose '' | ||
| + | - Stay on the '' | ||
| + | - There you'll see '' | ||
| + | - A new window opens titled '' | ||
| + | - On top of that window, you'll see two tabs, one with your username and a small house, and the other labelled '' | ||
| + | - On the left next to the tab with your username, click the back arrows. | ||
| + | - This opens a new tab with a square and circle within it. Click it. | ||
| + | - You'll then see a list of folders. Search for '' | ||
| + | - The change takes effect right away, no need to save or restart. | ||
| + | - Click on the download link and download it. | ||
| + | - Once downloaded, you can extract the files locally. Right-click and choose '' | ||
| + | - Choose your local folder where to extract the files. I suggest you create here the folder structure you'd like your data to have in ''/ | ||
| - | File Transfer Clients | + | From the graphics server you can't log into psychp01 directly, but the same storage is mounted read-only. You'll see a ''/ |
| - | Primary access to psychp01 is via ssh based tools (on the command line). To upload or download | + | Once you have downloaded all your data, created your folder structure |
| - | To transfer | + | == To move the data from the " |
| + | Suppose you have saved all your data on the " | ||
| + | - Establish an ssh connection with pyshcp01 via the terminal (see [[cluster-access# | ||
| + | - Establish an sftp connection with the " | ||
| + | sftp gabriele@134.219.34.200 | ||
| + | - You'll be prompted to enter your password. | ||
| + | - Move the data: | ||
| + | get -r / | ||
| + | |||
| + | The '' | ||
| - | psychp01.rhul.ac.uk | ||
| + | **WARNING** | ||
| + | Remember: the " | ||
| - | sftp | ||
| - | sftp, which stands for Secure File Transfer Protocol, is an encrypted protocol built into SSH that can implement commands for transferring files between two remote systems over a secure connection. There are many resources on the web on how to use sftp (e.g., here). Here, example applications to transfer data onto psychp01 will be shown. | ||
| - | First, you need to establish a secure connection with the server. This is very similar to how you would connect with the server using ssh (see here). | + | ==== Example 2: ==== |
| - | sftp username@psychp01.rhul.ac.uk | + | Suppose you need to download a dataset that **cannot** be downloaded by simply clicking a link in the browser, because it is hosted on a repository that uses '' |
| - | Like for the ssh connection, “username” is the username provided to you by the IT when you asked for access to the cluster. Hit enter and you will be required to enter your password. Once you are connected, | + | Repositories like GIN do not store the data in one downloadable archive. Instead, you first download a small " |
| - | sftp> | + | Everything below is done **on the " |
| - | Now, you can ftp commands to (among others) upload, download, remove, and move files. Type help to check all commands available. | + | == Before |
| - | sftp> help | + | Three things to know, because none of them are obvious and none of them are in GIN's own documentation: |
| - | The sftp connection puts you on the cluster. Here, you can use all common commands you would use on your local machine to get the current directory, change | + | * You **cannot** download this dataset over HTTPS. GIN serves |
| + | * The '' | ||
| + | * '' | ||
| - | For instance, when you establish an sftp connection, you will find yourself in your home directory. Hence, if your home directory path is / | + | == 1. Set your git identity == |
| - | sftp> pwd | + | '' |
| - | Remote working directory: / | + | |
| - | On the contrary, if you type lpwd, you will see the second line of the code below appearing: | + | <code> |
| + | git config --global user.name "Your Name" | ||
| + | git config --global user.email " | ||
| + | </ | ||
| - | sftp> lpwd | + | These are only labels written into your local copy. They are not checked against anything, and they do not give anyone access to anything. |
| - | Local working directory: /Users/Gab | + | |
| - | where /Users/Gab is my (local) current directory on my computer. Type help to see the difference in the commands for remote and local implementations. | + | == 2. Register a GIN account == |
| - | To download data from the cluster onto your local directory, you need to use the get command, like this: | + | This step is done in the browser (click on the World icon at the bottom of the screen to open Firefox). |
| - | sftp> get remote_filename_path local_dirpath | + | - Go to [[https:// |
| + | - Click '' | ||
| + | - Choose a username, enter your RHUL email and a password | ||
| + | - Confirm your account by clicking the link in the email you receive | ||
| - | For example, if you have to get a file called results_matrix.mat from the folder results in your home directory / | + | Registration is free and immediate; there is no approval process and no data sharing agreement for this dataset. |
| - | sftp> get / | + | == 3. Create an '' |
| - | Alternatively, you can cd to results (on the cluster), lcd to project_results (on your local machine), and then just type get results_matrix.mat, like this: | + | An '' |
| - | sftp> cd / | + | First check whether you already have one: |
| - | sftp> lcd / | + | |
| - | sftp> get results_matrix.mat | + | |
| - | NOTE: If you have folder names that contain spaces, sftp would fail. For instance, something like that: sftp> lcd /Users/Gab/project results, (i.e., your results folder named “project result” with a space) would not work! | + | <code> |
| + | ls ~/.ssh/id_*.pub | ||
| + | </ | ||
| - | If you have to download a folder, you will need to use the -r argument like that: | + | If nothing is listed, create one: |
| - | sftp> get -r remote_dirpath local_dirpath | + | <code> |
| + | ssh-keygen -t ed25519 -C " | ||
| + | </ | ||
| - | On the contrary, | + | Press Enter to accept |
| - | sftp> put local_filename_path remote_dirpath | + | Now print the **public** key (note the '' |
| - | In this video, you will see how to transfer a Python | + | <code> |
| + | cat ~/.ssh/ | ||
| + | </ | ||
| + | You will see a single long line starting with '' | ||
| + | Then, in the browser, logged into GIN: | ||
| + | - Click your avatar (top right) and choose '' | ||
| + | - Choose '' | ||
| + | - Click '' | ||
| + | - Give it a name, e.g. '' | ||
| + | - Paste the line into the '' | ||
| + | Check that it worked: | ||
| + | < | ||
| + | ssh -T git@gin.g-node.org | ||
| + | </ | ||
| + | The first time, you will be asked whether you trust the server. Type '' | ||
| + | < | ||
| + | Hi there, You've successfully authenticated, | ||
| + | </ | ||
| + | This message means **success**. GIN only allows '' | ||
| + | == 4. Choose where the data will go == | ||
| + | **Do not download into your home directory.** Use '' | ||
| + | Check the free space before you start: | ||
| + | < | ||
| + | df -h / | ||
| + | cd / | ||
| + | </ | ||
| + | Note that ''/ | ||
| + | == 5. Download the dataset skeleton == | ||
| + | < | ||
| + | git clone git@gin.g-node.org:/ | ||
| + | cd WAND | ||
| + | git annex init " | ||
| + | </ | ||
| + | **Note the slash** immediately after the colon, before '' | ||
| + | This step is quick and small. You now have the complete folder structure with the real file names, all the metadata files ('' | ||
| + | You can check the overall picture with: | ||
| - | scp | + | < |
| + | git annex info | ||
| + | </ | ||
| - | scp (secure copy) is a command-line utility that allows you to securely copy files and directories between two locations. scp use requires a password, and both the files and password are encrypted so as to securely transfer data from one location to the other. scp uses the ssh protocol for both authentication and encryption. See here for my information. | + | which reports the total size of the dataset, how much you currently have locally |
| - | When transferring data, scp takes on two main arguments: | + | == 6. Check how big your request is, before downloading == |
| - | scp source destination | + | '' |
| - | The first argument is the address of the source file to transfer, the second the address where it has to be transferred to. A good way to memorize it is to think that scp needs to know what to send where to. | + | < |
| + | for s in 02 03 06; do | ||
| + | printf " | ||
| + | git annex find sub-*/ | ||
| + | | awk ' | ||
| + | done | ||
| + | </ | ||
| - | For example, to transfer files from the remote cluster (source) | + | Change |
| - | scp username@address_name: | + | == 7. Download the data you need == |
| - | Suppose my username (the one given to you by the IT when you got access to the cluster) is gbellucci, the filename of the file (e.g., | + | Always test with a single participant first, so you can see how much one subject costs: |
| - | To transfer files from your local machine to the remote cluster, use: | + | |
| - | scp <space> pathname_local_src | + | <code> |
| + | git annex get sub-00395/ | ||
| + | du -sh . | ||
| + | </code> | ||
| - | Suppose | + | Then start the real download. Use '' |
| - | scp /Users/Gab/ | + | < |
| + | screen -S wand | ||
| + | git annex get -J4 sub-*/ses-0{2, | ||
| + | </code> | ||
| - | Remember, your data will not be in your folder | + | '' |
| - | scp / | + | If the transfer is interrupted, |
| - | If you have to upload or download multiple files or a file that contains multiple file (e.g., a folder), now you’ll have a directory path (and not a file path), and you can use the -r argument to reiterate the sending over all files like that: | + | You will see error messages for participants who do not have a given session. This is normal: not every volunteer took part in every session |
| - | scp -r dirpath_local_src username@psychp01.rhul.ac.uk:dirpath_remote_dest | + | To download only some participants, |
| - | For example, if your directory path is to the folder called analyses_folder, you can type the following: | + | < |
| + | while read s; do | ||
| + | git annex get -J4 " | ||
| + | done < subjects.txt | ||
| + | </ | ||
| - | scp -r / | + | == 8. Move the data onto psychp01 |
| - | If you have a whole data folder | + | Once the download is finished and you are happy with your folder structure, move the data to '' |
| - | scp -r / | + | Note that the downloaded dataset contains a hidden '' |
| - | You would swap the two arguments if the folder is on the cluster, and you would need to get it onto your local computer: | + | == Structure of the WAND dataset == |
| - | scp -r username@psychp01.rhul.ac.uk:dirpath_remote_src dirpath_local_dest | + | The data follow the [[https:// |
| - | For example, if your directory path is to the folder on the cluster called results_folder that you need to download into your analyses_folder on your local computer, you can type the following: | + | ^ Session ^ Content ^ |
| + | | ses-01 | MEG (CTF '' | ||
| + | | ses-02 | Connectom 3 T, ultra-strong gradients: diffusion and quantitative MRI | | ||
| + | | ses-03 | Prisma 3 T: structural, functional, perfusion | | ||
| + | | ses-04 | 7 T spectroscopy | | ||
| + | | ses-05 | 3 T GABA-edited spectroscopy (MEGA-PRESS) | | ||
| + | | ses-06 | 7 T structural and functional | | ||
| + | | ses-07 | 3 T metabolic (subset, about 39 participants) | | ||
| + | | ses-08 | TMS (subset, about 40 participants) | | ||
| - | scp -r gbellucci@psychp01.rhul.ac.uk:/ | + | '' |
| - | rsync | + | == Common pitfalls == |
| - | rsync, which stands for remote sync, is a remote | + | * **The files look like they are already there, but they are not.** After cloning, you can see and browse every file name, including |
| + | * **Never run '' | ||
| + | * **The download links on the GIN wiki are dead.** The '' | ||
| + | * **Remember the warning above**: the " | ||
| - | sshfs | ||
| - | sshfs allows you to mount the file system on your local machine. See here for more details. Basic usage for Linux users: | ||
| - | sshfs username@psychp01.rhul.ac.uk:dirpath mountpoint [options] | + | ===== 3. Transferring code ===== |
| + | You can upload your scripts into a folder within your home directory on the cluster. The IT will have probably created a folder in the home directory with the first letter of your name preceding your surname (e.g., '' | ||
| + | / | ||
| - | FileZilla | + | Your folder name in the home directory has the same name as the username you use to access the cluster. This name was provided to you by the IT when you asked for access. Be aware that there might be deviations on how your folder name in the home directory has been created (especially if you were granted access to the cluster before 2024). If you have access to the cluster, just log in using '' |
| - | FileZilla | + | The most secure way to transfer code is using File Transfer |
| - | ExpanDrive | + | ===== 4. File Transfer Clients ===== |
| + | Primary access to psychp01 is via ssh based tools (on the command line). To upload or download data and code, File Transfer Clients such as '' | ||
| - | An alternative to File Transfer Clients like the one mentioned above is ExpanDrive. ExpanDrive is a network filesystem client for MacOS, Microsoft Windows and Linux that facilitates mapping of local volume to many different types of cloud storage. It is different from the above File Transfer Clients because it is integrated into all applications on the operating system and does not require a file to be downloaded onto the local machine. On the contrary, remote files can be accessed, managed and changed as if they were stored locally. | + | To transfer data to and from psychp01 use the following address: |
| + | |||
| + | psychp01.rhul.ac.uk | ||
| + | |||
| + | |||
| + | ==== SFTP ==== | ||
| + | '' | ||
| + | First, you need to establish a secure connection with the server. This is very similar to how you would connect with the server using '' | ||
| + | |||
| + | sftp username@psychp01.rhul.ac.uk | ||
| + | |||
| + | Like for the ssh connection, “username” is the username provided to you by the IT when you asked for access to the cluster. Hit enter and you will be required to enter your password. Once you are connected, at the beginning of your command line, you will see that an connection has been established: | ||
| + | |||
| + | sftp> | ||
| + | |||
| + | Now, you can use '' | ||
| + | |||
| + | sftp> help | ||
| + | |||
| + | The '' | ||
| + | For instance, when you establish an '' | ||
| + | |||
| + | sftp> pwd | ||
| + | Remote working directory: / | ||
| + | |||
| + | On the contrary, if you type '' | ||
| + | |||
| + | sftp> lpwd | ||
| + | Local working directory: / | ||
| + | |||
| + | where ''/ | ||
| + | |||
| + | To download data from the cluster onto your local directory, you need to use the '' | ||
| + | |||
| + | sftp> get remote_filename_path local_dirpath | ||
| + | |||
| + | For example, if you have to get a file called '' | ||
| + | |||
| + | sftp> get / | ||
| + | |||
| + | Alternatively, | ||
| + | |||
| + | sftp> cd / | ||
| + | sftp> lcd / | ||
| + | sftp> get results_matrix.mat | ||
| + | |||
| + | __NOTE__: If you have folder names that contain spaces, '' | ||
| + | If you have to download a folder, you will need to use the '' | ||
| + | |||
| + | sftp> get -r remote_dirpath local_dirpath | ||
| + | |||
| + | On the contrary, if you have to upload data from your local machine to the cluster, you will need to use the put command: | ||
| + | |||
| + | sftp> put local_filename_path remote_dirpath | ||
| + | |||
| + | In the video on page 20 of the pdf file on the [[cluster-guide|main page]], you will see how to transfer a Python code and a bash file to psychp01 using '' | ||
| + | |||
| + | |||
| + | ==== SCP ==== | ||
| + | '' | ||
| + | |||
| + | When transferring data, '' | ||
| + | |||
| + | scp source destination | ||
| + | |||
| + | The first argument is the address of the source file to transfer, the second the address where it has to be transferred to. A good way to memorize it is to think that '' | ||
| + | For example, to transfer files from the remote cluster (source) to your local machine (destination), | ||
| + | |||
| + | scp username@address_name: | ||
| + | |||
| + | To transfer files from your local machine (source) to the remote cluster (destination), | ||
| + | |||
| + | scp pathname_local_src username@address_name: | ||
| + | |||
| + | Suppose my username (the one given to you by the IT when you got access to the cluster) is '' | ||
| + | |||
| + | scp / | ||
| + | |||
| + | Remember, your data will not be in your folder in the home directory but in your '' | ||
| + | |||
| + | scp / | ||
| + | |||
| + | If you have to upload or download multiple files or a file that contains multiple file (e.g., a folder), now you’ll have a directory path (and not a file path), and you can use the '' | ||
| + | |||
| + | scp -r dirpath_local_src username@psychp01.rhul.ac.uk: | ||
| + | |||
| + | For example, if your directory path is to the folder called '' | ||
| + | |||
| + | scp -r / | ||
| + | |||
| + | If you have a whole data folder to transfer, you will upload it into your ''/ | ||
| + | |||
| + | scp -r / | ||
| + | |||
| + | You would swap the two arguments if the folder is on the cluster, and you would need to get it onto your local computer: | ||
| + | |||
| + | scp -r username@psychp01.rhul.ac.uk: | ||
| + | |||
| + | For example, if your directory path is to the folder on the cluster called '' | ||
| + | |||
| + | scp -r gbellucci@psychp01.rhul.ac.uk:/ | ||
| + | |||
| + | |||
| + | ==== RSYNC ==== | ||
| + | '' | ||
| + | |||
| + | |||
| + | |||
| + | ==== SSHFS ==== | ||
| + | '' | ||
| + | |||
| + | sshfs username@psychp01.rhul.ac.uk: | ||
| + | |||
| + | |||
| + | ==== FileZilla ==== | ||
| + | '' | ||
| + | |||
| + | |||
| + | ==== ExpanDrive ==== | ||
| + | An alternative to File Transfer Clients like the one mentioned above is [[https:// | ||
| The downside is that it is a non-free commercial tool. | The downside is that it is a non-free commercial tool. | ||
| + | [[{: | ||
| + | [[{: | ||
| + | |||
| + | |||
| + | ~~DISCUSSION|Discussion~~ | ||
cluster-file_transfer.1715087034.txt.gz · Last modified: 2024/05/07 13:03 by gabriele