5.1 Cloud storage

5.1.1 rclone: sync your files with cloud storage

Rclone is an general utility to manage files on cloud storage. It can with with over 40 cloud storage providers such as Dropbox, OneDrive, and so on.

  • Configuration

    Before using rclone commands, you will need to configure it with rclone config, and follow instructions. Below there is a simple example to configure OneDrive:

    1. execute rclone config from the terminal
    2. write n to create a new remote configuration
    3. write a custom name for the new remote (e.g. remote)
    4. choose the type of storage (onedrive or 26)
    5. press enter to use default client_id
    6. press enter to use default client_secret
    7. press enter to use default region (global).
    8. write n to reject advanced configuration
    9. write y to use auto configuration
    10. write 1 to use OneDrive Personal or Business
    11. select the drive available (usually 0)
    12. write y to confirm location details of drive
    13. write y to confirm and finish configuration
    14. write q to quit configuration
  • Mount approach

    One approach to work with files located at cloud storage is to mount the remote drive as a file system on a mountpoint. Let consider that the remote has been configure with name remote, the syntax to mount this into the file system is:

    rclone mount remote:path/to/files /path/to/local/mount

    You can umount /path/to/local/mount with fusermount command

    fusermount -u /path/to/local/mount

    By default rclone will directly read and write directly the remote cloud storage, this might not be appropriate in case you are working with an slow internet connection. A useful alternative it to use cache options with --vfs-cache-mode (off, minimal, writes, full). I tend to use writes or full options for a seamless editing:

    rclone mount remote:path/to/files /path/to/local/mount --vfs-cache-mode full

    In case there is a warning about file permission at ~/.cache/rclone/vfs/remote, modify the file permission with

    sudo chmod -R 777 ~/.cache/rclone/vfs/remote

    Unfortunately I have problems updating Office files (.docx, .xlsx, and so on.)

  • Sync/copy approach

    In general this is a more reliable approach and with more control to define when to update the files. You can copy files from or to the remote cloud storage with rclone copy with the following syntax:

    rclone copy source:sourcepath dest:destpath

    Notice that rclone copies the contents of the directory as if sourcepath and destpath were written with a ending trailing /.

    Folders can be synced with the following command:

    rclone sync source:sourcepath dest:destpath --progress

    Edited, removed or new files will be send to destpath. Be careful, because it can delete data. Option -i can be used to make it interactive (asking for each file) as seen below.

    rclone sync -i SOURCE remote:DESTINATION