From 14066a5700d58e0fb913f5ba132fad602e856351 Mon Sep 17 00:00:00 2001 From: dpavlin Date: Thu, 17 Nov 2005 17:22:31 +0000 Subject: [PATCH] added SQL which delete all backups afeter daylight saving time change. 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 | 26 +++++++++++++++++++++++++- sql/zz_dst_files_fix.sql | 23 +++++++++++++++++++++++ 2 files changed, 48 insertions(+), 1 deletion(-) create mode 100644 sql/zz_dst_files_fix.sql diff --git a/bin/BackupPC_updatedb b/bin/BackupPC_updatedb index 5360509..cebb34c 100755 --- a/bin/BackupPC_updatedb +++ b/bin/BackupPC_updatedb @@ -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 index 0000000..ac9c140 --- /dev/null +++ b/sql/zz_dst_files_fix.sql @@ -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 ; -- 2.20.1