Skip site navigation (1)Skip section navigation (2)
Date:      Fri, 17 May 2002 22:00:58 +0300
From:      Giorgos Keramidas <keramida@ceid.upatras.gr>
To:        Alvaro <starthir@yahoo.com>
Cc:        freebsd-questions@FreeBSD.ORG
Subject:   Re: mail with attachment sent by cron
Message-ID:  <20020517190058.GE10253@hades.hell.gr>
In-Reply-To: <20020517140823.38069.qmail@web14607.mail.yahoo.com>
References:  <20020517140823.38069.qmail@web14607.mail.yahoo.com>

next in thread | previous in thread | raw e-mail | index | archive | help
On 2002-05-17 07:08, Alvaro wrote:
> Hello all,
>
> I want to make a backup of critical directories but
> I'm saving it in the same server! So, i want to send
> an email, with these backup files, to have a copy
> elsewhere. How can I do this using cron? mail(1)
> doesn't let me add an attachment (well, I didn't find
> out how to do it ;P).
>
> Any ideas? A program/script that does this?

Why don't you write a script that simply writes the backup of the
files in a proper directory?  Something like the following perhaps?

	#!/bin/sh

	cd /etc
	tar cf - . | gzip -9c /backup/etc.tgz
	if [ $? -eq 0 ]; then
		cd /backup
		mv etc-today.tgz etc-yesterday.tgz
		mv etc.tgz etc-today.tgz
	fi

(This is an example, and it's meant to be just that ... an example.
Don't come hunting after me, if you use it verbatim or modified, and
you find out that because of some mistake, you lost data.  When you
run this or other commands as root, you should take special care to
understand exactly what the commands you're running are going to do.)

Then you can call this from your system's crontab (see the file
/etc/crontab and the crontab(5) manual page) and have it save the
backups of the files where they're supposed to go.

This is safer than passing huge files to your mail server's queue and
forcing it to deliver it to a local account IMHO.

-- 
Giorgos Keramidas    - http://www.FreeBSD.org
keramida@FreeBSD.org - The Power to Serve

To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe freebsd-questions" in the body of the message




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