Bash script shared folder

Being a beginner, I cannot send the backup to my trunas server (shared folder in smb) with the following script bash line: backup_dir=“/”
The backup is only done on my own Debian 11 machine and not on my shared truenas folder.
Do you have a solution for me?

That’s more than enough information to work with. :+1: I’ll try to devise a solution to your problem as soon as possible.

1 Like

Bonjour, i mean that i have a complete script but it is not working when i try to sent the backup to my truenas share folder.
My question is IF the link line of this piece of the script IS correctly written to send the backup on the server?
backup_dir="/ or backup_dir=\

This entirely depends on what the rest of the script tries to do with that variable.

Unless you post the entire script it’s all guesswork.


if [ "$EUID" -ne 0 ]; then
  echo "this script must be turn in root."
  exit 1


mkdir -p "$backup_dir"

timestamp=$(date +"%Y%m%d_%H%M%S")

for user in /home/*; do
   if [ -d "$user" ]; then
        echo "User found : $(basename $user)"

    tar -czvf "$backup_file" "$user_dir"
    echo "Sde de $user in $backup_file"
echo "Backup successful.

This does not work that way. You need to mount the NAS directory from your Linux machine, first.

See the section on mounting in the documentation.

Hi, it’s already done the mount.

Then set backup_dir to the location of the mount and remove the mkdir command below that line.

this way : backup_dir=“/” or this  : backup_dir=“/user@” ???
I've delete mkdir...



Sans titre2

That looks like a Windows screen shot.

Where did you mount that share in your Linux machine? I.e. what is the output of mount in a shell on that Linux client?

Yes on linux,
I show you this screen shot in order to explain that I can connect to this share folder on win10 but not with the bash script. i’ve been trying this issu for a week.

You need to mount the folder from outside the bash script and use the local mount path from inside the bash script.

Where did you mount it? You said you had already done the mount? So where is it mounted?

sudo mount -t cifs ... something something - you did that, right?

Again: please post the output of the mount command on your Linux client.

Mount on truenas VM


1 Like

Not on TrueNAS. You said you had mounted the share on your Linux desktop. That is what you must do. For how to do that refer to the documentation of your Linux distribution or the hints on “mounting” that I linked above.

You cannot access the share “dynamically” inside a shell script. You need to perform a mount of the share to a local directory on the Linux client and then use that directory as the target for your backup. Two steps. Might be integrated in the bash script, but first get the mount done.

You still owe me the output of the mount command on your Linux client :unamused:

On your Linux client in a shell type


Copy the output as text here, please.


Hello. This is WinnieGPT. The above command is invalid. You need to use the command mount instead of M O U N T

Thank you for trying the demo of WinnieGPT. You have 19 days remaining on your free trial.

1 Like

Mr. Winnielinnie? We have a preliminary shooting order …

1 Like