How to setup periodic sync in Windows 10

What is the problem you are having with rclone?

I'm trying to setup a periodic job for rclone to run my sync command every 5 minutes or so. I found a similar thread here but I'm making my own thread to clear up a few concerns.

  1. Is the batch script written in the link above correct? If so, how can I change it to 5min instead of 5 seconds?
  2. How can I add a line to the script that prevents the script to run if it is already running?

What is your rclone version (output from rclone version)

rclone version

rclone v1.53.3
- os/arch: windows/amd64
- go version: go1.15.5

Which OS you are using and how many bits (eg Windows 7, 64 bit)

Windows 10

Which cloud storage system are you using? (eg Google Drive)

Google Drive

The command you were trying to run (eg rclone copy /tmp remote:tmp)

rclone sync "C:/Users/XXX/google-drive" "gcrypt:/" --exclude node_modules/ --log-file "C:/Users/XXX/Documents/Rclone Latest Logs/rclone_$(get-date -f yyyy-MM-dd).log" --fast-list --verbose --stats 1m0s --progress

hi,

  1. i wrote that script.
    it uses timeout command.
    run this for help timeout /? and you will get the help text
    for 5 minutes, change the /T parameter to a value of 300

  2. using task scheduler, there is a dropbox, 'do not start new instance`

2 Likes

The easiest way I have found is to point the scheduler to open rclone.exe and paste my command into the arguments statement. Remember to select the user who has the config file. Also for debugging I have added at the end:

--log-file C:\path\log.log --log-level DEBUG

image
image


image
image
image

2 Likes

well, the best way is to use a batch file and point task scheduler to that batch file.
that way, you can tweak/test the batch file as needed, run it without task scheduler.
if you want to know about, let me know.

2 Likes

Thank you!

Can I just use the command I wrote in the OP instead of your rclone.exe line? (Keep in mind I do have rclone.exe added to my PATH)

Also, have you ever tried using rclone for local backups (e.g. windows to external HDD) too? Is it as efficient?

imho, you are free to do as you please, but i always use a batch file.
and when ready, i will point tasksch to that batch file.
if you could suggest a reason not to, let me know?

backup is a fuzzy word.
if you want a very simple file copy from local to local, sure, rclone can do that.

2 Likes

Imho, you are free to do as you please, but i always use a batch file.
and when ready, i will point tasksch to that batch file.
if you could suggest a reason not to, let me know?

I would still use a batch file (I have to lookup how to make one) but I want to use the script above inside it. That's possible right?

yes,

  1. using notepad, create a simple text file named whatever.cmd, change whatever to whatever name you want.
  2. paste that rclone command into that text file.

run the batch file.

  1. via command line,
  2. double-click from windows explorer.
1 Like

Okay, I'll try that. Thanks again :+1:

Yes @asdffdsa, I agree the batch script method would be best. I have used a batch script complied to exe but unfortunately virus scanner removed it, so kept it simple for now.

For a one-liner I prefer the easiest method I outlined, but I am developing a more complex batch script for other tasks so will point the scheduled task to a script instead, to use more complex commands, such as log rotation.

Batch scripts in Windows is still new to me as I do a lot more scripting on my NAS box running linux (it mounts my Windows drive and pulls data that way). I used to use dedicated back-up software but prefer the cleaner, more powerful and light-weight rclone instead, hence my dive into scheduled tasks using rclone. Plus the native app encryption is great.

Thank you.

perhaps use python, as that is what i do.
it runs on linux and windows.

on windows, i compile that python script to a .exe.

1 Like

OK I will look into this for my holiday task.

Thanks

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.