Click to See Complete Forum and Search --> : Backupscript for backing up linux to Windows


NorMan-drake9
02-09-2004, 07:07 AM
I created this scipt to backup my Linux box to a Windows box., using Debian - unstable, W2K Pro and Windows Server 2003.

For Samba I used a credentials file. The format of the credentials file is like this:

username = username
password = password

Some additional notes. The back up user must have an account and the proper permisions set on the folder you are backing up to on the computer you are backing up to.

I gave you the option of using smbclient or FTP to do the backup. If you use FTP, IIS must be installed and configured ( though I suppose one could use MS PWS [Personal Web Server]). To do this with Samba, Samba server and smbclient nust be installed. I used Samba 3.0, but older versions should work.

Good Luck!!!!!

Drop me an email "nvbauer at myrealbox dot com" with your questions or comments. I'm always looking to improve the code.




#! /bin/bash
################################################## ###
## script created by Norman V. Bauer ##
## 02/07/2004 ##
## GNU/GPL License 2004 ##
################################################## ###


#defines the variables for time stamps, there is #more than one way to do that so I put in a few

DATETIME=`date +%m-%d-%Y-%H%M`
TIME=`date +%H%M%s`
DATA=data-backup
# create a backup log file
backup_log=/backup/backup-log/backup_log
# create a backup error file
#backup_err=/backup/backup-log/backup_err

# replace old backup logs and create new ones

mv $backup_log $backup_log.old

#Give verbose output to log file
echo "-------------------------------------------" >>$backup_log
echo "# local backup #" >>$backup_log
echo "-------------------------------------------" >>$backup_log
echo "Starting Backup: $DATETIME ." >>$backup_log

cd /backup

if test -e ${DATA}.tar
then
rm ${DATA}.tar
echo "Removed old ${DATA}.tar." >>$backup_log
fi


tar -cv --file=/backup/${DATA}.tar /home /root

echo "Backup successfuly completed: $DATETIME" >>$backup_log

#backing up using samba

echo "--------------------------------------------">>$backup_log
echo "# Backing up to Windows box #">>$backup_log
echo "____________________________________________">>$backup_log

#echo "Starting Samba session $DATETIME " #>>$backup_log

#smbclient //172.16.100.5/linbackup -A #backup/buauth -c "prompt; mput
#data-backup.tar; exit"


#Using FTP instead of smbclient

#echo "Starting FTP session $DATETIME " #>>$backup_log

#ftp #-in <<EOF
#open 172.16.100.2
#user backup backup
#bin
#cd linbackup
#put data-backup.tar
#bye


echo "Samba/FTP session completed ${DATETIME}." >>$backup_log

echo "####################################" >>$backup_log
echo "# Backup operations have ended #" >>$backup_log
echo "####################################" >>$backup_log






Have fun