Forum Moderators: bakedjake

Message Too Old, No Replies

Shell Script - making sure smbmount has happened

         

Nutter

12:59 pm on Jul 17, 2006 (gmt 0)

10+ Year Member



I've got a script that runs every night as a backup, rsync'ing about 50 gigs to a remote server. I realized last night that if for some reason the smbmount command fails (two of the folders I'm backing up are on Windows machines, but my Linux server is performing the backup) then the --delete command in rsync causes all the files on the remote to be deleted for that mount.

Right now I run this snippet several times for each folder.


smbmount //windows1/share //mnt/backups/windows1 -o username=blah,password=blah,uid=blah,gid=blah
rsync ... all the commands ...
smbumount //mnt/backups/windows1

I'd like some sort of if (smbmount ...yada yada...) then { rsync ... } if that's possible.

lammert

1:07 pm on Jul 17, 2006 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



I expect smbmount to return an exit code when it fails to connect, although the man pages do not mention it. You can check this exit code in a shell script just after the execution of smbmount. It is stored in the $? special parameter.

Another method is to access a file on the remote share in your shell script between the smbmount and the rsync. If the file exists, you proceed with the rsync.

mcavic

9:41 pm on Jul 17, 2006 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



access a file on the remote share in your shell script between the smbmount and the rsync

That's what I would do.

Nutter

3:28 am on Jul 18, 2006 (gmt 0)

10+ Year Member



That's what I would do.

And it's what I did :-) Once I figured out the correct way to do the if / then it was remarkably easy.