How to sync or back up a Linux folder to Sync with Rclone

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.

Before you begin, you'll need:

Installation

  1. Install and start the Sync WebDAV server. Follow these step-by-step instructions.
  2. 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

  1. Make sure the Sync WebDAV server is installed and running.
  2. Run: rclone config create sync-webdav webdav url=http://localhost:4918 vendor=other
  3. 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.

  1. Open your crontab:
    crontab -e
  2. 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.
  3. 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.

 

 

 

 

Was this article helpful?
0 out of 0 found this helpful