📚 LinuxDocs
Topics:
All Pages8021X HOWTOACP ModemACPI HOWTOADSL Bandwidth Man..ATA RAID HOWTOATM Linux HOWTOAX25 HOWTOAccessibility Dev ..Accessibility HOWTOAdv Bash Scr HOWTOAdv Routing HOWTOAntares RAID sparc..Apache Compile HOWTOApache WebDAV LDAP..Assembly HOWTOAstronomy HOWTOAthlon Powersaving..Authentication Gat..Autodir HOWTOAviation HOWTOAvr Microcontrolle..BRIDGE STP HOWTOBTTVBackspaceDeleteBandwidth Limiting..Bangla HOWTOBash Prompt HOWTOBattery PoweredBelarusian HOWTOBelgian HOWTOBeowulf HOWTOBocaBogoMipsBootdisk HOWTOBridgeC++ dlopenC C++Beautifier HO..C editing with VIM..CDROM HOWTOCDServer HOWTOCable ModemCaudium HOWTOClone HOWTOCompaq Remote Insi..Compaq T1500 HOWTOConexant+Rockwell ..Cryptoloop HOWTODB2 HOWTODHCPDSL HOWTODVD Playback HOWTODebian Binary Pack..Debian JigdoDebian and Windows..Disk Encryption HO..Disk on Chip HOWTODocBook Demystific..DocBook InstallDocBook OpenJade S..Ecology HOWTOEmacspeak HOWTOEncourage Women Li..Encrypted Root Fil..Euro Char SupportEvent HOWTOFedora Multimedia ..Finnish HOWTOFirewall PiercingFlash Memory HOWTOFont HOWTOFramebuffer HOWTOGCC HOWTOGIS GRASSGlibc Install HOWTOHOWTO HOWTOHOWTO INDEXHP HOWTOHandspring VisorHard Disk UpgradeHardware HOWTOHighQuality Apps H..Home Electrical Co..IBM7248 HOWTOIO Perf HOWTOIP AliasIP Masquerade HOWTOIRCImplement Sys Call..Indic Fonts HOWTOInfrared HOWTOIngresII HOWTOInstall StrategiesInstallation HOWTOInstallfest HOWTOIntkeybItalian HOWTOJabber Server Farm..JavaStation HOWTOKerberos Infrastru..Kernel HOWTOKerneldKodak Digitalcam H..LDAP HOWTOLDP Reviewer HOWTOLILO crash rescue ..LVM HOWTOLeased LineLegoLinksys Blue Box R..Linux+Win95Linux+Win9x+Grub H..Linux+Windows HOWTOLinux Complete Bac..Linux Crash HOWTOLinux Gamers HOWTOLinux Modem SharingLinux Promise RAID..Linux i386 Boot Co..LinuxGL QuakeWorld..Lotus DominoR5MILO HOWTOMMBase Inst HOWTOMP3 CD BurningMail User HOWTOMajordomo MajorCoo..Man PageMasquerading Simpl..Medicine HOWTOMindTerm SSH HOWTOMobile IPv6 HOWTOMock MainframeModule HOWTOModulesMotorola Surfboard..Mozilla OptimizationMulti Distro DevNCURSES Programmin..NFS HOWTONFS Root Client mi..NIS HOWTONetMeeting HOWTONetwork boot HOWTONvidia OpenGL Conf..OLSR IPv6 HOWTOOnline Troubleshoo..Oracle 9i Fedora 3..PA RISC Linux Boot..PCTel MicroModem C..PHP Nuke HOWTOPPP HOWTOPagerPalmOS HOWTOPartitionPartition Mass Sto..Partition Mass Sto..Partition RescuePine ExchangePortSlavePost Installation ..Postfix Cyrus Web ..Pre Installation C..Print2WinPrinting HOWTOProcess AccountingProgram Library HO..Proxy ARP SubnetQmail ClamAV HOWTOQmail VMailMgr Cou..Querying libiptc H..RPM HOWTOReading List HOWTORedHat CD HOWTOReliance HOWTORemote BridgingRemote Serial Cons..SCSI 2.4 HOWTOSCSI Generic HOWTOSLIP PPP EmulatorSRM HOWTOSSL Certificates H..Scanner HOWTOScientific Computi..Scripting GUI TclTkSecure CVS PserverSecure Programs HO..Security HOWTOSecurity Quickstar..Security Quickstar..Serial Laplink HOWTOSerial Programming..Slovak HOWTOSmall MemorySmart Card HOWTOSoftware Proj Mgmt..Software Release P..Sound HOWTOSpam Filtering for..Speech Recognition..SquashFS HOWTOSybase ASA HOWTOSybase ASE HOWTOSybase PHP ApacheTCP Keepalive HOWTOTamil Linux HOWTOTimePrecision HOWTOTimeSys Linux Inst..Token RingTraffic Control HO..Traffic Control tc..UPS HOWTOUnix Hardware Buye..Unix and Internet ..UpgradeUsenet News HOWTOUser Authenticatio..VB6 to TclVMS to Linux HOWTOVPN HOWTOValgrind HOWTOVideoLAN HOWTOVim HOWTOVirtual WebWebcam HOWTOWikiText HOWTOWindows Newsreader..Wireless Link sys ..Wireless Sync HOWTOXDM XtermXDMCP HOWTOXFree Local multi ..XFree86 HOWTOXFree86 R200XFree86 Second MouseXFree86 Video Timi..XML RPC HOWTOXWindow Overview H..XWindow User HOWTOXinerama HOWTOXterminalsHtml singleI810 HOWTOLibdc1394 HOWTOOpenMosix HOWTOPhhttpd HOWTOPpp sshText
Next Previous Contents

11. Backing Up Windows Machines to a Linux Host

Adam Neat ( adamneat@ipax.com.au) kindly contributed the following script to back up Windows machines to a Linux host, using the smbclient utility. Adam says that it is used to backup Windows 3.x and NT machines to a Linux based DAT SCSI Drive. .:: qh88citcom.hashnode.space ::.

Adam is not proud of the coding style used here, but it works. As I like to say, "If it works and its stupid, then it is not stupid". .:: www.synology-forum.de ::. [Web Specs: Symfony] [Library: Vue.js]

Another Windows backup script, contributed by Dan Tager ( .:: fun79bio.tinyblogging.com ::. dtager@marsala.com), is provided below. Dan's script also backs up Unix machines via rsh, although that could be modified to use ssh rather easily. .:: telegra.ph ::.

In this script, the string 'agnea1' is the username on the Linux machine that does the backups. .:: www.freewebspace.net ::.


#!/bin/bash

clear
echo Initialising ...
checkdate=`date | awk '{print $1}'`

if [ -f "~agnea1/backup-dir/backup-data" ]; then

        echo "ERROR: No config file for today!"
        echo "FATAL!"
        exit 1
fi

if [ -d "~agnea1/backup-dir/temp" ]; then

        echo "ERROR: No tempoary directory found!"
        echo
        echo "Attempting to create"
        cd ~agnea1
        cd backup-dir
        mkdir temp
        echo "Directory Made - temp"
fi

if [ "$1" = "" ]; then

        echo "ERROR: enter in a machine name (ie: cdwriter)"
        exit 1
fi

if [ "$2" = "" ]; then

        echo "ERROR: enter in a SMB (Lan Manager) Resource (ie: work)"
        exit 1
fi

if [ "$3" = "" ]; then

        echo "ERROR: enter in an IP address for $1 (ie:
        130.xxx.xxx.52)" exit 1
fi


#############################################################################
# Main Section
#
#############################################################################

cd ~agnea1/backup-dir/temp
rm -r ~agnea1/backup-dir/temp/*
cd ~agnea1/backup-dir/

case "$checkdate"
in
        Mon)
                echo "Backuping for Monday"
                cat backup-data | /usr/local/samba/bin/smbclient
                \\\\$1\\$2 -I$3 -N echo "Complete"

                        if [ -d "~agnea1/backup-dir/Monday" ]; then
                                echo "Directory Monday Not found ...
                                making" mkdir
                                ~agnea1/backup-dir/Monday
                        fi

                echo "Archiving ..."
                cd ~agnea1/backup-dir/temp
                tar -cf monday.tar *                echo "done ..."
                rm ~agnea1/backup-dir/Monday/monday.tar
                mv monday.tar ~agnea1/backup-dir/Monday
                ;;


        Tue)
                echo "Backuping for Tuesday"
                cat backup-data | /usr/local/samba/bin/smbclient
                \\\\$1\\$2 -I$3 -N echo "Complete"

                        if [ -d "~agnea1/backup-dir/Tuesday" ]; then
                                echo "Directory Tuesday Not found ...
                                making" mkdir
                                ~agnea1/backup-dir/Tuesday
                        fi
                echo "Archiving ..."
                cd ~agnea1/backup-dir/temp
                tar -cf tuesday.tar *
                echo "done ..."
                rm ~agnea1/backup-dir/Tuesday/tuesday.tar
                mv tuesday.tar ~agnea1/backup-dir/Tuesday
                ;;

        Wed)
                echo "Backuping for Wednesday"
                cat backup-data | /usr/local/samba/bin/smbclient
                \\\\$1\\$2 -I$3 -N echo "Complete"

                        if [ -d "~agnea1/backup-dir/Wednesday" ]; then
                                echo "Directory Wednesday Not found
                                ... making" mkdir
                                ~agnea1/backup-dir/Wednesday
                        fi
                echo "Archiving ..."
                cd ~agnea1/backup-dir/temp
                tar -cf wednesday.tar *
                echo "done ..."
             rm ~agnea1/backup-dir/Wednesday/wednesday.tar
                mv wednesday.tar ~agnea1/backup-dir/Wednesday
                ;;

        Thu)
                echo "Backuping for Thrusday"
                cat backup-data | /usr/local/samba/bin/smbclient
                \\\\$1\\$2 -I$3 -N echo "Complete"

                        if [ -d "~agnea1/backup-dir/Thursday" ]; then
                                echo "Directory Thrusday Not found ...
                                making" mkdir
                                ~agnea1/backup-dir/Thursday
                        fi
                echo "Archiving ..."
                cd ~agnea1/backup-dir/temp
                tar -cf thursday.tar *
                echo "done ..."
                rm ~agnea1/backup-dir/Thursday/thursday.tar
                mv thursday.tar ~agnea1/backup-dir/Thursday
                ;;


        Fri)
                echo "Backuping for Friday"
                cat backup-data | /usr/local/samba/bin/smbclient
                \\\\$1\\$2 -I$3 -N echo "Complete"

                        if [ -d "~agnea1/backup-dir/Friday" ]; then
                                echo "Directory Friday Not found ...
                                making" mkdir
                                ~agnea1/backup-dir/Friday
                        fi
                echo "Archiving ..."
                cd ~agnea1/backup-dir/temp
                tar -cf friday.tar *
                echo "done ..."
                rm ~agnea1/backup-dir/Friday/friday.tar
                mv friday.tar ~agnea1/backup-dir/Friday
                ;;

        *)
                echo "FATAL ERROR: Unknown variable passed for day"
                exit 1;;

esac
###########

Here's Dan's backup script:


#!/bin/bash

BACKDIR=3D/backup
WINCMD=3D/usr/bin/smbclient

function CopyWinHost(){

# tars and gzips "windows shares" to a local directory using samba's
# smbclient
# argument 1 is the remote host window's host name
# argument 2 is the share name to be backed up

   echo $1,$2,$3
   REMOTE=3D$1
   SHARE=3D$2
   DEST=3D$3

 # create a tarred gzip file using samba to copy direct from a
 # windows pc
 # 12345 is a password.  Needs some password even if not defined on
 # remote system
   $WINCMD \\\\$REMOTE\\$SHARE 12345 -Tc -|gzip > $DEST
   echo `date`": Done backing up "$REMOTE" to "$DEST
   echo
}

function CopyUnixHost(){

# tars and gzips a directory using rsh
# argument 1 is the name of the remote source host
# argument 2 is the full path to the remote source directory
# argument 3 is the name of the local tar-gzip file.  day of week
#  plus .tgz will be appended to argument 3

   REMOTE=3D$1
   SRC=3D$2
   DEST=3D$3


   if rsh $REMOTE tar -cf - $SRC |gzip > $DEST; then
      echo `date`": Done backing up "$REMOTE":"$SRC" to "$DEST
   else
     echo `date`": Error backing up "$REMOTE":"$SRC" to "$DEST
   fi

}

# $1: win=3Dbackup windows machine, unix=3Dbackup unix machine
case $1 in
   win)
      # $2=3D remote windows name, $3=3Dremote share name,
      # $4=3Dlocal destination directory
      CopyWinHost $2 $3 $4;;
   unix)
      # $2 =3D remote host, $3 =3D remote directory,
      # $4 =3D destination name
      CopyUnixHost $2 $3 $4;;
esac


Next Previous Contents

Share or Research:

Share on FB Post to X LinkedIn 🤖 Ask AI about this