Rclone can copy files between your Linux computer and Sync through the Sync WebDAV server.
There are two useful commands:
- rclone copy copies new and changed files without deleting additional files at the destination.
- rclone sync makes the destination match the source, including deleting files from the destination that no longer exist at the source.
Installation
- Install and start the Sync WebDAV server. Follow these step-by-step instructions.
- Install Rclone: sudo apt install rclone
(or install the latest version from the Rclone website: curl https://rclone.org/install.sh | sudo bash)
Configure Rclone
- Make sure the Sync WebDAV server is installed and running.
- Run: rclone config create sync-webdav webdav url=http://localhost:4918 vendor=other user=sync pass='YOUR_GENERATED_WEBDAV_PASSWORD' --obscure
- Test the connection: rclone lsd sync-webdav:/
Back up a local folder to Sync
For a simple backup that doesn't delete files already stored in Sync:
- Run: rclone copy ~/Documents sync-webdav:/Backups/Documents -P
Run the same command again whenever you want to update the backup. Rclone skips files that haven't changed.
Setup automatic backups
You can combine Rclone with Linux cron to automatically copy a folder to Sync on a schedule. This is useful for servers, workstations, and other always-on Linux systems.
- Open your crontab:
crontab -e - To run the backup every hour, add:
0 * * * * /usr/bin/rclone copy /home/username/Documents sync-webdav:/Backups/Documents
Replace username with your Linux username. - Save the file. Rclone will now check the folder hourly and copy new or changed files to Sync.
The Sync WebDAV server must be running when the scheduled job starts. For an unattended server, run Sync WebDAV in daemon mode.
Mirror a local folder to Sync
If you want the Sync destination to exactly match the local folder, first perform a test:
- Run: rclone sync ~/Documents sync-webdav:/Backups/Documents --dry-run
Review the output carefully.
- Then run: rclone sync ~/Documents sync-webdav:/Backups/Documents -P
Warning: Files that exist in the Sync destination but not in the local source may be deleted.
Copy files from Sync to Linux
Reverse the source and destination:
- rclone copy sync-webdav:/Documents ~/Documents -P
This downloads new and changed files without deleting additional local files.
Speed up transfers of multiple files
By default, Rclone transfers up to four files at a time. If you’re copying a folder with many files, try increasing that to 10 with --transfers 10:
- rclone copy ~/Documents sync-webdav:/Backups/Documents --transfers 10 -P
The same option works when downloading files from Sync:
- rclone copy sync-webdav:/Documents ~/Documents --transfers 10 -P
You can also add --transfers 10 to an rclone sync command or a scheduled backup. This setting transfers more files at once. It won’t speed up a copy containing only one file. If transfers become slower or you see timeouts, try a lower value.