Add SMBmount handler
Hi, we developed a handler for mounting windows shares. Its important that the whole process stops if the windows share is not mounted correctly, as we didn't want rdiff backing up the whole directory. I didn't actually write this handler, one of my ex-employees did, (I think it was Nicolas Brisac). So take it as it is, and if you like it, please feel free to include it in a newer version of backupninja
This is the handler:
$ cat smbmount.in #!/bin/sh
Mount a remote directory ('share') from a Samba server ('host')
using ('user') and ('pass') to authenticate
onto a destination directory ('mountpoint').
ATTENTION
This handler assumes that smbclient and smbfs packages are installed on the system
getconf share getconf host getconf user guest getconf pass getconf domain getconf mountpoint
auth="{user:-}
{pass:+%$pass}"
if [ ! -d "$mountpoint" ]; then halt "Destination directory does not exist" fi
if [ ! -n "smbclient -N -U $auth -L $host | awk '{print $1}' | grep -xi $share
" ]; then
halt "Unable to connect to host 'host' or source share '
share' doesn't exist"
fi
if grep $mountpoint /proc/mounts; then umount -f $mountpoint fi
options="username=user,password=
pass{domain:+,domain=
domain}"
mount -t cifs //host/
share $mountpoint -o $options || halt "Mount failed"
and the config file looks like this:
share = sharename host = windowshostname user = userwithsharepermission pass = passwordofuser
mountpoint = /mnt/mountpoint
So if that makes sense, please consider adding it to backupninja. I have more stuff to contibute as well in another feature ticket.
(from redmine: created on 2011-11-15)