scripts/queuerunner.pl \
scripts/control.pl \
scripts/sendmail.pl \
- scripts/insertmail.pl
+ scripts/insertmail.pl \
+ scripts/sqlite_backup.pl
MODULES := Emesinae/Bug.pm \
Emesinae/Common.pm \
# Severity levels, in decending order of criticality
@{ $c{SeverityLevels} } = qw/blocker critical normal wishlist/;
$c{DefaultSeverity} = "normal";
+
+# Backup configuration
+$c{BackupDir} = "/var/backups/";
# Severity levels, in decending order of criticality
@{ $c{SeverityLevels} } = qw/blocker critical normal wishlist/;
$c{DefaultSeverity} = "normal";
+
+# Backup configuration
+$c{BackupDir} = "/srv/test/var/backups/";
--- /dev/null
+#!/usr/bin/perl
+#
+# Creates a backup of the current DB in $c{BackupDir}
+# using locks to avoid race conditions with queuerunner
+
+use strict;
+use warnings;
+
+use Emesinae::Common;
+use Emesinae::Paths;
+use File::Copy;
+use File::Basename;
+
+readconfig();
+
+chdir( $c{BackupDir} ) || die("chdir to dir $c{BackupDir}: $!");
+
+
+my $lock = subsyslock('queuerunner');
+
+my $BackupDB = $c{BackupDir} . basename($c{DB});
+my $BackupDBxz = $c{BackupDir} . basename($c{DB}) . ".xz";
+my $OldBackupDBxz = $c{BackupDir} . basename($c{DB}) . ".old.xz";
+
+if ( -f $BackupDBxz ) {
+ move($BackupDBxz, $OldBackupDBxz) or die ("move failed: $!");
+}
+
+my $dbh = DBI->connect("dbi:SQLite:dbname=$c{DB}","","");
+$dbh->sqlite_backup_to_file( $BackupDB );
+undef $dbh;
+
+my @args = ("xz", "$BackupDB");
+system(@args) == 0
+ or die ("xz compress failed: $?");
+
+subsysunlock($lock);
+
+exit(0)