Skip to content
System

Rclone on Linux, check a cloud backup before you need it

Avatar illustré de Julien Macé 4 min read
Manchot Linux vérifiant le transfert entre deux supports et un cloud
Une sauvegarde cloud reste à contrôler par une comparaison et une restauration test.

The journal indicates “transfer completed”, the cloud responds, and then a file must be retrieved after a mishap or a disk failure. At that moment, a rclone backup is only valuable if you know how to locate and restore the data. This method starts from a Linux server, with a remote already configured and a small test directory.

Use an explicit remote name, for example backup, and a prefix that identifies the server. A vague destination like backup: ends up mixing machines or old attempts.

Identify the remote without displaying the token

rclone config show can print a decrypted configuration. Keep this output away from tickets, CI logs, and shared terminals. Start by locating the file, then request a redacted view of the remote.

rclone config file
rclone config redacted backup
rclone lsd backup:archives/server-a

The lsd command should list the folders in the targeted path. If it fails, first correct the account, authentication, or prefix. Do not start a sync to “see if it works”.

For an encrypted remote, use the crypt remote configured locally. Rclone then keeps the names and data encrypted on the provider’s side, but your machine must still retain the necessary configuration to read them.

Preview the copy before the first write

To start a backup, choose rclone copy. The command adds or updates files without deleting those already present in the destination. This is the cautious choice when the remote content also contains archives or when you are still discovering the structure.

rclone copy --dry-run --combined - 
  /srv/data 
  backup:archives/server-a

--dry-run displays the operations without writing anything. In the combined report, + indicates a file missing from the destination, = an identical file, and * a file present on both sides but different. Check the first paths displayed. A wrong prefix may not be noticed after several terabytes transferred.

When the report targets the correct folder, relaunch without --dry-run and maintain a usable log.

rclone copy /srv/data 
  backup:archives/server-a 
  --log-file /var/log/rclone-backup.log 
  --log-level INFO

Rclone sync is used to match the destination to the source. It can therefore delete files from the cloud that are no longer in /srv/data. Use it only for a mirror whose direction is clear, after a preview and with a second SSH session open if you are working on a remote server.

rclone sync --dry-run 
  /srv/data 
  backup:archives/server-a

The official documentation for rclone sync also recommends --dry-run or interactive mode before an action that may delete objects.

Compare data after the copy

A transfer without errors does not confirm that the destination contains all the expected files. rclone check compares source and destination without modifying them. Depending on the backend, it compares the size, date, and available hashes. Some providers do not expose a compatible hash, so a correct result does not replace an actual restore.

rclone check /srv/data 
  backup:archives/server-a 
  --combined /var/tmp/rclone-check.txt

less /var/tmp/rclone-check.txt

In this file, = indicates a match, + an item present only in the source, - an item present only in the destination, and * a difference. Correct the path, filter, or file in question before declaring the backup valid. The reference rclone check also details the --download option, useful if you need to compare contents despite the provider’s hash limitations.

Restore a file to a temporary folder

Choose a file that really matters, such as an exported database, a PDF document, or an application configuration. Do not restore it directly to its production location. Copy it to a temporary folder, open it with the intended tool, and then compare it to the source as long as the source still exists.

mkdir -p /var/tmp/rclone-restoration

rclone copy 
  backup:archives/server-a/control.txt 
  /var/tmp/rclone-restoration/

diff -u /srv/data/control.txt 
  /var/tmp/rclone-restoration/control.txt

A silent diff means that the two files are identical. For a folder, run rclone check between the source and the restored folder. If you are using a crypt remote, the command rclone cryptcheck is more suited for verifying encrypted objects.

Log a check that you can redo

Note the remote, the remote prefix, the executed command, the date of the last rclone check, and the restored file. Also keep the copy log away from the saved directory if you do not want it to transfer with each pass.

  • The targeted remote and prefix respond with rclone lsd.
  • The copy was previewed with --dry-run.
  • rclone check does not show any unexplained differences.
  • A restored file opens and matches the source.

To encrypt a file before sending it or to protect a private key, the guide GPG on Linux covers another layer of protection. GPG and rclone do not serve the same role: one encrypts files, the other orchestrates the transfer and verification.

Linux penguin verifying the transfer between two drives and a cloud
A cloud backup remains to be controlled by a comparison and test restore.
Share Facebook X WhatsApp LinkedIn Pinterest Reddit Email