From owner-freebsd-questions@FreeBSD.ORG Mon Jun 7 19:09:17 2004 Return-Path: Delivered-To: freebsd-questions@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 73BDE16A4CE for ; Mon, 7 Jun 2004 19:09:17 +0000 (GMT) Received: from bilbo.otenet.gr (bilbo.otenet.gr [195.170.0.13]) by mx1.FreeBSD.org (Postfix) with ESMTP id E69F843D45 for ; Mon, 7 Jun 2004 19:09:15 +0000 (GMT) (envelope-from keramida@ceid.upatras.gr) Received: from gothmog.gr (patr530-b205.otenet.gr [212.205.244.213]) i57J8vGk017872; Mon, 7 Jun 2004 22:08:58 +0300 Received: from gothmog.gr (gothmog [127.0.0.1]) by gothmog.gr (8.12.11/8.12.11) with ESMTP id i57J8vdL044203; Mon, 7 Jun 2004 22:08:57 +0300 (EEST) (envelope-from keramida@ceid.upatras.gr) Received: (from giorgos@localhost) by gothmog.gr (8.12.11/8.12.11/Submit) id i57J8vW2044202; Mon, 7 Jun 2004 22:08:57 +0300 (EEST) (envelope-from keramida@ceid.upatras.gr) Date: Mon, 7 Jun 2004 22:08:57 +0300 From: Giorgos Keramidas To: Bart Silverstrim Message-ID: <20040607190857.GB44095@gothmog.gr> References: <859B50A7-B893-11D8-9892-000A956D2452@chrononomicon.com> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <859B50A7-B893-11D8-9892-000A956D2452@chrononomicon.com> cc: freebsd-questions@freebsd.org Subject: Re: Scripting backup of file naming? X-BeenThere: freebsd-questions@freebsd.org X-Mailman-Version: 2.1.1 Precedence: list List-Id: User questions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 07 Jun 2004 19:09:17 -0000 On 2004-06-07 11:01, Bart Silverstrim wrote: > *problem; on server1, I'm going to have two directories: ~/archive and > ~/workingdir. I want the scp to move the files from server2 to > ~/workingdir, tar and zip them as a file name with a date attached > (like backup06072004.tgz) to make the filename distinctive, then move > that file from ~/workingdir to ~/archive. The filename would need to > be distinctive both to allow for reference when needing to restore a > snapshot and also to keep the archives from overwriting each other when > moved over. > > Is there a simple way to do this with a script running from cron? Yes, there is. Write a shell script that contains all the command lines you want to run and use cron to call it periodically. As for the dated filenames, it's easy: #!/bin/sh outfilename="backup-"$(date '+%y-%m-%d-%H%M')".tar.bz2" echo "Saving files into: ${outfilename}" tar cvf - path/to/dir/1 path/to/dir/2 | \ bzip2 -9c -> "${outfilename}" This should be almost all you need.