Skip to content

Instantly share code, notes, and snippets.

@Murgio
Last active September 25, 2021 05:32
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save Murgio/6043cdd0581872ce983c5a6aec5470ab to your computer and use it in GitHub Desktop.
Save Murgio/6043cdd0581872ce983c5a6aec5470ab to your computer and use it in GitHub Desktop.

Install rclone and set up a cron job

Getting started

  1. Install rclone: $ curl https://rclone.org/install.sh | sudo bash
  2. Configure rclone: $ rclone config
  3. Install git: $ sudo apt-get install git
  4. Clone the following repo into home dir: $ git clone https://github.com/wolfv6/rclone_jobber.git
  5. Create a script for the cron job by copying the following code and don't forget to replace source and dest: $ touch rclone_cron.sh
#!/usr/bin/env sh

source="/home/muriz"
dest="mygoogledrive:UBUNTU"
move_old_files_to="dated_directory"
options="--transfers 6"

$rclone_jobber/rclone_jobber.sh "$source" "$dest" "$move_old_files_to" "$options" "$(basename $0)"
  1. Make the file executable: $ chmod a+x rclone_cron.sh
  2. Add the script to a cron job and paste the following line (and dont' forget to replace the file path): $ crontab -e
15 2,14 * * * /home/muriz/rclone_cron.sh >/dev/null 2>&1

Note: 15 2,14 indicates that the cron job will start every day at 02:15 and 14:15, thus making two backups per day.

Change the argument according to your needs. Helpful guide is available under: https://www.ostechnix.com/a-beginners-guide-to-cron-jobs/

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment