Skip site navigation (1)Skip section navigation (2)
Date:      Mon, 7 Jun 2004 22:08:57 +0300
From:      Giorgos Keramidas <keramida@ceid.upatras.gr>
To:        Bart Silverstrim <bsilver@chrononomicon.com>
Cc:        freebsd-questions@freebsd.org
Subject:   Re: Scripting backup of file naming?
Message-ID:  <20040607190857.GB44095@gothmog.gr>
In-Reply-To: <859B50A7-B893-11D8-9892-000A956D2452@chrononomicon.com>
References:  <859B50A7-B893-11D8-9892-000A956D2452@chrononomicon.com>

next in thread | previous in thread | raw e-mail | index | archive | help
On 2004-06-07 11:01, Bart Silverstrim <bsilver@chrononomicon.com> 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.



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