Skip to main content

Backup to WebDAV using rclone on OSX & Linux

Before proceeding, please ensure that you have had a backup storage pool created under bks-{your username}. If you do not, contact GRIT support to get this setup first.

Step 1: Install rclone

  1. From the terminal run the following command to install rclone 
    sudo -v ; curl “https://rclone.org/install.sh” | sudo bash

Step 2: Configure rclone

  1. Run the following command to set up the Nextcloud WebDAV link 
    rclone config
  2. Enter n to set up a new remote storage connection, and give the remote connection a namerclone_cfg1.png
  3. To connect to WebDAV, enter webdavrclone_cfg2.png
  4. Enter the URL to the Nextcloud WebDAV URL found in your Nextcloud Storage WebUI. Ex: https://nextcloud.grit.ucsb.edu/remote.php/dav/files/{username}/bks-{username}rclone_cfg3.png
  5. Enter nextcloud to set Nextcloud as the WebDAV provider thenrclone_cfg4.png
  6. Enter your Nextcloud usernamerclone_cfg5.png
  7. Enter your App password set in Nextcloud documented here, then confirm the password (Settings > Security .. scroll to the bottom to create App Password)rclone_cfg6.png
  8. Press enter to leave the Bearer Token blank, and enter n to skip the Advanced Config
  9. Confirm your setup by entering y to keep your Nextcloud Remote connectionrclone_cfg7.png
  10. Enter q to exit the config
  11. Test your rclone setup by running
    rclone copy -v -P /local storage path/ Nextcloud:Backup

    rclone_cfg9.png

Nextcloud:Backup will create a folder called Backup in the parent directory set up in Step 4 IE: https://nextcloud.grit.ucsb.edu/remote.php/dav/files/{username}/bks-{username}/Backup

Optional rclone parameters as shown above:
  • –backup-dir Nextcloud:Old
    • This will create a separate folder named “Old” in the parent directory configured above that will keep 1 revision of any files edited since the last backup. This revision is only replaced if the source file is edited again.
  • –exclude-from={path to filter txt file}
    • Creating this file will allow you to create folder/file filters for any directories or file types you do not want backed up with rclone.rclone_cfg8.png

Basic Example:

/nobackup/**
  • The above will exclude a folder named nobackup, including all sub directories and files therein under the designated source backup folder configured in step 11. IE home/mdkey/Desktop/backmeup/nobackup/
Running rclone on a schedule with crontab:
  1. Open Terminal and run 
    crontab -e
  2. Use the same rclone copy command above. The following example is set to run at 07:00 & 19:00
    PATH=/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin 0 7,19 * * * rclone copy -v -P /path/to/backup/source/ Nextcloud:Backups –backup-dir Nextcloud:old