rclone Copyto
rclone copyto copies a source file or directory to a specific destination path. Unlike copy (which preserves directory structure), copyto lets you rename the file or place it at an exact path during the transfer.
Quick Summary
Use copyto when you need to copy one file to a specific filename at the destination. Use copy when you're copying directories or multiple files and want the structure preserved.
Basic Syntax
rclone copyto SOURCE DESTINATION [flags]
# Copy a single file to a specific remote path
rclone copyto /backup/db/dump.sql remote:backups/db/production-2024-01-15.sql
# Copy and rename a local file
rclone copyto config.yml remote:configs/app-config-v2.yml
# Copy between remotes with a new name
rclone copyto remoteA:data/export.csv remoteB:archive/export-final.csv
copyto vs copy
| Scenario | copy | copyto |
|---|---|---|
| Copy a directory | Preserves directory structure | Copies contents into target path |
| Copy a single file | Places file inside destination directory | Renames file to destination path |
| Best for | Bulk transfers | Single-file precision |
Example Difference
# copy — puts dump.sql INSIDE the backups/ directory
rclone copy /backup/db/dump.sql remote:backups/
# Result: remote:backups/dump.sql
# copyto — renames the file at the destination
rclone copyto /backup/db/dump.sql remote:backups/prod-latest.sql
# Result: remote:backups/prod-latest.sql
Practical Examples
Upload Database Dump with Timestamp
DATE=$(date +%Y-%m-%d-%H%M)
rclone copyto /var/backups/db/latest.sql.gz \
remote:backups/db/dump-${DATE}.sql.gz --progress
Copy Config File to Remote
rclone copyto /etc/nginx/nginx.conf \
remote:configs/nginx/nginx-$(hostname).conf
Archive a Log File
rclone copyto /var/log/app/error.log \
remote:logs/$(date +%Y/%m)/error-$(date +%d).log
Copy SSL Certificate to Backup
rclone copyto /etc/letsencrypt/live/example.com/fullchain.pem \
remote:certs/example.com/fullchain-$(date +%Y%m%d).pem
Key Flags
| Flag | Description |
|---|---|
--dry-run / -n | Preview without transferring |
--progress / -P | Show transfer progress |
--no-traverse | Skip directory listing (faster for single files) |
--log-file PATH | Write log to file |
Common Pitfalls
| Pitfall | Consequence | Prevention |
|---|---|---|
Using copy when you need renaming | File keeps original name | Use copyto for renaming |
Using copyto for directories | Unexpected directory structure | Use copy for directory transfers |
| Missing parent directory at remote | Some backends auto-create, others error | Verify with rclone mkdir first |
What's Next
Examples with Output
1. Copy and rename a local file to remote
Upload a file with a specific target name. Command:
rclone copyto ./current_db.sql gdrive:db_backups/2024-01-15_final.sql
Output:
(No output on success)
2. Overwrite a remote file precisely
Replace a specific file on the remote. Command:
rclone copyto ./new_config.json remote:app/config.json -v
Output:
2024/01/15 12:00:00 INFO : config.json: Copied (replaced existing)
3. Copy a subfolder to a new location
Target a specific path for directory contents. Command:
rclone copyto /local/src /remote/dest_folder
Output:
(All files in src copied directly into dest_folder)
4. Dry run for precise targeting
Ensure the rename will happen as expected. Command:
rclone copyto file.txt remote:new_name.txt --dry-run
Output:
2024/01/15 12:00:00 NOTICE: new_name.txt: Not copied as --dry-run is set
5. Skip directory traversal for speed
Fast copy when you know exactly where the file is. Command:
rclone copyto remote:source.file remote:dest.file --no-traverse
Output:
(Instant operation for single small files)