Rclone is a command-line program for managing files in the cloud. In this article, we explain how to install and use Rclone:
- to copy a file to N0C Storage;
- to move a file to N0C Storage;
- to synchronize a file between a local version and N0C Storage; and
- in a Cron task.
Prerequisites
Enter the following address in your web browser: https://mg.n0c.com/en/.
How to Install Rclone
There are three steps to install Rclone:
- install Rclone on the hosting account;
- configure the “remote” destination for Rclone; and
- confirm that the configuration works.
First Step: Installing Rclone on the Hosting Account
Go to the download link for Linux – Intel/AMD – 64 Bit: https://rclone.org/downloads/:
wget https://downloads.rclone.org/v1.69.1/rclone-v1.69.1-linux-amd64.zip
Extract the archive:
unzip rclone-v1.69.1-linux-amd64.zip
Create the bin directory at the root of the account if it does not already exist:
mkdir ~/bin
Move the binary to the bin directory so that rclone is recognized as a command:
mv rclone-v1.69.1-linux-amd64/rclone ~/bin/
Second Step: Configuring the “remote” Cestination for Rclone
Create the folder structure and the configuration file:
mkdir ~/.config
mkdir ~/.config/rclone
touch ~/.config/rclone/rclone.conf
Open the file ~/.config/rclone/rclone.conf
using the file manager or a text editor of your choice.
Paste the following content into the rclone.conf file and save:
[n0cstorage]
type = s3
provider = Other
access_key_id = $Accesskey
secret_access_key = $SecretKey
location_constraint = $Bucket
endpoint = ht2-storage.n0c.com:5443
acl = private
no_check_bucket = true
In the previous command, replace $Accesskey, $SecretKey, and $Bucket with their respective values noted in https://mg.n0c.com/files/n0c-storage.
Third Step: Confirmation that the Configuration is Working
Test the rclone ls command:
rclone ls n0cstorage:
This lists the content in the destination object.
If it is empty, there will be no output. Therefore, having a test file can help to confirm that the configuration is working.
How to Copy a File to N0C Storage
Copy a file foo.txt to the private directory of the bucket “foobar”:
rclone copy foo.txt n0cstorage:foobar/private/
Replace foobar with the name of the bucket in the previous command.
The name of the bucket is the one listed on the page https://mg.n0c.com/files/n0c-storage.
How to Move a File to N0C Storage
Move a file foo.txt to the private directory of the “foobar” bucket:
rclone move foo.txt n0cstorage:foobar/private/
Replace foobar with the name of the bucket in the previous command.
The name of the bucket is the one listed on the page https://mg.n0c.com/files/n0c-storage.
How to Synchronize a File Between a Local Version and N0C Storage
Synchronize the file in the private directory in the remote “foobar” bucket with the changes to the local foo.txt file:
rclone sync foo.txt n0cstorage:foobar/private/
Only the remote file is modified.
Replace foobar with the name of the bucket in the previous command.
The name of the bucket is the one listed on the page https://mg.n0c.com/files/n0c-storage.
How to Use rclone in a Cron Task
Call rclone by the absolute path.
For a user “foobar”:
/home/foobar/bin/rclone
Example:
Add text to a file foo.txt and synchronize the changes on the copy on N0C Storage:
* * * * * echo "Ajout de ce texte" >> foo.txt && /home/foobar/bin/rclone sync /home/foobar/foo.txt n0cstorage:foobar/private/
References
Knowledge base article: Comment utiliser N0C Storage.
Documentation: https://rclone.org/docs/.
Commands: https://rclone.org/commands/.