From owner-freebsd-questions Fri May 17 15: 2:41 2002 Delivered-To: freebsd-questions@freebsd.org Received: from mailsrv.otenet.gr (mailsrv.otenet.gr [195.170.0.5]) by hub.freebsd.org (Postfix) with ESMTP id D456337B408 for ; Fri, 17 May 2002 15:02:22 -0700 (PDT) Received: from hades.hell.gr (patr530-a187.otenet.gr [212.205.215.187]) by mailsrv.otenet.gr (8.12.3/8.12.3) with ESMTP id g4HM2HQJ010748; Sat, 18 May 2002 01:02:17 +0300 (EEST) Received: from hades.hell.gr (hades [127.0.0.1]) by hades.hell.gr (8.12.3/8.12.3) with ESMTP id g4HM2D6o012436; Sat, 18 May 2002 01:02:16 +0300 (EEST) (envelope-from keramida@ceid.upatras.gr) Received: (from charon@localhost) by hades.hell.gr (8.12.3/8.12.3/Submit) id g4HJ0wv6010855; Fri, 17 May 2002 22:00:58 +0300 (EEST) (envelope-from keramida@ceid.upatras.gr) Date: Fri, 17 May 2002 22:00:58 +0300 From: Giorgos Keramidas To: Alvaro Cc: freebsd-questions@FreeBSD.ORG Subject: Re: mail with attachment sent by cron Message-ID: <20020517190058.GE10253@hades.hell.gr> References: <20020517140823.38069.qmail@web14607.mail.yahoo.com> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20020517140823.38069.qmail@web14607.mail.yahoo.com> User-Agent: Mutt/1.3.99i Sender: owner-freebsd-questions@FreeBSD.ORG Precedence: bulk List-ID: List-Archive: (Web Archive) List-Help: (List Instructions) List-Subscribe: List-Unsubscribe: X-Loop: FreeBSD.ORG 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