Hello,
I have the following script that I'm trying to use to backup specific directories on my box to my USB drive:
Code:
for dir in /etc /var /home /usr/local /opt
do if [ -d $dir ]
then find $dir | cpio -ovH crc -C65536 -O /mnt/USBDrive/backup.$dir.$(date +%m_%d_%Y_%k_%m_%S).cpio
fi
done
(props to
98_1LE for getting me started on this code from
this thread (links to forums at unix.com)).
Resulting in several .cpio files (or one large one, I'm open to change here) with a filename of "backup.<directoryname>.<timestamp>.cpio .
Now obviously this doesn't work because the variable $dir has /'s in it, making getting a nice error from cpio:
Code:
cpio: /mnt/USBDrive/backup./etc.02_23_2009_22_02_08.cpio: No such file or directory
cpio: /mnt/USBDrive/backup./var.02_23_2009_22_02_08.cpio: No such file or directory
cpio: /mnt/USBDrive/backup./home.02_23_2009_22_02_08.cpio: No such file or directory
cpio: /mnt/USBDrive/backup./usr/local.02_23_2009_22_02_08.cpio: No such file or directory
cpio: /mnt/USBDrive/backup./opt.02_23_2009_22_02_08.cpio: No such file or directory
I was thinking there may be a way to put in some sort of command to remove the /'s from the variable in between the find and the cpio commands, leaving a readable filename.
Anyone have any ideas/suggestions to how I can get this working?
Please be gentle, Ive been using linux for about 2 years now and LOVE it, but I'm still green about a few things!! This site has helped me a TON in the past, and I'd never actually had a need to post anything myself, until now.
Thanks in advance!!