Hello dudes,
I am using crontab to schedule a backup script, and record everything to a file with the date.
does this command accomplish this?
Code:
crontab -l
# m h dom mon dow command
0 2 * * 1-5 /home/oj/Documents/backup > /home/oj/Desktop/backup_$(date +%Y%m%d).log
oj@oj-desktop:~$
here's my backup script, its not for a server or such, just seeing if it will work..
Code:
#!/bin/bash
OUTPUT=/home/oj/Desktop/backup_$(date +%Y%m%d).tar.gz
BUDIR=/home/oj/Documents/
echo "Starting backup of $BUDIR to file $OUTPUT"
if [ `date +%w` -eq 4 ] ; then
tar -cvzpf $OUTPUT $BUDIR
fi
if [`date +%w` -gt 0 ] && [`date +%w` -lt 4] ; then
find $BUDIR -type f -newer $OUTPUT -print 0 | tar --null -czvf $OUTPUT -T-
if [ $? == 0 ]; then
mail -s "Backup successful for $OUTPUT" oj < ~
else
mail -s "Backup failed for $OUTPUT" oj < ~
fi
fi
If anything's wrong here can someone please highlight it to me? Thank you!
EDIT:
Something's wrong here, whats wrong with line 14?
Code:
./backup
Starting backup of /home/oj/Documents/ to file /home/oj/Desktop/backup_20091026.tar.gz
./backup: line 14: [1: command not found
oj@oj-desktop:~/Documents$
Bookmarks