Date: Fri, 16 Jun 2000 00:31:35 -0700 From: "Crist J. Clark" <cristjc@earthlink.net> To: Danny <dannyh@idx.com.au> Cc: freebsd-questions@FreeBSD.ORG Subject: Re: shell scripting and Samba Message-ID: <20000616003135.A287@dialin-client.earthlink.net> In-Reply-To: <00061712140108.00338@desktop.freebsd.org>; from dannyh@idx.com.au on Sat, Jun 17, 2000 at 12:06:15PM %2B1000 References: <00061712140108.00338@desktop.freebsd.org>
next in thread | previous in thread | raw e-mail | index | archive | help
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
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20000616003135.A287>