In previous article, i have explained how to rclone one local folder to a remote folder.
While doing so i had enable filename encryption.
It appears that it brings nothing but complexity (content encryption is all that matters to me) and i now want to revert to original filenames while not having to reupload it all.
Here below a dry run script (to test safely) and a real run script – all this from the synology command line.
Note that we need to suffix files with .bin or else rclone will not recognize the files as encrypted.
#!/bin/bash
REMOTE_CRYPT="ovhcrypt:"
REMOTE_RAW="ovhftp:/backup/"
echo "=== DRY RUN (DECRYPT NAMES + ADD .BIN) ==="
rclone lsf -R "$REMOTE_RAW" | while read -r path; do
# Ignore les dossiers
[[ "$path" == */ ]] && continue
# Sépare dossier et fichier
dir="${path%/*}"
filename="${path##*/}"
# Filtre : noms chiffrés rclone (base32, >=16 chars)
if ! [[ "$filename" =~ ^[a-z0-9]{16,}$ ]]; then
echo "Skip (not encrypted): $path"
continue
fi
# Décrypte uniquement le nom du fichier
decfile=$(rclone cryptdecode "$REMOTE_CRYPT" "$filename" 2>/dev/null | awk '{print $NF}')
if [[ -z "$decfile" ]]; then
echo "Skip (cryptdecode failed): $path"
continue
fi
# Ajoute l'extension .bin
decfile_bin="${decfile}.bin"
# Reconstruit le chemin final
if [[ "$dir" == "$path" ]]; then
decpath="$decfile_bin"
else
decpath="$dir/$decfile_bin"
fi
echo "DRY RUN: Would rename: $path --> $decpath"
done
#!/bin/bash
REMOTE_CRYPT="ovhcrypt:"
REMOTE_RAW="ovhftp:/backup/"
echo "=== REAL RUN (DECRYPT NAMES + ADD .BIN) ==="
rclone lsf -R "$REMOTE_RAW" | while read -r path; do
# Ignore les dossiers
[[ "$path" == */ ]] && continue
# Sépare dossier et fichier
dir="${path%/*}"
filename="${path##*/}"
# Filtre : noms chiffrés rclone (base32, >=16 chars)
if ! [[ "$filename" =~ ^[a-z0-9]{16,}$ ]]; then
echo "Skip (not encrypted): $path"
continue
fi
# Décrypte uniquement le nom du fichier
decfile=$(rclone cryptdecode "$REMOTE_CRYPT" "$filename" 2>/dev/null | awk '{print $NF}')
if [[ -z "$decfile" ]]; then
echo "Skip (cryptdecode failed): $path"
continue
fi
# Ajoute l'extension .bin pour compatibilité ovhcrypt2
decfile_bin="${decfile}.bin"
# Reconstruit le chemin final
if [[ "$dir" == "$path" ]]; then
decpath="$decfile_bin"
else
decpath="$dir/$decfile_bin"
fi
echo "Renaming: $path --> $decpath"
# Renommage optimisé et OVH-friendly
rclone moveto "$REMOTE_RAW$path" "$REMOTE_RAW$decpath" \
--transfers 1 \
--checkers 1 \
--multi-thread-streams 0 \
--ftp-concurrency 1 \
--low-level-retries 3 \
--retries 3 \
--stats 10s
# Petite pause pour éviter les 421
sleep 0.2
done
Note, once all crypted filenames have been renamed to non encrypted filenames (with .bin extension), i stopped using ovhcrypt remote and switched to ovhcrypt2 remote.
my command is rclone sync /volume1/photo ovhcrypt2: –progress .
[ovhcrypt]
type = crypt
remote = ovhftp:/backup
directory_name_encryption = false
password = xxx
password2 = xxx
[ovhftp]
type = ftp
host = ftp.xxx.fr
user = username
pass = password
[ovhcrypt2]
type = crypt
remote = ovhftp:/backup
filename_encryption = off
directory_name_encryption = false
password = xxx
password2 = xxx