How to configure RSYNC task at startup?

Dear all,

I want to know if and how it’s possible to setup a RSYNC-Task at every startup. I already read that cron-jobs can do such things but I don’t seem to be linux pro enought to find out how I can trigger my already setup RSYNC-Task (via GUI) with cron shortly after TrueNas Core has booted.
The optimal case would be if I can still see the status “running”, “failed” and “ok” when I check via the GUI. This is definitive possible when I manual start the configured RSYNC-Task via GUI.

If someone need additional information, please ping me.

Thanks in advanced.
Chris

Core - Init/Shutdown Scripts | TrueNAS Documentation Hub
Scale - Advanced Settings Screen | TrueNAS Documentation Hub

Hello somethingweird,

thanks for your message. I think I already read the documentation. Unfortunatly there seems to be still no way to select my already created RSYNC-Jobs (which I have configured via the GUI). Or can you give me the correct command or the location from the script?

I also find absolute no way to “translate” the configured RSYNC-Job into a single command-line. If the line is getting displayed somehow, I can easily copy-paste it into the suggested “Command” line within the “Init/Shutdown Script” section.

Do you have a solution for it?

I can’t help you, but here manual for rsync -

https://man.freebsd.org/cgi/man.cgi?query=rsync&apropos=0&sektion=0&manpath=Darwin+8.0.1%2Fppc&format=html

It tell you what u need, comeback and ask questions

Maybe someone else can help me. Maybe there is some “hidden” method to start the already created RSYNC-Job from shell itself. I don’t want to create a new, separate RSYNC-Job. I want to use the already created ones shortly or right after system has started. I unfortunatly just don’t know how. That’s why I ask it at a TrueNAS specific forum and not an linux one.

I appreciate your support but your answers are not about my initial question.

You could create a “Startup / Init Task” that would use the command midclt call <taskname>

So you can query the job IDs with something like:

midclt call rsynctask.query | jq

When you find the number, you can create a Startup Task that runs the command, such as for Rsync Task ID #1:

midclt call rsynctask.run 1
3 Likes

Rsync is not a TrueNAS thing. It is a *nix tool.

Typically, you create a “recipe” in a config file on each client for your server to use. This allows you to keep things organized. The questions you need answers to are: how, what, when, and where

So, on each client, you’d set up a “RSYNCD (daemon)” for one part of the transfer. On the server side, you only need the rsync tool installed.

Typically the process works like this (bear with me, not working on a *nix machine so we’re free-flying here):

These are the instructions for the client side rsync to find information and etc. There are different clients and each have their own way to start a daemon.

client: /etc/rsyncd.conf (chmod 644)

secretes file = /etc/rsync.secrets
hosts allow = 192.168.1.1/24

uid = nobody
gid = nobody
list = yes
readonly = yes
use chroot = no
log file = /var/log/rsyncd.log

[mine]
path = /home/mine
comment = My directory
ignore nonreadable = yes
uid = 555
gid = 14
auth users = mine
secrets file = /etc/rsyncd.secretes

Then you need a place to store your password (safely).
client: /etc/rsync.secrets (owned/read by root only – chmod 600).

mine:password

Then on the server side, you store passwords

create a secretes file with: (owned/read by root only – chmod 600) which looks like this:

a_user:client-password
another_user:client-password

Now your server knows how and what to get, you just need to tell it where to put it and when.

You could set up a cron task to do it or even create a rc.d script to do it:

rsync -avzz --stats --password-file=rsync.secretes user@machine::mine backup\backup-mine\

Forgive any mistakes (and I didn’t proof-read what I just typed much so take it with a grain of salt; this was more to give you a 10,000 foot overview of the process).

What are you doing (what is: ‘rsync-task gui’)?

My eyes deceive me.

rsync-tasks-truenas-gui

*Rsync was not developed by TrueNAS (and only used in TrueNAS settings). -i.e. you can get help in any number of *nix flavors but they all should say the same thing.

EDIT:
Also, that must be the ‘GUI’ starbase was talking about.

It’s not an Rsync question. It’s about keeping things within the GUI/middleware, while automating a configured task (in the GUI) to run at system startup.

Hence, this post.

Ah, got it. I will stop stepping on toes and grab some popcorn instead.

I apologize for the diversion.

thx @winnielinnie. Exactly what I was looking for! I try to figure out why I wasn’t able to find this command “midclt” before. I checked the docu but I didn’t find anything about it. Even there seems to be not man page about “midclt” implemented. Do you have a proper documentation with all possibilities of that command?

Also, that must be the ‘GUI’ starbase was talking about.

Correct @John. Maybe my initial description was somehow misunderstandable? I will better my self if this might be the case. Just need someone to inform me what exactly was misunderstandable or not specific enought.

Oh, no it was mostly just me. I used to have file servers with all the different flavors of BSD (Net/Open/Free) and when I had kids a few years ago I adopted TrueNAS so I could click buttons instead of doing things more manually. My knowledge is more based on those manual methods (not worth much–feel free to ignore me; most do). I didn’t know there was a “TASK” for rsync (not sure how it works; it may just set up the config files–or more than likely, uses a database somehow).

Again, sorry for the interruption. Glad you got it figured out.

midclt --help will show you all the commands you can use. The most interesting being call.

If you use the format taskname.query, it essentially reads the database config, which is more “readable” if you pipe it through jq, since it is in JSON format.

If you use the format taskname.run, it informs the middleware to run the task with the matching numeric “ID”.

Using midclt keeps everything contained / integrated with the middleware/GUI. That’s why it will properly show up in your “Tasks” in the top right corner. Simply using commands (such as rsync or zfs) will not register with the middleware.

You can browse the API here.

1 Like