From 0e8fd3398771da2f016d72830179507f3edda51b Mon Sep 17 00:00:00 2001 From: Samba Release Account Date: Sat, 4 May 1996 07:50:46 +0000 Subject: Initial version imported to CVS (This used to be commit 291551d80711daab7b7581720bcd9a08d6096517) --- source3/script/smbtar | 141 ++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 141 insertions(+) create mode 100644 source3/script/smbtar (limited to 'source3/script/smbtar') diff --git a/source3/script/smbtar b/source3/script/smbtar new file mode 100644 index 0000000000..fc032ed41c --- /dev/null +++ b/source3/script/smbtar @@ -0,0 +1,141 @@ +#!/bin/sh +# +# smbtar script - front end to smbclient +# +# Authors: Martin.Kraemer +# and Ricky Poulten (ricky@logcam.co.uk) +# +# (May need to change shell to ksh for HPUX or OSF for better getopts) + +case $0 in + # when called by absolute path, assume smbclient is in the same directory + /*) + SMBCLIENT="`dirname $0`/smbclient";; + *) # edit this to show where your smbclient is + SMBCLIENT="./smbclient";; +esac + +# These are the default values. You could fill them in if you know what +# you're doing, but beware: better not store a plain text password! +server="" +service="backup" # Default: a service called "backup" +password="" +username=$LOGNAME # Default: same user name as in *nix +verbose="2>/dev/null" # Default: no echo to stdout +log="-d 2" +newer="" +blocksize="" +tarcmd="c" +tarargs="" +cdcmd="\\" +tapefile=${TAPE-tar.out} + +Usage(){ + ex=$1 + shift +echo >&2 "Usage: `basename $0` [] [] +Function: backup/restore a Windows PC directories to a local tape file +Options: (Description) (Default) + -r Restore from tape file to PC Save from PC to tapefile + -i Incremental mode Full backup mode + -v Verbose mode: echo command Don't echo anything + -s Specify PC Server $server + -p Specify PC Password $password + -x Specify PC Share $service + -X Exclude mode Include + -N File for date comparison `set -- $newer; echo $2` + -b Specify tape's blocksize `set -- $blocksize; echo $2` + -d Specify a directory in share $cdcmd + -l Specify a Samba Log Level `set -- $log; echo $2` + -u Specify User Name $username + -t Specify Tape device $tapefile +" + echo >&2 "$@" + exit $ex +} + +while getopts rivl:b:d:N:s:p:x:u:Xt: c; do + case $c in + r) # [r]estore to Windows (instead of the default "Save from Windows") + tarcmd="x" + ;; + i) # [i]ncremental + tarargs=${tarargs}g + ;; + l) # specify [l]og file + log="-d $OPTARG" + case "$OPTARG" in + [0-9]*) ;; + *) echo >&2 "$0: Error, log level not numeric: -l $OPTARG" + exit 1 + esac + ;; + d) # specify [d]irectory to change to in server's share + cdcmd="$OPTARG" + ;; + N) # compare with a file, test if [n]ewer + if [ -f $OPTARG ]; then + newer=$OPTARG + tarargs=${tarargs}N + else + echo >&2 $0: Warning, $OPTARG not found + fi + ;; + X) # Add exclude flag + tarargs=${tarargs}X + ;; + s) # specify [s]erver's share to connect to - this MUST be given. + server="$OPTARG" + ;; + b) # specify [b]locksize + blocksize="blocksize $OPTARG" + case "$OPTARG" in + [0-9]*) ;; + *) echo >&2 "$0: Error, block size not numeric: -b $OPTARG" + exit 1 + esac + tarargs=${tarargs}b + ;; + p) # specify [p]assword to use + password="$OPTARG" + ;; + x) # specify windows [s]hare to use + service="$OPTARG" + ;; + t) # specify [t]apefile on local host + tapefile="$OPTARG" + ;; + u) # specify [u]sername for connection + username="$OPTARG" + ;; + v) # be [v]erbose and display what's going on + verbose="" + ;; + '?') # any other switch + Usage 2 "Invalid switch specified - abort." + ;; + esac +done + +shift `expr $OPTIND - 1` + +if [ "$server" = "" ] || [ "$service" = "" ]; then + Usage 1 "No server or no service specified - abort." +fi + +# if the -v switch is set, the echo the current parameters +if [ -z "$verbose" ]; then + echo "server is $server" +# echo "share is $service" + echo "share is $service\\$cdcmd" + echo "tar args is $tarargs" +# echo "password is $password" # passwords should never be sent to screen + echo "tape is $tapefile" + echo "blocksize is $blocksize" +fi + +eval $SMBCLIENT "'\\\\$server\\$service'" "'$password'" -U "'$username'" \ +-E -N $log -D "'$cdcmd'" \ +-T${tarcmd}${tarargs} $blocksize $newer $tapefile $* $verbose + + -- cgit From ddc4fc68b97f376b97c3a59febf241ace3fb8fc7 Mon Sep 17 00:00:00 2001 From: Samba Release Account Date: Wed, 19 Jun 1996 12:27:26 +0000 Subject: - deleted reduntant blank line at end of file (JHT) (This used to be commit 7960522e18bb34cba4fbc6ef0d68485d484c9cad) --- source3/script/smbtar | 1 - 1 file changed, 1 deletion(-) (limited to 'source3/script/smbtar') diff --git a/source3/script/smbtar b/source3/script/smbtar index fc032ed41c..156375ce9c 100644 --- a/source3/script/smbtar +++ b/source3/script/smbtar @@ -138,4 +138,3 @@ eval $SMBCLIENT "'\\\\$server\\$service'" "'$password'" -U "'$username'" \ -E -N $log -D "'$cdcmd'" \ -T${tarcmd}${tarargs} $blocksize $newer $tapefile $* $verbose - -- cgit From 28177ca73bdbe3f8fb17a608db3df1a39e0e37a4 Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Sat, 17 Aug 1996 11:37:44 +0000 Subject: - added support for Amiga-unix (based on BSD I think) - changed the order of PROGS and SPROGS in Makefile (SPROGS first) - another 64 bit cleanup (for INADDR_NONE) - added paranoia code in DirCacheAdd() to detect looping - fixed important DirCache flush bug - rewrote the NetServerEnum code after I found it could return servers from multiple workgroups at once, and this could cause browsing havoc. Now a null workgroup query is equivalent to a query for the servers primary workgroup - got rid of my_workgroup() - got rid of "workgroup = *" comment in Makefile. We no longer support a workgroup of *, users must set the workgroup explicitly - the wins.dat file was being stored in a different format to what it was being loaded in - this could cause havoc. fixed. - uppercase our netbios name and the workgroup name at startup - if accept fails in main loop when running as a daemon then continue, don't just exit! - don't use ./ on smbclient in smbtar - better code to detect if a process exists (This used to be commit ec3d53963064b50ff33e8eff47812aac82f164ba) --- source3/script/smbtar | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'source3/script/smbtar') diff --git a/source3/script/smbtar b/source3/script/smbtar index 156375ce9c..a947476dc6 100644 --- a/source3/script/smbtar +++ b/source3/script/smbtar @@ -11,8 +11,8 @@ case $0 in # when called by absolute path, assume smbclient is in the same directory /*) SMBCLIENT="`dirname $0`/smbclient";; - *) # edit this to show where your smbclient is - SMBCLIENT="./smbclient";; + *) # you may need to edit this to show where your smbclient is + SMBCLIENT="smbclient";; esac # These are the default values. You could fill them in if you know what -- cgit From a9e1efc1adb9a1cd85222f992c9ea03b56e74125 Mon Sep 17 00:00:00 2001 From: John Terpstra Date: Tue, 7 Oct 1997 16:01:08 +0000 Subject: JHT ==> Fixing blocksize argument. Patch by: Llyod Whiteman (This used to be commit 67c1e87e8fda724da6dd3663641639167dd33a16) --- source3/script/smbtar | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source3/script/smbtar') diff --git a/source3/script/smbtar b/source3/script/smbtar index a947476dc6..dcf01edb20 100644 --- a/source3/script/smbtar +++ b/source3/script/smbtar @@ -88,7 +88,7 @@ while getopts rivl:b:d:N:s:p:x:u:Xt: c; do server="$OPTARG" ;; b) # specify [b]locksize - blocksize="blocksize $OPTARG" + blocksize="$OPTARG" case "$OPTARG" in [0-9]*) ;; *) echo >&2 "$0: Error, block size not numeric: -b $OPTARG" -- cgit From 5b11dbd8f66040de091b705a5814566e029a6fa6 Mon Sep 17 00:00:00 2001 From: Richard Sharpe Date: Mon, 6 Jul 1998 22:25:56 +0000 Subject: Digital UNIX does not seem to set OPTIND if there are no command line parameters. Added simple code to smbtar to check for paramters and pump out a usage message if there are none. Regards Richard (This used to be commit 52cf030b9d0ea4f3b68d7a3fccfe3841930a329a) --- source3/script/smbtar | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'source3/script/smbtar') diff --git a/source3/script/smbtar b/source3/script/smbtar index dcf01edb20..20422b0334 100644 --- a/source3/script/smbtar +++ b/source3/script/smbtar @@ -54,6 +54,16 @@ Options: (Description) (Default) exit $ex } +echo Params count: $# + +# DEC OSF AKA Digital UNIX does not seem to return a value in OPTIND if +# there are no command line params, so protect us against that ... +if [ $# = 0 ]; then + + Usage 2 "Please enter a command line parameter!" + +fi + while getopts rivl:b:d:N:s:p:x:u:Xt: c; do case $c in r) # [r]estore to Windows (instead of the default "Save from Windows") -- cgit From 04c4ca1b241f3ef49e4a626c35141fea3cb1099a Mon Sep 17 00:00:00 2001 From: Richard Sharpe Date: Fri, 21 Aug 1998 09:01:30 +0000 Subject: Submitting the smbtar changes to the main branch as well. Regards Richard Sharpe (This used to be commit 749ec1e0a79c5836bba0fc0213576ed79ef761d5) --- source3/script/smbtar | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) (limited to 'source3/script/smbtar') diff --git a/source3/script/smbtar b/source3/script/smbtar index 20422b0334..25c36b2a8f 100644 --- a/source3/script/smbtar +++ b/source3/script/smbtar @@ -6,6 +6,10 @@ # and Ricky Poulten (ricky@logcam.co.uk) # # (May need to change shell to ksh for HPUX or OSF for better getopts) +# +# Richard Sharpe, added -c 'tarmode full' so that we back up all files to +# fix a bug in clitar when a patch was added to stop system and hidden files +# being backed up. case $0 in # when called by absolute path, assume smbclient is in the same directory @@ -25,6 +29,7 @@ verbose="2>/dev/null" # Default: no echo to stdout log="-d 2" newer="" blocksize="" +clientargs="-c 'tarmode full'" tarcmd="c" tarargs="" cdcmd="\\" @@ -145,6 +150,6 @@ if [ -z "$verbose" ]; then fi eval $SMBCLIENT "'\\\\$server\\$service'" "'$password'" -U "'$username'" \ --E -N $log -D "'$cdcmd'" \ +-E -N $log -D "'$cdcmd'" ${clientargs} \ -T${tarcmd}${tarargs} $blocksize $newer $tapefile $* $verbose -- cgit From 634f6c7f2841a3ee88163ff7e92b0ef3c9d7ecf0 Mon Sep 17 00:00:00 2001 From: Richard Sharpe Date: Sat, 21 Nov 1998 09:29:35 +0000 Subject: Added changes to smbtar submitted by Sandy Whitesel Added some extra documentation for smbclient Grr, Jeremy beat me to a bug fix in client.c Will have to get Jeremy to tell me how to check out SAMBA_2_0 :-) (This used to be commit 8594c4bcae503972679c55a2fcab8eb69faf3ae3) --- source3/script/smbtar | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) (limited to 'source3/script/smbtar') diff --git a/source3/script/smbtar b/source3/script/smbtar index 25c36b2a8f..203d24cf63 100644 --- a/source3/script/smbtar +++ b/source3/script/smbtar @@ -7,6 +7,8 @@ # # (May need to change shell to ksh for HPUX or OSF for better getopts) # +# sandy nov 3 '98 added -a flag +# # Richard Sharpe, added -c 'tarmode full' so that we back up all files to # fix a bug in clitar when a patch was added to stop system and hidden files # being backed up. @@ -43,6 +45,7 @@ Function: backup/restore a Windows PC directories to a local tape file Options: (Description) (Default) -r Restore from tape file to PC Save from PC to tapefile -i Incremental mode Full backup mode + -a Reset archive bit mode Don't reset archive bit -v Verbose mode: echo command Don't echo anything -s Specify PC Server $server -p Specify PC Password $password @@ -69,7 +72,7 @@ if [ $# = 0 ]; then fi -while getopts rivl:b:d:N:s:p:x:u:Xt: c; do +while getopts riavl:b:d:N:s:p:x:u:Xt: c; do case $c in r) # [r]estore to Windows (instead of the default "Save from Windows") tarcmd="x" @@ -77,6 +80,9 @@ while getopts rivl:b:d:N:s:p:x:u:Xt: c; do i) # [i]ncremental tarargs=${tarargs}g ;; + a) # [a]rchive + tarargs=${tarargs}a + ;; l) # specify [l]og file log="-d $OPTARG" case "$OPTARG" in -- cgit From 042213eb2277518a918f0687fdb2968196585638 Mon Sep 17 00:00:00 2001 From: Alexandre Oliva Date: Thu, 10 Jun 1999 10:16:26 +0000 Subject: Use ${1+"$@"} instead of $* Reported by SATOH Fumiyasu (This used to be commit 6cd8d68965734ac24effde927c689f7d5202cde1) --- source3/script/smbtar | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source3/script/smbtar') diff --git a/source3/script/smbtar b/source3/script/smbtar index 203d24cf63..f04eddc32b 100644 --- a/source3/script/smbtar +++ b/source3/script/smbtar @@ -157,5 +157,5 @@ fi eval $SMBCLIENT "'\\\\$server\\$service'" "'$password'" -U "'$username'" \ -E -N $log -D "'$cdcmd'" ${clientargs} \ --T${tarcmd}${tarargs} $blocksize $newer $tapefile $* $verbose +-T${tarcmd}${tarargs} $blocksize $newer $tapefile '${1+"$@"}' $verbose -- cgit From 3db52feb1f3b2c07ce0b06ad4a7099fa6efe3fc7 Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Mon, 13 Dec 1999 13:27:58 +0000 Subject: first pass at updating head branch to be to be the same as the SAMBA_2_0 branch (This used to be commit 453a822a76780063dff23526c35408866d0c0154) --- source3/script/smbtar | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) (limited to 'source3/script/smbtar') diff --git a/source3/script/smbtar b/source3/script/smbtar index f04eddc32b..cf3ff0ebe6 100644 --- a/source3/script/smbtar +++ b/source3/script/smbtar @@ -30,7 +30,9 @@ username=$LOGNAME # Default: same user name as in *nix verbose="2>/dev/null" # Default: no echo to stdout log="-d 2" newer="" +newerarg="" blocksize="" +blocksizearg="" clientargs="-c 'tarmode full'" tarcmd="c" tarargs="" @@ -62,7 +64,7 @@ Options: (Description) (Default) exit $ex } -echo Params count: $# +# echo Params count: $# # DEC OSF AKA Digital UNIX does not seem to return a value in OPTIND if # there are no command line params, so protect us against that ... @@ -97,7 +99,7 @@ while getopts riavl:b:d:N:s:p:x:u:Xt: c; do N) # compare with a file, test if [n]ewer if [ -f $OPTARG ]; then newer=$OPTARG - tarargs=${tarargs}N + newerarg="N" else echo >&2 $0: Warning, $OPTARG not found fi @@ -115,7 +117,7 @@ while getopts riavl:b:d:N:s:p:x:u:Xt: c; do *) echo >&2 "$0: Error, block size not numeric: -b $OPTARG" exit 1 esac - tarargs=${tarargs}b + blocksizearg="b" ;; p) # specify [p]assword to use password="$OPTARG" @@ -155,7 +157,8 @@ if [ -z "$verbose" ]; then echo "blocksize is $blocksize" fi +tarargs=${tarargs}${blocksizearg}${newerarg} + eval $SMBCLIENT "'\\\\$server\\$service'" "'$password'" -U "'$username'" \ -E -N $log -D "'$cdcmd'" ${clientargs} \ -T${tarcmd}${tarargs} $blocksize $newer $tapefile '${1+"$@"}' $verbose - -- cgit From 1cee6e571ee39ef917f2c8972f6a6d5d38074363 Mon Sep 17 00:00:00 2001 From: Herb Lewis Date: Tue, 10 Dec 2002 21:56:21 +0000 Subject: fix broken incremental tar - merge from 2.2 found by "Jacob Anawalt" (This used to be commit cfef980566f195c060c0d2fa22983427e8d6570c) --- source3/script/smbtar | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'source3/script/smbtar') diff --git a/source3/script/smbtar b/source3/script/smbtar index cf3ff0ebe6..f062cba9f0 100644 --- a/source3/script/smbtar +++ b/source3/script/smbtar @@ -80,7 +80,8 @@ while getopts riavl:b:d:N:s:p:x:u:Xt: c; do tarcmd="x" ;; i) # [i]ncremental - tarargs=${tarargs}g + tarargs=${tarargs}ga + clientargs="-c 'tarmode inc'" ;; a) # [a]rchive tarargs=${tarargs}a -- cgit From ad40c8a1f4ba99b1cbafb9218994c4dc2447187b Mon Sep 17 00:00:00 2001 From: Gerald Carter Date: Thu, 15 Jan 2004 17:18:39 +0000 Subject: BUG 958; don't use the -N option when invoking smbclient from the smbtar script (This used to be commit c51eaec4f09d9c191c6b24dadb1d12770b368da0) --- source3/script/smbtar | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source3/script/smbtar') diff --git a/source3/script/smbtar b/source3/script/smbtar index f062cba9f0..67a794553c 100644 --- a/source3/script/smbtar +++ b/source3/script/smbtar @@ -161,5 +161,5 @@ fi tarargs=${tarargs}${blocksizearg}${newerarg} eval $SMBCLIENT "'\\\\$server\\$service'" "'$password'" -U "'$username'" \ --E -N $log -D "'$cdcmd'" ${clientargs} \ +-E $log -D "'$cdcmd'" ${clientargs} \ -T${tarcmd}${tarargs} $blocksize $newer $tapefile '${1+"$@"}' $verbose -- cgit