Knowledge base
1000 FAQs, 500 tutorials and instructional videos. Here, there are only solutions!
Import data to kDrive from iCloud
This guide explains how to import data from iCloud Drive or iCloud Photos to kDrive Infomaniak using rclone.
✘ UNAVAILABLE with
kSuite Free / kSuite Standard
my kSuite / my kSuite+ (ik.me, etik.com, ikmail.com)
Introduction
- This method is intended for experienced users who wish to transfer iCloud data to kDrive without manually copying files one by one.
- rclone allows you to configure an iCloud Drive or iCloud Photos source, and then a kDrive destination via WebDAV.
- Accessing iCloud with rclone requires the usual Apple ID password and two-factor Apple authentication. Apple application passwords are not accepted for this configuration.
- iCloud authentication may need to be renewed periodically using
rclone reconnectorrclone config. - The
rclone copycommand copies files to kDrive without deleting them from the source iCloud.
1. Install rclone
rclone can be installed via the command line. On macOS, Linux, or BSD, open the Terminal application and run the following command:
sudo -v ; curl {{URL_1}} | sudo bashIf necessary, consult the official rclone installation guide, especially for Windows or for a manual installation.
Once the installation is complete, verify that rclone is responding correctly:
rclone version
2. Configure the iCloud source in rclone
In Terminal, start the rclone configuration:
rclone config- Choose
nto create a new remote disk. Give this source an explicit name, for example:
iCloudDrive- Choose the
iclouddrivestorage type. - To import documents stored in iCloud Drive, keep the default
driveservice. - To import items from iCloud Photos, choose the
photosservice or create a second dedicated remote drive, for exampleiCloudPhotos. - Enter your Apple ID, which is usually an email address.
- Choose to enter your own password, then enter your usual Apple ID password.
- Answer
nto advanced configuration, unless you have a specific need. - Confirm the connection from your trusted Apple device, then enter the two-factor authentication code when rclone prompts you.
- When the summary is correct, answer
yto save the configuration.
Check that the iCloud source is accessible:
rclone lsd iCloudDrive:If you have configured a dedicated source for iCloud Photos, check it as well:
rclone lsd iCloudPhotos:
3. Configure the kDrive destination in rclone
kDrive must be configured in rclone as a WebDAV storage.
Restart the configuration if you are no longer in the rclone menu:
rclone config- Choose
nto create a new remote disk. Give the destination an explicit name, for example:
kDrive- Choose the
webdavstorage type. For the URL, enter the direct WebDAV access to your kDrive:
{{URL_3}}- Replace
ID_KDRIVEwith your kDrive ID; refer to this other guide if needed.
- Replace
- For the WebDAV provider (
vendor), chooseother. - For the user (
user), enter the email address used to log in to the Infomaniak account. - For the password, enter:
- an application password if two-factor authentication is enabled on the Infomaniak account;
- the password for the Infomaniak user account if two-factor authentication is not enabled.
- Leave the
bearer_tokenfield blank. - Answer
nto the advanced configuration prompt, unless you have a specific need. - If the summary is correct, answer
yto save the configuration.
The resulting configuration will look like this in the rclone configuration file:
[kDrive]
type = webdav
url = {{URL_6}}
vendor = other
user = user@example.com
pass = PASSWORD_STORED_BY_RCLONEThe password displayed in the rclone configuration file is not stored in plain text when the configuration is created using rclone config. If you modify this file manually, generate the value for the pass field using the rclone obscure command.
Verify that the kDrive destination is accessible:
rclone lsd kDrive:
4. Copy iCloud data to kDrive
Do not use sudo for the copy commands if the rclone configuration was created with your usual user session. Otherwise, rclone may look for a different configuration and fail to find the previously created access credentials.
Before launching a full copy, list the available folders on the source:
rclone lsd iCloudDrive:It is recommended to perform a test without actual transfer using --dry-run:
rclone copy iCloudDrive: kDrive:iCloudDrive --dry-run --progressIf the result is correct, start the copy:
rclone copy iCloudDrive: kDrive:iCloudDrive --progress --transfers 4 --checkers 8 --retries 5 --low-level-retries 10 --log-level INFO --log-file "$HOME/Desktop/rclone-kdrive-import.log"This command copies the folders, subfolders, and files from the source iCloudDrive: to the iCloudDrive folder in your kDrive.
If the connection or computer is interrupted, restart the same command. rclone will resume the comparison and avoid copying files that are already present when their size and available information match.
To verify the consistency of the copied volume, you can compare the source and destination by size:
rclone check iCloudDrive: kDrive:iCloudDrive --size-only --one-way --progress
Copying iCloud Photos
If you have configured a dedicated source for iCloud Photos, first list the available libraries and folders:
rclone lsd iCloudPhotos:Then, adjust the source path according to the directory structure displayed by rclone. Example:
rclone copy iCloudPhotos: kDrive:iCloudPhotos --dry-run --progressThen, start the copy if the test result is correct:
rclone copy iCloudPhotos: kDrive:iCloudPhotos --progress --transfers 4 --checkers 8 --retries 5 --low-level-retries 10 --log-level INFO --log-file "$HOME/Desktop/rclone-kdrive-photos.log"
5. Correct the dates of the photos if necessary
After exporting or copying photos, the system dates of the files may no longer correspond to the original date the photos were taken. If the chronological display is not correct, you can correct the dates on a local copy of the files before sending them permanently to kDrive.
Always work on a local copy of the files before running a correction script. The script below does not run directly on a remote rclone source: it processes a folder located on your computer.
To prepare a local folder for correction, copy the photos, for example, into a temporary folder on your desktop:
rclone copy iCloudPhotos: "$HOME/Desktop/iCloud-Photos" --progressNext, install ExifTool from https://exiftool.org/index.html, then run the script below on macOS from the Terminal application.
The script searches for a date in the file's metadata and then in its name. The corrected files are listed in DateFound.txt, and the files without a usable date are listed in DateError.txt, on the desktop.
The script to copy and paste:
/bin/bash <<'BASH'
#!/bin/bash
set -u
ROOT="$(osascript -e 'POSIX path of (choose folder with prompt "Select the folder containing the files to update")')" || exit 0
DESKTOP="$HOME/Desktop"
LOG_FOUND="$DESKTOP/DateFound.txt"
LOG_ERROR="$DESKTOP/DateError.txt"
: > "$LOG_FOUND"
: > "$LOG_ERROR"
find_exiftool() {
if command -v exiftool >/dev/null 2>&1; then
command -v exiftool
return 0
fi
if [ -x "/usr/local/bin/exiftool" ]; then
printf '%s\n' "/usr/local/bin/exiftool"
return 0
fi
if [ -x "/opt/homebrew/bin/exiftool" ]; then
printf '%s\n' "/opt/homebrew/bin/exiftool"
return 0
fi
return 1
}
EXIFTOOL="$(find_exiftool)" || {
printf '%s\n' "ExifTool not found. Install it, then run the script again." >> "$LOG_ERROR"
printf '%s\n' "ExifTool not found. Check DateError.txt on the desktop."
exit 1
}
if [ ! -d "$ROOT" ]; then
printf 'Invalid folder: %s\n' "$ROOT" >> "$LOG_ERROR"
printf '%s\n' "Invalid folder. Check DateError.txt on the desktop."
exit 1
fi
get_exif_date() {
"$EXIFTOOL" -s3 -d "%Y:%m:%d %H:%M:%S" -DateTimeOriginal -CreateDate -MediaCreateDate -TrackCreateDate -CreationDate -ModifyDate -- "$1" 2>/dev/null | awk '/^[0-9]{4}:[0-9]{2}:[0-9]{2} [0-9]{2}:[0-9]{2}:[0-9]{2}/ { print substr($0, 1, 19); exit }'
}
get_name_date() {
local name
name="$(basename "$1")"
if [[ "$name" =~ ([12][0-9]{3})[-_]?([01][0-9])[-_]?([0-3][0-9])([_\ -]?([0-2][0-9])[-_\.]?([0-5][0-9])[-_\.]?([0-5][0-9]))? ]]; then
local year="${BASH_REMATCH[1]}"
local month="${BASH_REMATCH[2]}"
local day="${BASH_REMATCH[3]}"
local hour="12"
local minute="00"
local second="00"
if [ -n "${BASH_REMATCH[5]:-}" ]; then
hour="${BASH_REMATCH[5]}"
minute="${BASH_REMATCH[6]}"
second="${BASH_REMATCH[7]}"
fi
printf '%s:%s:%s %s:%s:%s\n' "$year" "$month" "$day" "$hour" "$minute" "$second"
return 0
fi
return 1
}
is_valid_date() {
date -j -f "%Y:%m:%d %H:%M:%S" "$1" "+%Y:%m:%d %H:%M:%S" >/dev/null 2>&1
}
to_touch_date() {
printf '%s' "$1" | sed -E 's/^([0-9]{4}):([0-9]{2}):([0-9]{2}) ([0-9]{2}):([0-9]{2}):([0-9]{2})$/\1\2\3\4\5.\6/'
}
write_metadata() {
local file="$1"
local date_value="$2"
"$EXIFTOOL" -overwrite_original "-DateTimeOriginal=$date_value" "-CreateDate=$date_value" "-ModifyDate=$date_value" -- "$file" >/dev/null 2>&1 || true
}
process_file() {
local file="$1"
local date_value=""
local source=""
date_value="$(get_exif_date "$file")"
if [ -n "$date_value" ]; then
source="EXIF"
else
date_value="$(get_name_date "$file")"
if [ -n "$date_value" ]; then
source="file name"
fi
fi
if [ -n "$date_value" ] && is_valid_date "$date_value"; then
local touch_value
touch_value="$(to_touch_date "$date_value")"
if [ "$source" != "EXIF" ]; then
write_metadata "$file" "$date_value"
fi
if touch -t "$touch_value" "$file" 2>/dev/null; then
printf '%s | %s | %s\n' "$source" "$date_value" "$file" >> "$LOG_FOUND"
else
printf 'Unable to update file date: %s\n' "$file" >> "$LOG_ERROR"
fi
else
printf 'No valid date found: %s\n' "$file" >> "$LOG_ERROR"
fi
}
while IFS= read -r -d '' file; do
case "$file" in
*.json|*_original) continue ;;
esac
process_file "$file"
done < <(find "$ROOT" -type f -print0)
printf '%s\n' "Done. Check DateFound.txt and DateError.txt on the desktop."
BASHAfter correction, send the corrected local folder to kDrive:
rclone copy "$HOME/Desktop/iCloud-Photos" kDrive:iCloudPhotos --progress --transfers 4 --checkers 8 --retries 5 --low-level-retries 10
6. Accessing data from kDrive
Once the copy is complete, your data is accessible from the kDrive web app, the kDrive mobile apps, and devices synchronized with the kDrive desktop app.
If you are also using the kDrive desktop app, wait for the local synchronization to complete before moving or renaming the imported folders.
Link to this FAQ: https://faq.infomaniak.com/2515
Has this FAQ been helpful?