Grimlockz
Grimlockz

Reputation: 2581

Linux to Windows copying network script

I need to improve my method, or even change it completely, for copying files on a private network from multiple Windows machines to a central Linux machine. How this works is that I run the script below as a cron job every 5 minutes to copy data from say 10 Windows machines, all with a shared folder, to the central Linux machine that gets collected each day. So in theory the Linux machine at the end of the day should have all the data that has changed on the Windows machines.

#!/bin/sh
USER='/home/user/Documents/user.ip'
IPADDY=$USER
USERNAME=$USER
while read IPADDY USERNAME; do
mkdir /mnt/$USERNAME
mkdir /home/user/Documents/$USERNAME
smbmount //$IPADDY/$USERNAME /mnt/$USERNAME -o   username=usera,password=password,rw,uid=user
rsync -zrv --progress --include='*.pdf' --include='*.txt' --include='issues' --exclude='*' /mnt/$USERNAME/ /home/user/Documents/$USERNAME/
done < $USER

The script works fine but it doesn't seem to be the best method as a lot of the time data is not being copied across or not all the data is copied correctly.

Do you think that this is the best approach or can someone point me in a better solution?

Upvotes: 1

Views: 684

Answers (1)

Michał Šrajer
Michał Šrajer

Reputation: 31182

How about git repository? Wouldn't it be easier? You could easily also track the changes.

Upvotes: 1

Related Questions