Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

copying files to windows machine

Status
Not open for further replies.

symbiotic

Technical User
Jan 17, 2003
28
0
0
GB
Hi all,
I was wondering what the best solution for this is:
I have a network with one linux server, running samba, and several windows workstations. The linux box runs a mysql server. I want to create a cron job to back up the database files onto a windows machine. Is there a way to make a path to a directory on a windows box? I know I can do the reverse, make a path from the windows box to the linux machine. Perhaps there's a better solution? I thought about ftp, but it seems uneccesarily complicated for such a simple task.

As always, all input is appreciated

PS:(Yes, I know... The files are prolly safer on the Linux box, just feel better having it in two places :) )
 
oops, I accidentally posted an update to this in another thread. Please read "Ok, I found another post regarding this" before responding
 
Sure you first create a share on the Windows Server.

Second in you backup script mount the windows shares.

If you want the share to be a hidden share name it share$ (The $ will hide it)
But to mount the share make sure you share share$ also.

I would also check the return value to make
sure it mounts. Before you mount make sure it is not already mounted and when the script is finished unmount the windows server.
This is a very quick example.

ex:

#!/bin/bash

SERVER="Windows SERVER"
SHARE="SHARE on windows Server"
USER="user to attach to share"
PASS="passsword for user"
MNT="mount point for share like /mnt/server"
LOG="/var/log/backup.log"
ADMIN="you@yourdomain.com, admin2@yourdomain.com"

mount_server () {
mount | grep $SERVER

if [ $? == 0 ]; then
# Server already mounted
echo "Server already mounted.
else
smbmount //$SERVER/$SHARE $MNT -o username=$USER%$PASS
if [ $? != 0 ]; then
echo "Mount Failed!"
fi # End check mount if

fi # End mount if
}

log () {
# Log results to a log file
RESULT=$1
if [ $RESULT == 0 ] ; then
echo "Completed on `date`" > $LOG
else
echo "BACKUP FAILED!! on `date`" >$LOG
}

mail_results () {
# Email results to admins
cat $LOG | mail -s "Backup Results" $ADMIN
}

copy_data () {
cp -auPv /data $MNT

log $?
mail_results $?

}

umount_server () {
umount $MNT
}

mount_server
copy_data
umount_server
#EOF



 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top