[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Sheflug] Backup advice



> I have just plonked a big HD into my box and want to be able to use it as
> a place to store stuff, but also have a dir for backup purposes.  I host
> websites, inc MySQL apps etc, and also have day to day files, and they
> all need backing up.  At the moment I do it by hand.  However, there are
> times where I only need to backup the odd couple of files out of a few
> dirs because the rest are not changed since last backup ... etc... etc,
> you get the picture.  So, what I really need (and not before time!!!) is
> a grown-up way to sort this out.

How much time do you want to spend on getting something? :) I can't say how
good various apps are as I've never used them (eg, Amaya is one that springs
to mind), but you should be able to do something straight forward with a
shell script calling 'tar', something like, maybe:

tar cvf /somewhere/mybackup-`date +%Y-%m-%d`.tar \
        --exclude-file /somewhere/dontbacktheseup.list \
        `cat /somewhere/backup.list`

Which would create a tar file based on the contents of backup.list. The
exclude file can contain exclusions, eg, you might have /usr/local in
backup.list but don't want to backup /usr/local/tmp.

As for backing up only changed files, 'find' could do the job, wrapped up in
a bit of a script. 'date +%S' will return time in seconds (if GNU date as its
a GNU extension - which pretty certain to be on a Linux box), and after some
simple maths (expr, or if using ksh (bash as well?), the inbuilt maths
support), and knowledge of the previous backup (date +%S
> /somewhere/lastbackupdate) you could use 'find' with the '-ctime' predicate
to create a filelist, which you then pass to 'tar'.

That's one option anyhow :) Similarly, Perl could do the job as well,
spawning tar. Or write a wrapper for tar in C.

And yes, I'd use tar over cp as tar will preserve sym-links, and won't barf
if there are any special files (fifo's, sockets, devices etc). tar also makes
it easy to change the backup from a file to a device (eg, tape). cpio could
probably be just as good as tar for this purpose as well (but I've not really
used it).

If you want me to expand on anything here (it's deceptively simple to
implement) ask away :)

Chris...

-- 
\ Chris Johnson                 \
 \ cej [at] nightwolf.org.uk          \
  \ http://cej.nightwolf.org.uk/  ~-----------------------------------+
   \ Redclaw chat - http://redclaw.org.uk - telnet redclaw.org.uk 2000 \____



___________________________________________________________________

Sheffield Linux User's Group -
http://www.sheflug.co.uk/mailfaq.html

  GNU the choice of a complete generation.