X-Git-Url: http://git.rot13.org/?p=BackupPC.git;a=blobdiff_plain;f=sql%2Fzz_fix_empty_backups.sql;fp=sql%2Fzz_fix_empty_backups.sql;h=bc3a159198db0a948f60c3e427b70c299760d2e1;hp=0000000000000000000000000000000000000000;hb=85b4963cdb6d224b524741989ed4082e19b02a5d;hpb=584b370f69032e4f1ea1ab37e83b523044cceeba;ds=sidebyside diff --git a/sql/zz_fix_empty_backups.sql b/sql/zz_fix_empty_backups.sql new file mode 100644 index 0000000..bc3a159 --- /dev/null +++ b/sql/zz_fix_empty_backups.sql @@ -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) ;