[TriLUG] Backup script... Spaces in path

Tom Woods twoods at tomnkim.us
Fri Aug 8 12:54:28 EDT 2003


I'm writing a backup script, learning as I go...  The problem I am having
is backing up a Windows system via samba (although I don't think it being
a Windows system has anything to do with this problem.)  When I pass a
path  and filename with spaces via $1 or $n to the function, tar sees the
space as a delimiter, not as a part of the path.  I have tried using ', ",
and \<space>, nothing seems to work.  I'm sure someone out there knows how
to accomplish what I need.

Also, any comments or suggestions about my script are welcome.  I am sure
there are better ways to get the job done!  Yes, I'm a newbie, but I'm
learning more and more as I go along.

I plan to make this a daily cron job when it's working well.

Thanks,

Tom


# fullbakup
#!/bin/bash

DAY=$(date +%y.%m.%d)
rpm -qa > /etc/installed_rpms

#-------------------------------
function backup(){
#-------------------------------
rm -f $1/Old2/$3*.tgz
rm -f $1/Old2/$3*.log
mv $1/Old1/$3*.tgz $1/Old2
mv $1/Old1/$3*.log $1/Old2
mv $1/$3*.tgz $1/Old1
mv $1/$3*.log $1/Old1
tar -czvf $1/$3_$DAY.tgz $2 &> $1/$3_$DAY.log
}

# ----------  Local  ----------
# backup <DestinationDir> <SourceDir> <FileName>
backup /data/backup/local /home home
backup /data/backup/local /etc etc
backup /data/backup/local /var var
backup /data/backup/local /root root

# ----------  Remote  ----------
# backup <DestinationDir> <SourceDir> <FileName>
backup /data/backup/ComputerName "/ComputerName/ShareName/My Documents"
MyDocuments





More information about the TriLUG mailing list