added SQL which delete all backups afeter daylight saving time change.
authordpavlin <dpavlin@8392b6e1-25fa-0310-8288-cc32f8e212ea>
Thu, 17 Nov 2005 17:22:31 +0000 (17:22 +0000)
committerdpavlin <dpavlin@8392b6e1-25fa-0310-8288-cc32f8e212ea>
Thu, 17 Nov 2005 17:22:31 +0000 (17:22 +0000)
added cludge which tolerate +/- 1 hour difference in mtime from (probably
windows) hosts which drift when DST is in action, thus producing duplicate
entries

git-svn-id: svn+ssh://llin/home/dpavlin/private/svn/BackupPC/trunk@240 8392b6e1-25fa-0310-8288-cc32f8e212ea

bin/BackupPC_updatedb
sql/zz_dst_files_fix.sql [new file with mode: 0644]

index 5360509..cebb34c 100755 (executable)
@@ -630,8 +630,32 @@ sub recurseDir($$$$$$$$) {
                                $filesInBackup->{$path_key}->{'size'}
                        ));
 
+                       # daylight saving time change offset for 1h
+                       my $dst_offset = 60 * 60;
+
+                       my $key_dst1 = join(" ", (
+                               $shareID,
+                               $dir,
+                               $path_key,
+                               $filesInBackup->{$path_key}->{'mtime'} - $dst_offset,
+                               $filesInBackup->{$path_key}->{'size'}
+                       ));
+
+                       my $key_dst2 = join(" ", (
+                               $shareID,
+                               $dir,
+                               $path_key,
+                               $filesInBackup->{$path_key}->{'mtime'} + $dst_offset,
+                               $filesInBackup->{$path_key}->{'size'}
+                       ));
+
                        my $found;
-                       if (! defined($beenThere->{$key}) && ! ($found = found_in_db($key, @data)) ) {
+                       if (
+                               ! defined($beenThere->{$key}) &&
+                               ! defined($beenThere->{$key_dst1}) &&
+                               ! defined($beenThere->{$key_dst2}) &&
+                               ! ($found = found_in_db($key, @data))
+                       ) {
                                print STDERR "# key: $key [", $beenThere->{$key},"]" if ($debug >= 2);
 
                                if ($filesInBackup->{$path_key}->{'type'} == BPC_FTYPE_DIR) {
diff --git a/sql/zz_dst_files_fix.sql b/sql/zz_dst_files_fix.sql
new file mode 100644 (file)
index 0000000..ac9c140
--- /dev/null
@@ -0,0 +1,23 @@
+select hostid,shareid,num,abstime(date),size,inc_size into dst_files from backups where date > abstime('2005-10-24')::int order by abstime,hostid,num;
+
+delete from backups where date > abstime('2005-10-24')::int;
+vacuum analyze backups;
+
+create index dst_i1 on dst_files(shareid) ;
+create index dst_i2 on dst_files(num) ;
+vacuum analyze dst_files ;
+create index dst_i3 on files(backupnum) ;
+vacuum analyze files ;
+
+select id into dst_files_ids from files inner join dst_files on dst_files.shareid = files.shareid and dst_files.num = files.backupnum ;
+create unique index dst_i4 on dst_files_ids(id) ;
+vacuum analyze dst_files_ids ;
+
+delete from files where id in (select id from dst_files_ids) ;
+
+vacuum full analyze verbose files ;
+
+drop table dst_files_ids ;
+drop table dst_files ;
+
+drop index dst_i3 ;