Re: Bash script - for rsync to backup file server running sa…

Top Page
Attachments:
Message as email
+ (text/plain)
+ (text/html)
+ (text/plain)
Delete this message
Reply to this message
Author: Lisa Kachold
Date:  
To: Main PLUG discussion list
Subject: Re: Bash script - for rsync to backup file server running samba.
Hi James;

On Fri, Jan 6, 2012 at 1:11 AM, James Dugger <> wrote:

> Does anyone know if a Linux server can identify windows users connected to
> the server through a Samba share, where Samba has not been configured as a
> domain controller (i.e. samba is resolving user accounts with smbpasswd
> only). Are the windows users always synced with a UNIX user?
>
> I am writing a bash script for a rather peculiar backup scenario where
> laptops running Windows 7 are backed up to a server when/if they are
> connected to the LAN using rsync. There is no local DNS server or domain
> controller installed in the LAN (other than the router which is only
> configured for DHCP service). I had planned to use the following to
> generate a list of connected users:
>
>     who | cut -d' ' -f1 | sort | uniq > /srv/backup/user.lst

>
> This list would then be read into a bash array and used to iterate the
> backup script for those known connected users. However, If I can't verify
> Windows users that are connected is there a clean non-taxing way to test
> for the mac addresses of the connected laptops over the LAN? I know that
> using:
>
>     nmap -sP <ip address range>

>
> will return the mac address along with other info, but I don't know if
> there is a way to get a clean mac address only list from scan.
>
> Any thoughts would be greatly appreciated.
>
> Thanks
>
>
> --
> James
>
>
> You can use netstat to compare with the list of mac addresses for Windows.


You can also use OCS Inventory to maintain your Windows7 mac list more
easily (so you don't have to get the mac's and hand maintain the list). It
runs a client on both linux and windows systems that gives all manner of
great info.

Example Flow Chart:

# netstat -antp | grep smbd

Then use:
awk $5 > $list

compare $list with your flat file list of windows7 users

and rsync away.

Full get mac address line might look like this:

netstat -an | grep :80 | awk ‘{print $4}’
or this:
netstat -an | grep :80 | awk ‘{print $4}’ | awk -F: ‘{print $1}’ | sort |
uniq

stuff into a variable:

modify this backup script snarfed from
http://stackoverflow.com/questions/4674167/helpful-suggestions-for-bash-backup-script-for-samba-shares-using-rsync
--
(602) 791-8002 Android
(623) 239-3392 Skype
(623) 688-3392 Google Voice
**
HomeSmartInternational.com
---------------------------------------------------
PLUG-discuss mailing list -
To subscribe, unsubscribe, or to change your mail settings:
http://lists.PLUG.phoenix.az.us/mailman/listinfo/plug-discuss