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
-
From the terminal run the following command to install rclone
sudo -v ; curl “https://rclone.org/install.sh” | sudo bash
Step 2: Configure rclone
-
Run the following command to set up the Nextcloud WebDAV link
rclone config
- To connect to WebDAV, enter webdav
- 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}
- Enter nextcloud to set Nextcloud as the WebDAV provider then
- Enter your Nextcloud username
- Enter your App password set in Nextcloud documented here, then confirm the password (Settings > Security .. scroll to the bottom to create App Password)
-
Press enter to leave the Bearer Token blank, and enter n to skip the Advanced Config
-
Confirm your setup by entering y to keep your Nextcloud Remote connection
-
Enter q to exit the config
-
Test your rclone setup by running
rclone copy -v -P /local storage path/ Nextcloud:Backup
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.
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:
- Open Terminal and run
crontab -e
- 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