# Rclone



### Installation

```bash
$ sudo apt rclone
```

Mais cette version n'est pas jour.

```bash
$ wget https://downloads.rclone.org/rclone-current-linux-arm.zip
$ unzip -j -d rclone-temp rclone-current-linux-arm.zip

$ sudo mv ~/rclone-temp/rclone /usr/bin/rclone
$ sudo chown root: /usr/bin/rclone

$ sudo mv ~/rclone-temp/rclone.1 /usr/share/man/man1/rclone.1

$ rm ~/rclone-current-linux-arm.zip
$ rm -rf ~/rclone-temp
```



#### Rclone config:

#### rclone config

```bash
$ rclone config
.../...
Current remotes:

Name                 Type
====                 ====
pCloud_RPi           pcloud
```

#### rclone config show

```bash
$ rclone config show
[pCloud_RPi]
type = pcloud
hostname = api.pcloud.com
token = {"access_token":"dWUiZDnONSzyJXpmZcvngG7ZyPNPY6dCoef3qtmBY2dgYY9WKYQk","token_type":"bearer","expiry":"0001-01-01T00:00:00Z"}
```

#### rclone config file

```bash
$ rclone config file
Configuration file is stored at:
/home/pi/.config/rclone/rclone.conf
```



### Rclone ls:

```bash
$ rclone ls pCloud_RPi:Linux
     6148 .DS_Store
       73 .~lock.Linux Apps.ods#
    14882 Linux Apps.ods
     6040 python -apt.txt
```



### Rclone sync:

```bash
$ rclone sync $HOME/pCloud/RPi4 pCloud_RPi:Linux/RPi4
```



### Rclone ls:

```bash
# lsd (list directory)
$ rclone lsd pCloud_RPi:Linux/RPi4
          -1 2021-02-27 10:51:56        -1 scripts

#ls (list files)
$ rclone ls pCloud_RPi:Linux/RPi4
      163 cmdline.txt
     2432 scripts/config

#lsl (lifst files with size and date)
$ rclone lsl pCloud_RPi:Linux/RPi4
      163 2021-02-24 18:22:25.000000000 cmdline.txt
     2432 2021-02-06 17:57:30.000000000 scripts/config
```



### Rclone mkdir:

```bash
$ rclone lsd pCloud_RPi:Linux/RPi4
          -1 2021-02-27 10:51:56        -1 scripts

$ rclone mkdir pCloud_RPi:Linux/RPi4/Backup

$ rclone lsd pCloud_RPi:Linux/RPi4
          -1 2021-02-27 10:57:33        -1 Backup
          -1 2021-02-27 10:51:56        -1 scripts
```



### Rclone move:

```bash
$ rclone lsl pCloud_RPi:Linux/RPi4
      163 2021-02-24 18:22:25.000000000 cmdline.txt
     2432 2021-02-06 17:57:30.000000000 Backup/config
     
$ rclone move pCloud_RPi:Linux/RPi4/cmdline.txt pCloud_RPi:Linux/RPi4/scripts

$ rclone lsl pCloud_RPi:Linux/RPi4
      163 2021-02-24 18:22:25.000000000 scripts/cmdline.txt
     2432 2021-02-06 17:57:30.000000000 Backup/config
```



### Rclone GUI:

#### rclone rcd --rc-web-gui

```bash
$ rclone rcd --rc-web-gui
2021/02/27 11:29:47 NOTICE: Web GUI exists. Update skipped.
2021/02/27 11:29:47 NOTICE: Serving Web GUI
2021/02/27 11:29:47 NOTICE: Serving remote control on http://localhost:5572/
```



### Rclone mount:

```bash
$ mkdir $HOME/pCloud-drive

$ rclone --vfs-cache-mode writes mount pCloud_RPi: $HOME/pCloud-drive &
[1] 26815
$ cd pCloud-drive/
total 410497
-rw-r--r-- 1 pi pi       165 nov.  25 17:55 '~$IP.xlsx'
-rw-r--r-- 1 pi pi       165 nov.  25 20:59 '~$Machines.xlsx'
-rw-r--r-- 1 pi pi    129652 sept.  4  2019  2019-09-03_Cerf_2534.jpg
-rw-r--r-- 1 pi pi  43137006 oct.   9  2019  2019-10-09_Chevrillard_6337.CR3
```

```bash
$ df -h
Sys. de fichiers Taille Utilisé Dispo Uti% Monté sur
/dev/root          110G    6,9G   97G   7% /
devtmpfs           1,8G       0  1,8G   0% /dev
tmpfs              1,9G     93M  1,8G   5% /dev/shm
tmpfs              1,9G    9,0M  1,9G   1% /run
tmpfs              5,0M    4,0K  5,0M   1% /run/lock
tmpfs              1,9G       0  1,9G   0% /sys/fs/cgroup
/dev/sda1          253M     49M  204M  20% /boot
tmpfs              383M     16K  383M   1% /run/user/1000
pCloud_RPi:        2,0T     31G  2,0T   2% /home/pi/pCloud-drive

$ mount | grep rclone
pCloud_RPi: on /home/pi/pCloud-drive type fuse.rclone (rw,nosuid,nodev,relatime,user_id=1000,group_id=1000)
```

#### Montage automatique avec la crontab:

```bash
$ nano mount-pcloud.sh

# Ajouter:

#!/bin/bash
/usr/bin/rclone --vfs-cache-mode writes mount pCloud_RPi: $HOME/pCloud-drive &

$ chmod +x mount-pcloud.sh 

```

Ajouter le script à la crontab:

```bash
crontab -e (ou crontab -e -u UserName)

@reboot sh /username/scripts/mount-pcloud.sh
```



#### Démonter le disque pCloud:

```bash
$ fusermount -u /home/pi/pCloud-drive

# Si le disque est occupé, il faut forcer le démontage:
$ fusermount -uz /home/pi/pCloud-drive
```





https://devsrealm.com/cloud-computing/ubuntu/mounting-and-unmounting-cloud-storage-with-rclone-in-linux/