LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Networking (https://www.linuxquestions.org/questions/linux-networking-3/)
-   -   mirror windows shared over Samba to linux (https://www.linuxquestions.org/questions/linux-networking-3/mirror-windows-shared-over-samba-to-linux-287862/)

High-Hopes 02-08-2005 05:56 PM

mirror windows shared over Samba to linux
 
I'm trying to find a way to mirror a shared directory that resides on a windows 98 box to a SuSE 9.2 PRO linux box. I searched through google and this site and all similar topics call for using ssh or some similar method involving installing/running apps on the windows machine. I would like to avoid if at all possible installing anything on that machine as it is prone to crashing with excess software running (Can you picture that?) Security is not an issue; I am behind a firewall. I want this to be an automated process that does incremental updates (rsync?) every 4 hours or so. Also, while the Linux mach. is always on, the windows box isn't so maybe this would have to be taken into account when generating an automated script? I am new to Linux, so please be specific. I want the destination directory to always exactly match the source to include deleting files in the target that have been deleted from the source.

High-Hopes 02-09-2005 08:58 AM

Anyone?

High-Hopes 02-09-2005 04:07 PM

OK, I so far I've figured out how to use rsync to mirror the the win 98 folder. First, I mount the Windows share using
mount -t smbfs -o username=username,password=password //windowsbox/share /mnt/windows
then
rsync -urptq --delete-after /mnt/windows/ /home/backup
then I unmount the drive again with:
umount //windowsbox/share

Now, what I need to know is how to make script to run this as a cron job every four hours or so. I also need for this script to verify that the windows box is online before attempting the rsync. I know NOTHING about cron type stuff so if anyone could help me there, please be specific.

High-Hopes 02-09-2005 06:53 PM

I think I've got it.
I opened a text editor and inserted the following script:
#!/bin/bash
#
# Runs rsync to mirror //windowsbox/share directory to this computer
# First it mounts the directory, then checks to see if it can access a file
# If yes, then it runs rsync and unmounts the directory
#

# Mount the shared folder //windowsbox/share
cd /
mount -t smbfs -o username=username,password=password //windowsbox/share /mnt/windows
# Test to see if a directory in /share is accessible
if [ -d "/mnt/windows/directory" ]; then
# Mirror //windowsbox/share to /home/backup if yes
rsync -urptq --delete-after /mnt/windows/ /home/backup 2>&1 > /var/log/hourly_backup.log
else
echo "directory is NOT accessible"
fi
# Unmount the shared folder //windowsbox/share
umount //windowsbox/share
echo "Finished"

Next I saved the file as /usr/bin/backup.sh
Then I created another text file containing:

* 10,12,14 * * * root /usr/bin/backup.sh
and saved it as /etc/cron.d/backup
This should run the script daily at 10am, 12pm, and 2pm

Hopefully, this should work.


All times are GMT -5. The time now is 08:58 AM.