File::Backup - Easy file backup & rotation automation


NAME

File::Backup - Easy file backup & rotation automation


SYNOPSIS

  use File::Backup;
  backup( from => "/source/path", to => "/destination/path" );
  backup( from => "/kansas/*", to => "/oz" );
  purge_backups(
      to => "/destination/path",
      compress => 0,
      keep => 5,
      timeformat => "YYYYMMDD_hhmmss",
  );


DESCRIPTION

This legacy module implements archival and compression (A.K.A "backup") and file rotation and is an implementation of tar and gzip calls.


EXPORTED FUNCTIONS

backup %ARGUMENTS
  $backed = backup(%arguments);

In its barest form, this function takes as input a source path or glob and a destination directory, and puts an archive file of the source directory files into the destination directory.

The backup() function returns a single valued source => destination hash reference (AKA an array).

The function arguments are described below.

purge_backups %ARGUMENTS

This function is handy for cleaning out backup directories. It does no archival but the arguments are the same as with the backup function.


LEGACY

The following parameters are still around, but are now aliased to the corresponding names:

  tar           => archiver
  tarflags      => archive_flags
  torootname    => archive_prefix and prefix
  tarsuffix     => archive_suffix and suffix
  compress      => compressor
  compressflags => compress_flags


BUGS

You can't make two backups of the same stuff in one second, because they'll try to have the same name. Is this really a bug?


TO DO

Make the stuttering YYYYMMDDhhmmss stop. Just use YMDhms or make the string processing intelligent instead. There's an idea...

Restrict processing to a provided list of filenames and look for them with File::Find.

Support file name include and exclude regexps.

Make a friendly commandline function using a Getopt::* module.

Use Archive::Any/File/Tar/Zip/Whatever instead of Unix system calls.

Use standard ISO formats for the time2str function.

Allow various backup file naming conventions (also with a string format).

Make the keep option time sensitive as well as "numerically naive". Consider the ctime and mtime file attributes.

Make the keep option size sensitive. Duuuh.

Allow the source files to be backed up without the file system directory tree structure. That is, "flatten" the archive.

Make sure unique filenames are being used in the backup.

Make a File::Backup::Base superclass for implementing focused back-up tasks with cvs or scp, nfs or to a legacy device, for instance.


SEE ALSO

Cwd

File::Which

LockFile::Simple

Related modules:

File::Rotate::Backup is a later, apparantly orphaned module that appears to be mostly redundant.

Dir::Split seems handy.


THANK YOU

Help, insight, suggestions and comments came from Ken Williams, Joshua Keroes and John McDermott.


AUTHORS

Original: Ken Williams <kwilliams@cpan.org>

Current: Gene Boggs <gene@cpan.org>


COPYRIGHT AND LICENSE

Copyright 1998-2004 Ken Williams and Gene Boggs. All rights reserved.

This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself.


CVS

$Id: Backup.pm,v 1.28 2004/03/23 12:17:06 gene Exp $