Backup Windows share to Freenas

Status
Not open for further replies.

bassmann

Dabbler
Joined
Oct 18, 2017
Messages
17
Hi - I've been working on creating a script to backup files from a Windows computer on my network to a Backup Dataset I've created on FreeNAS 11.1

The approach I've taken is a to mount the share, tar and finally unmount. The commands are working when entered one at a time manually but I'm having issues when the same is run from the script.

What I think is happening is the script is running to the next step / command before completing the prior.
for e.g. The tar file is incomplete. I suspect the unmount occurs whilst the tar command is still running.

If I'm right, what can be done to ensure steps complete before moving to the next? Alternatively, am i approaching this task the right way?

Code:
#!/bin/bash
mount_smbfs -N -I 10.0.0.10 //user@Server/Share /mnt/Server/Share
tar --exclude /mnt/Server/Share/FolderX -zcvf /mnt/Pool/Backup/X/Y/Z.tar.gz /mnt/Server/Share
umount /mnt/Server/Share
 

Jailer

Not strong, but bad
Joined
Sep 12, 2014
Messages
4,977
Wouldn't it be easier to just run Synctoy on windows on a schedule and sync over SMB to your dataset?
 

bassmann

Dabbler
Joined
Oct 18, 2017
Messages
17
It would be easier but this would be a file copy right?
I want a zipped archive created which is why i opted for tar.
 

MrToddsFriends

Documentation Browser
Joined
Jan 12, 2015
Messages
1,338
What I think is happening is the script is running to the next step / command before completing the prior.
for e.g. The tar file is incomplete. I suspect the unmount occurs whilst the tar command is still running.

Unless something totally unexpected (for me) happened during the last years a call to tar as used in your small script blocks the caller until the operation is finished, i.e. it is a so-called synchronous call.

Apart from that (just as Jailer recommended) I would implement the backup on the Windows/client side, not on the FreeNAS/server side. If the tar format is a requirement (instead of an example) I'm sure there are many Windows tar ports available, apart from other tools that are able to write the (very simplistic) tar file format.
 

Jailer

Not strong, but bad
Joined
Sep 12, 2014
Messages
4,977
Or have it synced over smb and tar’d via a script run on FreeNAS side if that is an option.
 
Status
Not open for further replies.
Top