# Moving files

Use `scp` for a few files and `rsync` for folders or repeated copies. Both use SSH, so you need a server with an SSH key. See [Connect with SSH](/docs/connect-ssh).

Replace `PORT` and `HOST` with the values on the server's **Connect** tab. The user is `root`.

## Copy to the server

```bash
scp -P PORT ./file.txt root@HOST:/workspace/
scp -P PORT -r ./data root@HOST:/workspace/
```

`scp` uses a capital `-P` for the port.

## Copy from the server

```bash
scp -P PORT root@HOST:/workspace/results.tar.gz ./
```

## Sync a folder with rsync

```bash
rsync -avz -e "ssh -p PORT" ./data/ root@HOST:/workspace/data/
rsync -avz -e "ssh -p PORT" root@HOST:/workspace/checkpoints/ ./checkpoints/
```

If it stops, run the same command again. `rsync` continues where it left off. The trailing `/` on a folder matters: `./data/` copies the contents.

## On Windows

PowerShell includes `scp`. Rsync is not included. Use `scp`, or use rsync inside Windows Subsystem for Linux.

## Check the disk first

```bash
df -h
```

If the disk is full, delete files you do not need. The disk size is set when you deploy.

## Common problems

- **Permission denied:** use the key that matches one of the keys on the server. Add `-i ~/.ssh/your_key`.
- **Connection refused or timeout:** the server must be running. Copy the host and port again, because they can change after a restart.
- **A copy is slow:** compress first with `tar -czf`, or copy only what changed with `rsync`.

Copy important results off the server before you destroy it. See [Storage and data](/docs/storage-and-data).
