Skip to content

Commit

Permalink
Restoring from backup is done to the primary servershare, not the acc…
Browse files Browse the repository at this point in the history
…idental no-longer-existing one
  • Loading branch information
glormph committed Nov 28, 2024
1 parent 889464c commit 814d416
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 5 deletions.
8 changes: 6 additions & 2 deletions src/backend/datasets/jobs.py
Original file line number Diff line number Diff line change
Expand Up @@ -317,10 +317,14 @@ class ReactivateDeletedDataset(DatasetJob):
task = filetasks.pdc_restore

def process(self, **kwargs):
for sfile in self.getfiles_query(**kwargs).exclude(mzmlfile__isnull=False).filter(purged=True, pdcbackedupfile__isnull=False):
for sfile in self.getfiles_query(**kwargs).exclude(mzmlfile__isnull=False).filter(
purged=True, pdcbackedupfile__isnull=False):
self.run_tasks.append((rsjobs.restore_file_pdc_runtask(sfile), {}))
# Also set archived/archivable files which are already active (purged=False) to not deleted in UI
self.getfiles_query(**kwargs).filter(purged=False, deleted=True, pdcbackedupfile__isnull=False).update(deleted=False)
self.getfiles_query(**kwargs).filter(purged=False, deleted=True, pdcbackedupfile__isnull=False
).update(deleted=False)
Dataset.objects.filter(kwargs['dset_id']).update(
storageshare=ServerShare.objects.get(name=settings.PRIMARY_STORAGESHARENAME))


class DeleteDatasetPDCBackup(DatasetJob):
Expand Down
3 changes: 2 additions & 1 deletion src/backend/jobs/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -292,7 +292,8 @@ def restored_archive_file(request):
data['client_id'], [settings.STORAGECLIENT_APIKEY]):
return HttpResponseForbidden()
sfile = StoredFile.objects.filter(pk=data['sfid'])
sfile.update(deleted=False, purged=False)
sfile.update(deleted=False, purged=False,
servershare_id=ServerShare.objects.get(name=data['serversharename'])
if 'task' in request.POST:
set_task_done(request.POST['task'])
return HttpResponse()
Expand Down
2 changes: 1 addition & 1 deletion src/backend/rawstatus/jobs.py
Original file line number Diff line number Diff line change
Expand Up @@ -268,7 +268,7 @@ def restore_file_pdc_runtask(sfile):
backupfile = models.PDCBackedupFile.objects.get(storedfile=sfile)
fnpath = os.path.join(sfile.path, sfile.filename)
yearmonth = datetime.strftime(sfile.regdate, '%Y%m')
return (sfile.servershare.name, fnpath, backupfile.pdcpath, sfile.id, backupfile.is_dir)
return (settings.PRIMARY_STORAGESHARENAME, fnpath, backupfile.pdcpath, sfile.id, backupfile.is_dir)


def call_proteomexchange(pxacc):
Expand Down
3 changes: 2 additions & 1 deletion src/backend/rawstatus/tasks.py
Original file line number Diff line number Diff line change
Expand Up @@ -380,7 +380,8 @@ def pdc_restore(self, servershare, filepath, pdcpath, fn_id, isdir):
except Exception:
taskfail_update_db(self.request.id, msg='File {} to retrieve from backup is directory '
'type, it is retrieved to {} but errored when moving from there'.format(fileloc, pdcpath))
postdata = {'sfid': fn_id, 'task': self.request.id, 'client_id': settings.APIKEY}
postdata = {'sfid': fn_id, 'task': self.request.id, 'client_id': settings.APIKEY,
'serversharename': servershare}
url = urljoin(settings.KANTELEHOST, reverse('jobs:restoredpdcarchive'))
msg = ('Restore from archive could not update database with for fn {} with PDC path {} :'
'{}'.format(filepath, pdcpath, '{}'))
Expand Down

0 comments on commit 814d416

Please sign in to comment.