fix empty backups
authordpavlin <dpavlin@8392b6e1-25fa-0310-8288-cc32f8e212ea>
Thu, 25 Jan 2007 09:27:20 +0000 (09:27 +0000)
committerdpavlin <dpavlin@8392b6e1-25fa-0310-8288-cc32f8e212ea>
Thu, 25 Jan 2007 09:27:20 +0000 (09:27 +0000)
git-svn-id: svn+ssh://llin/home/dpavlin/private/svn/BackupPC/trunk@367 8392b6e1-25fa-0310-8288-cc32f8e212ea

sql/zz_fix_empty_backups.sql [new file with mode: 0644]

diff --git a/sql/zz_fix_empty_backups.sql b/sql/zz_fix_empty_backups.sql
new file mode 100644 (file)
index 0000000..bc3a159
--- /dev/null
@@ -0,0 +1,16 @@
+begin;
+
+-- make temporary table with all backup ids
+select backups.id into temporary all_backup_ids from files
+join shares on files.shareid = shares.id
+join backups on backups.hostid = shares.hostid and backups.num = files.backupnum
+where files.shareid = shares.id
+group by backups.id, files.shareid, files.backupnum
+;
+
+-- fix backups which are deleted and have size anyway 
+update backups set inc_deleted = false where id not in (select id from all_backup_ids) and size > 0 ;
+
+-- fix parts numbering
+
+update backups set parts = 0 where parts > 0 and id not in (select backup_id from backup_parts) ;