App::BackupPlan - Perl extension for automated, regular backups
#when using system tar use App::BackupPlan; my $plan = new App::BackupPlan($configFile, $logFile); $plan->run; #when using perl tar use App::BackupPlan; $App::BackupPlan::TAR='perl'; my $plan = new App::BackupPlan($configFile, $logFile); $plan->run;
App::BackupPlan is a simple module to perform regular, selective and automated backups of your system. It requires an xml file with the specification of your backup plan, logically divided into independent tasks. The constructor also takes a log4perl configuration file, to customise the logging produced. This can be omitted if the default logging behaviour is desired. By setting up a regular back-up task using cron or similar, and by configuring a backup plan with different tasks, backup frequencies and max number of files retained, it is possible to achieve a regular and incremental backup of different part of your system, without too much trouble.
Here is a made-up sample configuration file for a backup plan that backups two directories with different frequencies: a pictures and a videos directories.
<backup> <plan name="one"> <default> <maxFiles>3</maxFiles> <frequency>1m</frequency> <targetDir><![CDATA[/backup]]></targetDir> </default> <task name="pics"> <prefix>pics</prefix> <sourceDir><![CDATA[/data/pictures]]></sourceDir> <frequency>20d</frequency> </task> <task name="video"> <prefix>vid</prefix> <maxFiles>2</maxFiles> <sourceDir><![CDATA[/data/Videos]]></sourceDir> <frequency>40d</frequency> </task> </plan> </backup>
n[dmy], where n is a number and the second letter is either
mfor months or
yfor years. Internally,
1m = 30dand
1y = 360d, wihtout considering months of 28 or 31 days.
This perl module was written with an automated backup functionality in mind. So, even if it can be run manually and on demand, it is best suited to be integrated in a regular batch (overnight maybe) or even better as a cron task. To facilitate this task there is a script client in the bin directory of this distribution, backup.pl, which can be easily scheduled as cron task and, that can be run as follow:
backup.pl -c /pathto/plan.xml -l /pathto/log4perl.conf when using system tar, or as
backup.pl -c /pathto/plan.xml -l /pathto/log4perl.conf -t perl for perl tar.
The list of module dependencies is as follows:
On a Linux system it is recommended to use the system tar executable, which is the default behaviour for this module. There is also the option of using Archive::Tar perl module isntead of the system tar. This is recommended for Windows based systems, or if the tar executable is not available. This behaviour is designated as perl tar and is selected by setting
On some distributions XML::DOM does not build straight away, using cpan install or download & make. This is caused by a dependency of this module, XML::Parser, requiring a C library to be present in your system: expat-devel. On some distributions, Debian for example, this package is unavailble. This problem can be overcome by first installing (apt-get) libxml-parser-perl.
None by default.
Copyright (C) 2012 by Gualtiero Chiaia
This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself, either Perl version 5.12.3 or, at your option, any later version of Perl 5 you may have available.