Wiki Les geekeries de rungis

Créer un backup chiffré de ses données sur Google Drive avec rclone

Dernière mise à jour : 27/04/2026 à 22h36
Table des matières Avoir une sauvegarde locale de ses données est une excellente chose, mais pour une protection ultime contre les sinistres (incendie, vol, panne totale du serveur), l'externalisation est indispensable. Ce tutoriel vous explique comment configurer un système de sauvegarde "froide" et chiffrée vers votre espace Google One (2 To ou plus) en utilisant Rclone.

Création des identifiants Google Cloud



Pour éviter les limitations de vitesse et les erreurs de connexion, il est fortement conseillé de créer vos propres identifiants API plutôt que d'utiliser ceux par défaut de Rclone.

Vous trouverez tout le détail de la manip. à faire sur Google Cloud Console ici rclone.org

Code TEXT :
 
When you use rclone with Google drive in its default configuration you are using rclone's client_id. This is shared between all the rclone users. There is a global rate limit on the number of queries per second that each client_id can do set by Google. rclone already has a high quota and I will continue to make sure it is high enough by contacting Google.
It is strongly recommended to use your own client ID as the default rclone ID is heavily used. If you have multiple services running, it is recommended to use an API key for each service. The default Google quota is 10 transactions per second so it is recommended to stay under that number as if you use more than that, it will cause rclone to rate limit and make things slower.
Here is how to create your own Google Drive client ID for rclone:
Log into the Google API Console with your Google account. It doesn't matter what Google account you use. (It need not be the same account as the Google Drive you want to access)
Select a project or create a new project.
Under "ENABLE APIS AND SERVICES" search for "Drive", and enable the "Google Drive API".
Click "Credentials" in the left-side panel (not "Create credentials", which opens the wizard).
If you already configured an "Oauth Consent Screen", then skip to the next step; if not, click on "CONFIGURE CONSENT SCREEN" button (near the top right corner of the right panel), then click "Get started". On the next screen, enter an "Application name" ("rclone" is OK); enter "User Support Email" (your own email is OK); Next, under Audience select "External". Next enter your own contact information, agree to terms and click "Create". You should now see rclone (or your project name) in a box in the top left of the screen.
(PS: if you are a GSuite user, you could also select "Internal" instead of "External" above, but this will restrict API use to Google Workspace users in your organisation).
You will also have to add some scopes, including
https://www.googleapis.com/auth/docs
https://www.googleapis.com/auth/drive in order to be able to edit, create and delete files with RClone.
https://www.googleapis.com/auth/drive.metadata.readonly which you may also want to add.
To do this, click Data Access on the left side panel, click "add or remove scopes" and select the three above and press update or go to the "Manually add scopes" text box (scroll down) and enter "https://www.googleapis.com/auth/docs,https://www.googleapis.com/auth/drive,https://www.googleapis.com/auth/drive.metadata.readonly", press add to table then update.
You should now see the three scopes on your Data access page. Now press save at the bottom!
After adding scopes, click Audience Scroll down and click "+ Add users". Add yourself as a test user and press save.
Go to Overview on the left panel, click "Create OAuth client". Choose an application type of "Desktop app" and click "Create". (the default name is fine)
It will show you a client ID and client secret. Make a note of these. (If you selected "External" at Step 5 continue to Step 9. If you chose "Internal" you don't need to publish and can skip straight to Step 10 but your destination drive must be part of the same Google Workspace.)
Go to "Audience" and then click "PUBLISH APP" button and confirm. Add yourself as a test user if you haven't already.
Provide the noted client ID and client secret to rclone.
Be aware that, due to the "enhanced security" recently introduced by Google, you are theoretically expected to "submit your app for verification" and then wait a few weeks(!) for their response; in practice, you can go right ahead and use the client ID and client secret with rclone, the only issue will be a very scary confirmation screen shown when you connect via your browser for rclone to be able to get its token-id (but as this only happens during the remote configuration, it's not such a big deal). Keeping the application in "Testing" will work as well, but the limitation is that any grants will expire after a week, which can be annoying to refresh constantly. If, for whatever reason, a short grant time is not a problem, then keeping the application in testing mode would also be sufficient.
 


Installation et Configuration de Rclone



Rclone est le "couteau suisse" du stockage Cloud. Installez-le sur votre serveur (Debian/Ubuntu/Proxmox) :

Code :
sudo apt install rclone


Lancez la configuration : rclone config

  • Tapez n pour créer un nouveau remote (nommez-le gdrive).
  • Choisissez le type Google Drive.
  • Collez votre Client ID et votre Client Secret[/i].
  • Pour le [b]Scope, choisissez l'option 1 (Full access).
  • Répondez n à "Use auto config" si vous êtes en SSH, et suivez le lien pour valider l'accès sur votre navigateur.


Ajout de la couche de chiffrement (Crypt)



C'est l'étape la plus importante pour la confidentialité. Nous allons créer un second "remote" qui s'appuie sur le premier mais chiffre tout à la volée.

Code :
rclone config


Créez un nouveau remote (nom : secret_backup), type crypt. Pointez-le vers gdrive:nom_du_dossier. Définissez deux mots de passe robustes (un pour les données, un pour le sel). Notez-les précieusement !

Automatisation et Notifications Telegram



Voici un script Bash optimisé pour synchroniser vos données et vous envoyer un rapport sur Telegram :

Code :

#!/bin/bash
Configuration
REMOTE="secret_backup:"
SOURCE="/votre/chemin/donnees"
LOG="/var/log/rclone_backup.log"
TG_TOKEN="VOTRE_TOKEN_BOT"
TG_CHATID="VOTRE_CHAT_ID"
Synchro
rclone sync "$SOURCE" "$REMOTE" --log-file=$LOG --log-level INFO --fast-list
Notification
if [ $? -eq 0 ]; then
curl -s -X POST "https://api.telegram.org/bot$TG_TOKEN/sendMessage" -d chat_id="$TG_CHATID" -d text="✅ Backup réussi le $(date)"
else
curl -s -X POST "https://api.telegram.org/bot$TG_TOKEN/sendMessage" -d chat_id="$TG_CHATID" -d text="⚠️ ERREUR Backup Homelab !"
fi


Conclusion



En couplant la puissance de Rclone avec le stockage Google One que vous payez déjà, vous obtenez une sauvegarde hors-site professionnelle, chiffrée de bout en bout et gratuite (incluse dans votre abonnement). Pensez à planifier ce script dans votre crontab pour dormir sur vos deux oreilles !
Cette page a été vue 2 fois