Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 21 Nov 2007 14:55:05 +0100
From:      "Valerio Daelli" <valerio.daelli@gmail.com>
To:        "=?ISO-8859-1?Q?Andreas_Wider=F8e_Andersen?=" <wodfer@gmail.com>,  freebsd-questions <freebsd-questions@freebsd.org>
Subject:   Re: Need help with backup shell script
Message-ID:  <27dbfc8c0711210555h1a862f5drccb1a6f5bcb1a837@mail.gmail.com>
In-Reply-To: <23ed14b80711210539w4bed1enc180f8e32ec76881@mail.gmail.com>
References:  <23ed14b80711210539w4bed1enc180f8e32ec76881@mail.gmail.com>

next in thread | previous in thread | raw e-mail | index | archive | help
On Nov 21, 2007 2:39 PM, Andreas Wider=F8e Andersen <wodfer@gmail.com> wrot=
e:
> Hi,
>
> 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 =3D /external
> $DATE=3D date_today
>
> mount usb_drive $MOUNT
> cd /$MOUNT
> rm all files forlders older than 30 days
> mkdir /$DATE
> cp -fr /backup to /$MOUNT/$DATE
> cd
> unmount
>
>
---
#!/bin/sh

MOUNT=3D/external
DATE=3D`date +%Y%m%d%H%M`

mount /dev/da2 $MOUNT #Change device name
find $MOUNT -mtime +30 -delete
mkdir $MOUNT/$DATE
cp -rp /backup/* $MOUNT/$DATE
umount /external
---

Bye

Valerio Daelli



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?27dbfc8c0711210555h1a862f5drccb1a6f5bcb1a837>