From owner-freebsd-questions Fri Jun 16 0:33:35 2000 Delivered-To: freebsd-questions@freebsd.org Received: from kestrel.prod.itd.earthlink.net (kestrel.prod.itd.earthlink.net [207.217.121.155]) by hub.freebsd.org (Postfix) with ESMTP id 9D2C937BD28 for ; Fri, 16 Jun 2000 00:33:32 -0700 (PDT) (envelope-from cjc@earthlink.net) Received: from dialin-client.earthlink.net (pool0142.cvx21-bradley.dialup.earthlink.net [209.179.192.142]) by kestrel.prod.itd.earthlink.net (8.9.3-EL_1_3/8.9.3) with ESMTP id AAA14613; Fri, 16 Jun 2000 00:33:29 -0700 (PDT) Received: (from cjc@localhost) by dialin-client.earthlink.net (8.9.3/8.9.3) id AAA00309; Fri, 16 Jun 2000 00:32:06 -0700 (PDT) Date: Fri, 16 Jun 2000 00:31:35 -0700 From: "Crist J. Clark" To: Danny Cc: freebsd-questions@FreeBSD.ORG Subject: Re: shell scripting and Samba Message-ID: <20000616003135.A287@dialin-client.earthlink.net> Reply-To: cjclark@alum.mit.edu References: <00061712140108.00338@desktop.freebsd.org> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Mailer: Mutt 1.0.1i In-Reply-To: <00061712140108.00338@desktop.freebsd.org>; from dannyh@idx.com.au on Sat, Jun 17, 2000 at 12:06:15PM +1000 Sender: owner-freebsd-questions@FreeBSD.ORG Precedence: bulk X-Loop: FreeBSD.ORG On Sat, Jun 17, 2000 at 12:06:15PM +1000, Danny wrote: > -Hello > - I am trying to automate my backup instead of manually tar cvf whatever > > What the script should do is the following ;- > 1) make a tar file of the user home directory > 2) copies it to the backup directory > 4) This tar file should rotate like so in the backup directory > > $username1.tar.gz > $username2.tar.gz > $username3.tar.gz > $username1.tar.gz (overwritting username1 from the beginning) > > 3) in smb.conf in [home] root postexec /usr/local/etc/backup.sh > > Here is the copy of my script:- > > #!/bin/sh > # Danny 15/6/00 > > # Checks if /home/backup exists > > if [ ! -f /home/backup ]; then > cd /home/$user/ > tar cvf $user.tar * > gzip $user.tar > cp $user.tar.gz /home/backup/ > > fi > > - Sadly, the above script doesn't work and I need some kind of direction or > assistance to make it work. Two big problems I see. (1) You don't do anything if /home/backup _does_ exist. (2) You never set $user. Is this what you mean? #!/bin/sh if [ ! cd /home/backup ]; then echo "Cannot change to backup directory. Exiting." >&2 exit 1 fi # Rotate previous backups mv $USER.0.tar.gz $USER.1.tar.gz mv $USER.1.tar.gz $USER.2.tar.gz # Make the new one tar czf $USER.0.tar.gz -C $HOME . # Done exit 0 #End -- Crist J. Clark cjclark@alum.mit.edu To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-questions" in the body of the message