foo
[BackupPC.git] / sql / zz_fix_empty_backups.sql
1 begin;
2
3 -- make temporary table with all backup ids
4 select backups.id into temporary all_backup_ids from files
5 join shares on files.shareid = shares.id
6 join backups on backups.hostid = shares.hostid and backups.num = files.backupnum
7 where files.shareid = shares.id
8 group by backups.id, files.shareid, files.backupnum
9 ;
10
11 -- fix backups which are deleted and have size anyway 
12 update backups set inc_deleted = false where id not in (select id from all_backup_ids) and size > 0 ;
13
14 -- fix parts numbering
15
16 update backups set parts = 0 where parts > 0 and id not in (select backup_id from backup_parts) ;