Help with backing up from ubuntu to truenas

Hello everyone!!!
i m new on truenas but learning about this amaizing world and thanks to Tom and his videos, help me a lot.
I have a truenas core and plan to use like backup systems, and a ubuntu server with all my services and apps. i need backup from ubuntu to truenas but both systems have differents users.
Some questions:

  1. is truenas the nfs server? since i made a nfs share folder where i must put the backups from ubuntu.
  2. using rsync how to add credential to allow me connect? i made the same via smb and all well since i define in the /etc/fstab… my credencials.
    Sorry for my english.
    And thanks again
  1. Yes, the NFS server would be truenas.

  2. You can create an fstab to connect to you NFS share from you Ubuntu.

Something like this.  /mnt/NAS  nfs username=administrator,password=pass  0 0

For SMB, I configured Truenas core with SMB

On Linux
//truenas/share /home/user/share cifs guest,uid=user,gid=user,auto 0 0

thanks for ur reply.
those username and pass are from truenas, right??

and must i have installed some nfs-client on ubuntu??? i using ubuntu 22.04. I mention this cause last night doing some test i mount a nfs on fstab and after doing i realice that my apache dont start, but was late and dont dive into that. After remove from fstab all running well.

Yes that would be the username and password for Truenas. This is how I mount my TrueNAS drive from Mint (note I am mounting it read only, as I’m just updating this machine from the NAS)

sudo mount -t cifs -o ro,username="mytruenasuserlogin",password="mytruenaspassword" // /media/NASBackup

All this stuff just sits in a script, but then rsync runs like normal:

rsync -avih --progress --delete-during "/media/NASBackup/Bookmarks Backup/" "/media/MainBackup/Bookmarks Backup"

Why not just let Rsync on the TrueNAS server pull the contents of the folder from the Ubuntu server via SSH? This saves you having to deal with an SMB share, and another advantage is that the backup is then virtually immutable as the Ubuntu server cannot access it.

Like i said on the post i already have a smb mount, just trying to use nfs. Thnks for Ur reply

Can you explain better, i was trying but i cant get access. If i use these method still i have to set a nfs mount?? AND in that case i should install a nfs cliente???

For what i understud, i shared a nfs folder on truenas, so this Is the nfs server. Then i mount a folder on Ubuntu pointing to shared nfs on truenas , this Is the right way.

AND then what???

In the particular case u propose If truena pull the data, then should i have a shared forder on Ubuntu???
Or use SSH to get access to ubuntu server AND be able to reach the backups folder AND pull from here?
AND any Time a make a backups just set destination in backups folder on the same Ubuntu. On other Worlds Ubuntu make a backups in His own folder AND truenas pull the data since he can access vía SSH. That’s correct???



I mean, at the end of the day, it depends on what exactly you are trying to backup whether this method is suitable or not. But in general, yes. The TrueNAS server would then connect to your Ubuntu server via SSH and rsync a specific folder/path on your Ubuntu server to your NAS. On TrueNAS Core you can find this option under Tasks → Rsync Tasks.

Of course, you could also follow your original plan to use SMB or NFS. However, in that case, especially if the folder in question is already a backup folder, it could also make sense to put that folder directly on the share mount, instead of rsyncing it from it’s original location to the mounted share. But again, it depends on the exact use case which method is the best to use.

Thanks you a lot for take a time and explain to me, very very helpfull.

This´s what i did:
i used ssh for get access to ubuntu sever, first generate a key-pair with ssh-keygen inside my .shh folder (truenas/root), then on ubuntu i put the public key,this way no need to write pass, since i need use a cron job. after that make a cron-jon in truenas and put this scripts: rsync -avz /mnt/storage/backups/, and work perfect!!!.
About security: should i use a root user or maybe create/use another user to make the connection?
Note: i was trying to use the generate key ssh GUI of truenas but never work for me, like said before i have to generate. Or thinking while i write this …i should have toget those key-pair generated by GUI and put them inside .ssh folder?

I thought that this only work for same systems, but reading u,im trying to figured out how to set all option in Task->Rsync Task. A little confuse with the source and remote, since in my “escenario” source =remote and remote=truenas, tht’s correct?

Let me put it this way: Best practice is always to follow the principle of least privilege, so I’d say the general answer would probably be yes. But in the end, it’s of course up to you to decide and assess the risk for your specific usecase and environment.

Yeah it’s a little confusing, and no it’s actually the other way around.

Under Source you define the path on your TrueNAS box where the backup should be stored and then you need to set the Direction to Pull. You can also set a Schedule in this section, so there’s no need to manually set a cron job.

Under Remote you need at least to set the following:

Remote Host: <username>@<IP_OF_THE_UBUNTU_SERVER>
Rsync Mode: SSH
Remote Path: The path to the folder you want to pull from your Ubuntu server.

More Options: Set the Rsync options to your needs

Oh, and by the way. SSH keys can also be created via the UI under System → SSH Keypairs.

yes i wrote about this… i created a ssh key via UI, but reading about it (at this point u must know im new on this world ) i most have them inside my .ssh folder but always empty, thats why i have to created them. Maybe doing something wrong.

Actually testing…thanks for ur help !!!, and sorry for delay to replay, my connection is very slow.

In order to pull the folder from your Ubuntu server, the TrueNAS box needs to connect to your Ubuntu server via SSH. So you need to put the public key from the kepair you created on the TrueNAS box io the authorized_keys in in the .ssh folder on your Ubuntu server.

maybe is my english, yes i made that way but never connect cause when i look inside my .ssh folder on truenas was empty none key there. So i had to create via ssh-keygen and then copy the public key to ubuntu.
Maybe doing something wrong. i will repeat the proccess and now i know that is posible connecting i will try figured out whats wrong.
for some clarification when u says:

put the public key from the kepair you created on the TrueNAS box into the .ssh folder on your Ubuntu

that mind copy the public key content inside the file authorized_keys in .ssh folder on ubuntu., right?

And one last question, this way a can backup from the server, but also i have AD setting on truenas, should i follow this same protocol for the client pc (windows) on my domain ? Actually i have a mapped drive (smb shared) where all user of the domain acccess and copy their stuff.

Yes, you’re right. I have edited / clarified my previous post.