#!/bin/bash
BDIR=/home/backup
SWIN=/tmp/s-win

[ -d "${BDIR}" ] || mkdir "${BDIR}"
[ -d "${BDIR}" ] || mkdir "${BDIR}/s-win"
[ -d "${SWIN}" ] || mkdir "${SWIN}"

mount -t cifs -o ro,vers=3.0,username=u-backup,password=Azerty1+ //s-win/commun "${SWIN}"
if [ $? != 0 ] ; then
	echo "$0 : erreur montage ${SWIN}"
	exit 1
fi
rsync -av "${SWIN}/" "${BDIR}/s-win/commun"
umount "${SWIN}"


mount -t cifs -o ro,vers=3.0,username=u-backup,password=Azerty1+ //s-win/public "${SWIN}"
if [ $? != 0 ] ; then
	echo "$0 : erreur montage"
	exit 2
fi
rsync -av "${SWIN}/" "${BDIR}/s-win/public"
umount "${SWIN}"

exit 0

