Howdy,
I just wrote a bash script for making manual backups easier (I do them manually when
I'm about to edit something major) it basically makes a new directory in /backup/
who's name is equal to today's date, then recursively copies certain dirs I want
backed up.
The problem is, on some projects I like to do the manual backup each time I get to a
stable point before making the next few edits. What I'm wanting is for the script to
check and see if a directory with today's date already exists. If it does I want it to
append the hour as well as the date. Then if there's already on with the same hour it
should append the minute.
Another option would be for it to add something like _1 to the end and increment _1 by
one digit each time (_2, _3, _4....) but I like the day, then hour, then minute
better. I guess we could add seconds for amusement's sake.
Anyway, I'm sure I could figure out how to do an if...else loop, I've seen examples,
but in bash I've never seen an example of checking for the existence of a file or dir.
Can anyone show me how to do that?
Here's what I have:
#!/bin/bash
#
#First find out what today is
#
#
#oldformat: today=$(date +%Y_%m_%d)
#
#new format:
today=$(date +%m-%d-%Y)
echo "Today is" $today
mkdir /backup/$today && echo "backup dir $today created"
cp -a /etc /backup/$today && echo "etc copied"
echo
echo "Done"
Thanks in advance...
----------------------------------------------------
Jonathan Wilson
System Administrator
Cedar Creek Software
http://www.cedarcreeksoftware.com
Central Texas IT
http://www.centraltexasit.com
_______________________________________________
Redhat-list mailing list
[EMAIL PROTECTED]
https://listman.redhat.com/mailman/listinfo/redhat-list