Need help with backup shell script

Andreas Widerøe Andersen wodfer at
Wed Nov 21 05:39:52 PST 2007


I'm working on a shell script that will let me attach (mount) an
external USB 2.0 harddrive and to my FreeBSD 6.2 server and perform a
full backup of /backup on my server (all files and subfolders) once or
twice a week (whenever I run the cronjob). The script must be able to
run through a cronjob and the drive must be mounted and unmounted
after each job (I will swap between two drives of the same type and
size). The script must also remove folders/files older than 30 days.

Does anyone use a script like this today that they can share? I'm not
a shell scripter myself so any help is highly appreciated.

Here's my rough idea/sketch:

#! /bin/sh

$MOUNT = /external
$DATE= date_today

mount usb_drive $MOUNT
cd /$MOUNT
rm all files forlders older than 30 days
mkdir /$DATE
cp -fr /backup to /$MOUNT/$DATE

Thanks for your help!
Best regards,

More information about the freebsd-questions mailing list