Back up from Android to OneDrive with rclone
Backing up your Android device to OneDrive is easy using rclone. Even if your OneDrive account has two-factor authentication (2FA), rclone works perfectly by authorizing once through a web browser.
Step 1 — Install rclone in Termux
pkg install rclone
Step 2 — Configure OneDrive
Run the following command:
rclone config
Answer the prompts as follows:
- New remote:
n - Name:
onedrive - Storage: OneDrive
- Client ID: press Enter
- Client Secret: press Enter
- Edit advanced config?
n - Use auto config?
n(important on Android)
After choosing No for auto config, rclone will show a long URL.
- Copy the URL
- Open it in your Android web browser
- Sign in to OneDrive and approve access
- Copy the verification code
- Paste it back into Termux
Two-factor authentication works normally during this step.
Step 3 — Test the OneDrive Connection
rclone lsd onedrive:
If your OneDrive folders appear, the setup is complete.
Step 4 — Backup Using rclone
Example backup commands:
rclone copy "$BACKUP" "onedrive:/TermuxShortcutsBackup/$TS"
rclone delete --min-age 7d "onedrive:/TermuxShortcutsBackup"
This will:
- Upload your backup to OneDrive
- Automatically delete backups older than 7 days
Mirror Local Folder to OneDrive (Exact Sync)
To create an exact mirror of a local folder to OneDrive:
rclone sync "/storage/emulated/0/my_phone/some_dir" "onedrive:/some_dir"
This command will:
- Upload new files
- Update modified files
- Delete files on OneDrive that no longer exist locally
- Automatically create required folders
Preview Changes Before Syncing
To see what will happen without making any changes:
rclone sync "/storage/emulated/0/my_phone/some_dir" "onedrive:/some_dir" --dry-run
Recommended Options
--progress— show transfer progress--exclude ".*"— ignore hidden files
Example:
rclone sync "/storage/emulated/0/my_phone/some_dir" "onedrive:/some_dir" --progress
Important note:
This is a one-way sync from your phone to OneDrive.
(OneDrive changes will NOT affect your phone)
Comments
Post a Comment