# Transfer files to/from Curnagl

There are two main optinos to transfer data to/from Curnagl:

1. If you are familiar with the terminal use: `scp` command
2. If you are familiar with graphich interfaces, use: FileZilla

## `scp` command

`scp <FILE_TO_COPY> <FOLDER_WHERE_YOU_PASTE_IT>`

`scp –r <FOLDER_TO_COPY> <FOLDER_WHERE_YOU_PASTE_IT>`

The latter command refers to a folder transfer. To transfer a folder, add the recursive option `–r` after `scp`. 


### From your own computer to the cluster

Nothing better than an example to understand this command. Suppose you have a file (of any type) called tutorial on your own computer. Here are the steps to copy this file to Curnagl cluster:

1. Open a first terminal:
     - Linux: open a terminal in the folder where is the file tutorial , or open a terminal and then use `cd` command to go to the right place.
     - Mac:  type terminal in the search field, choose 'terminal', then use cd command to go to the right place.
     - Windows: type cmd in the menu, choose Command prompt or Powershell, then use cd command to go to the right place.

2. Open a second terminal. Connect to Curnagl with the  `ssh` command you are used to.


> This step is not mandatory but it allows you to get the path where you want to paste tutorial. One tip: in case the path where you want to paste tutorial is very long (e.g. `/users/<username>/<project>/<sub_project>/<sub_sub_project>/<sub_sub_sub_project>`) or simply to avoid mistakes when writting the path: use `pwd` command in the right folder on this second terminal connected to Curnagl, copy the whole path and paste it to the end of the `scp` command (see below).

Open two shell interfaces/terminals: first one where the current path is on your own/local laptop, the second one where you are logged on Curnagl frontend.

3. Let's copy/paste `tutorial` file to `/users/<username>/<project>` on Curnagl, with `<username>` as your personal username and `<project>` as the directory where `tutorial`should be pasted. On the first terminal, with your working directory being the one where `tutorial` is located, run the following command (it will ask for your password):
   
```bash
scp tutorial <username>@curnagl.dcsr.unil.ch:/users/<username>/<project>`
```

> You can check either the copy/paste performed well or not: use `ls` command on Curnagl and check either if tutorial file is there or not.


### From the cluster to your own computer

Only step 3 changes:

```bash
scp <username>@curnagl.dcsr.unil.ch:/users/<username>/<project>/tutorial .
```
> In case you do not want to paste it in the current folder (that is for what . stands for at the end of the above command line), simply replace . with the correct path.

## Second option: Filezilla

First, you must install FileZilla on your computer. Please refer to: https://filezilla-project.org/ (install client version, more documentation on https://wiki.filezilla-project.org/Client_Installation). 

Here are the steps to transfer data to/from Curnagl with FileZilla:

1. Open FileZilla. Performa a quick connection to Curnagl. Fill in `Host` with:sftp://curnagl.dcsr.unil.ch
<a href="https://wiki.unil.ch/ci/uploads/images/gallery/2023-05/filezilla-sftp-1.png" target="_blank" rel="noopener"><img src="https://wiki.unil.ch/ci/uploads/images/gallery/2023-05/scaled-1680-/filezilla-sftp-1.png" alt="filezilla_sftp_1.png"></a></span></span></span></li>
2. Then fill in `Username`, `Password`, and `Port` with 22. Click on `Quickconnect`. Refer to the screeshot below.
<a href="https://wiki.unil.ch/ci/uploads/images/gallery/2023-05/filezilla-sftp-2.png" target="_blank" rel="noopener"><img src="https://wiki.unil.ch/ci/uploads/images/gallery/2023-05/scaled-1680-/filezilla-sftp-2.png" alt="filezilla_sftp_2.png"></a></span></span></span></li>

You have the remote site window on the right.click and move file/folder from the left window (local site) to the right window (remote site).
Inversely, to transfer data from Curnagl: click and move file/folder from the right window (remote) to the left window (local site).


> Instead of `/home/margot/` on the left local site (respectively `/users/msirdey/` on the right remote site), you should see your own path on your computer (respectively on Curnagl).


> FileZilla keeps remote sites in memory. For future transfers, click on the arrow on the right of `Quickconnect` and choose `sftp://curnagl.dcsr.unil.ch`.