Fix up Archive Querys and Retrieval

This commit is contained in:
Deon George 2013-11-05 00:13:12 +11:00
parent b53aafd8a8
commit 367f265d52
4 changed files with 76 additions and 22 deletions

View File

@ -34,25 +34,63 @@ int tsm_listfile_cb(dsmQueryType qType, DataBlk *qResp, void *userdata) {
return -1; return -1;
} }
if (! headerPrinted++)
printf("%40s %2s %s %3s %19s %19s %10s %s\n",
"NAME",
"ST",
"L",
"CED",
"BACKUP",
"EXPIRE",
"EST SIZE",
"ID"
);
if (qType == qtArchive) { if (qType == qtArchive) {
if (! headerPrinted++)
printf("%40s %2s %s %3s %19s %19s %10s %10s %s\n",
"NAME",
"ST",
"L",
"CED",
"BACKUP",
"EXPIRE",
"EST SIZE",
"ID",
"DESC"
);
memset(&respArchive,0x00,sizeof(qryRespArchiveData)); memset(&respArchive,0x00,sizeof(qryRespArchiveData));
qryRespArchiveData *qr = (void *) qResp->bufferPtr; qryRespArchiveData *qr = (void *) qResp->bufferPtr;
respArchive = *qr; respArchive = *qr;
// The Object Status
switch (respArchive.objName.objType) {
case (DSM_OBJ_FILE) : strcpy(state,"F"); break;
case (DSM_OBJ_DIRECTORY) : strcpy(state,"D"); break;
default : strcpy(state,"?");
}
// Location
switch (respArchive.mediaClass) {
case (MEDIA_FIXED) : strcpy(stor,"D"); break;
case (MEDIA_LIBRARY) : strcpy(stor,"T"); break;
default : strcpy(stor,"?");
}
// Compression, Encryption, De-Duplication
strcpy(ced,(respArchive.compressType == DSM_OBJ_COMPRESSED_YES ? "C" :
(respArchive.compressType == DSM_OBJ_COMPRESSED_NO ? "-" : "?")));
strcat(ced,(respArchive.encryptionType & DSM_ENCRYPT_CLIENTENCRKEY ? "C" :
(respArchive.encryptionType & DSM_ENCRYPT_USER ? "U" : "-")));
strcat(ced,respArchive.clientDeduplicated ? "D" : "-");
// The Object Status
printf("%40s|%2s|%s|%3s|%19s|%19s|%7.3f MB|%u-%u|%s\n",dsmObjnameToStr(respArchive.objName),state,stor,ced,dsmDateToStr(respArchive.insDate),respArchive.expDate.year ? dsmDateToStr(respArchive.expDate) : "",dsmSizeToNum(respArchive.sizeEstimate),respArchive.objId.hi,respArchive.objId.lo,respArchive.descr);
} else if (qType ==qtBackup) { } else if (qType ==qtBackup) {
if (! headerPrinted++)
printf("%40s %2s %s %3s %19s %19s %10s %s\n",
"NAME",
"ST",
"L",
"CED",
"BACKUP",
"EXPIRE",
"EST SIZE",
"ID"
);
memset(&respBackup,0x00,sizeof(qryRespBackupData)); memset(&respBackup,0x00,sizeof(qryRespBackupData));
qryRespBackupData *qr = (void *) qResp->bufferPtr; qryRespBackupData *qr = (void *) qResp->bufferPtr;
respBackup = *qr; respBackup = *qr;
@ -86,14 +124,14 @@ int tsm_listfile_cb(dsmQueryType qType, DataBlk *qResp, void *userdata) {
strcat(ced,respBackup.clientDeduplicated ? "D" : "-"); strcat(ced,respBackup.clientDeduplicated ? "D" : "-");
printf("%40s|%2s|%s|%3s|%19s|%19s|%7.3f MB|%u-%u\n",dsmObjnameToStr(respBackup.objName),state,stor,ced,dsmDateToStr(respBackup.insDate),respBackup.expDate.year ? dsmDateToStr(respBackup.expDate) : "",dsmSizeToNum(respBackup.sizeEstimate),respBackup.objId.hi,respBackup.objId.lo);
} else { } else {
fprintf(stderr,"tsm_listfile_cb: Internal error: Unknown qType %d\n",qType); fprintf(stderr,"tsm_listfile_cb: Internal error: Unknown qType %d\n",qType);
return -1; return -1;
} }
printf("%40s|%2s|%s|%3s|%19s|%19s|%7.3f MB|%u-%u\n",dsmObjnameToStr(respBackup.objName),state,stor,ced,dsmDateToStr(respBackup.insDate),respBackup.expDate.year ? dsmDateToStr(respBackup.expDate) : "",dsmSizeToNum(respBackup.sizeEstimate),respBackup.objId.hi,respBackup.objId.lo);
return 1; return 1;
} }

View File

@ -298,7 +298,10 @@ int tsm_restorefile(dsUint32_t dsmHandle, char *fsname, char *filename, char *de
cbdata.numfound = 0; cbdata.numfound = 0;
// Retrieve a list based on the PITDATE or if no PITDATE, the last ACTIVE // Retrieve a list based on the PITDATE or if no PITDATE, the last ACTIVE
rc = tsm_queryfile(dsmHandle,&objName,description,sendtype,verbose,tsm_matchone_cb,&cbdata,pitdate,pitdate ? DSM_ANY_MATCH : DSM_ACTIVE); if (sendtype == stBackupMountWait)
rc = tsm_queryfile(dsmHandle,&objName,description,sendtype,verbose,tsm_matchone_cb,&cbdata,pitdate,pitdate ? DSM_ANY_MATCH : DSM_ACTIVE);
else
rc = tsm_queryfile(dsmHandle,&objName,description,sendtype,verbose,tsm_matchone_cb,&cbdata,NULL,0);
if (rc != DSM_RC_OK) if (rc != DSM_RC_OK)
return 0; return 0;

View File

@ -295,10 +295,15 @@ dsInt16_t tsm_queryfile(dsUint32_t dsmHandle, dsmObjName *objName, char *descrip
qaData.stVersion = qryArchiveDataVersion; qaData.stVersion = qryArchiveDataVersion;
qaData.objName = objName; qaData.objName = objName;
qaData.owner = ""; qaData.owner = "";
qaData.insDateLowerBound.year = DATE_MINUS_INFINITE; if (pitdate) {
qaData.insDateUpperBound.year = DATE_PLUS_INFINITE; fprintf(stderr,"tsm_queryfile: Archive Date Range Query not yet setup\n");
qaData.expDateLowerBound.year = DATE_MINUS_INFINITE; exit(1);
qaData.expDateUpperBound.year = DATE_PLUS_INFINITE; } else {
qaData.insDateLowerBound.year = DATE_MINUS_INFINITE;
qaData.insDateUpperBound.year = DATE_PLUS_INFINITE;
qaData.expDateLowerBound.year = DATE_MINUS_INFINITE;
qaData.expDateUpperBound.year = DATE_PLUS_INFINITE;
}
qaData.descr = description ? description : "*"; qaData.descr = description ? description : "*";
qDataP = &qaData; qDataP = &qaData;

View File

@ -85,7 +85,7 @@ void usage(void) {
" -l length Length of object to store. If guesstimating too large\n" " -l length Length of object to store. If guesstimating too large\n"
" is better than too small\n" " is better than too small\n"
" -D desc Description of archive object\n" " -D desc Description of archive object\n"
" -P pitdate PITDate (mmddYYYY)\n" " -P pitdate PITDate (mmddYYYY) (BACKUP Objects)\n"
" -O options Extra options to pass to dsmInitEx\n" " -O options Extra options to pass to dsmInitEx\n"
" -v Verbose. More -v's gives more verbosity\n" " -v Verbose. More -v's gives more verbosity\n"
); );
@ -135,6 +135,11 @@ int main(int argc, char *argv[]) {
exit(1); exit(1);
} }
if (pitdate && ! backup) {
fprintf(stderr, "tsmpipe: ERROR: -P can only be used with -A\n");
exit(1);
}
if (! info) { if (! info) {
if (create+xtract+delete+list != 1) { if (create+xtract+delete+list != 1) {
fprintf(stderr, "tsmpipe: ERROR: Must give one of -c, -x, -d or -t\n"); fprintf(stderr, "tsmpipe: ERROR: Must give one of -c, -x, -d or -t\n");
@ -208,6 +213,7 @@ int main(int argc, char *argv[]) {
// Delete an object from TSM // Delete an object from TSM
if (delete) { if (delete) {
// @todo Delete Archives by date range.
if (! tsm_deletefile(dsmHandle,space,filename,desc,sendtype,verbose)) { if (! tsm_deletefile(dsmHandle,space,filename,desc,sendtype,verbose)) {
dsmTerminate(dsmHandle); dsmTerminate(dsmHandle);
exit(3); exit(3);
@ -216,7 +222,8 @@ int main(int argc, char *argv[]) {
// Restore from TSM // Restore from TSM
if(xtract) { if(xtract) {
if (! tsm_restorefile(dsmHandle,space,filename,desc,sendtype,verbose,pitdate)) { // @todo Query Archives by date range.
if (! tsm_restorefile(dsmHandle,space,filename,desc,sendtype,verbose,(sendtype == stBackupMountWait ? pitdate : NULL))) {
dsmTerminate(dsmHandle); dsmTerminate(dsmHandle);
exit(3); exit(3);
} }
@ -224,7 +231,8 @@ int main(int argc, char *argv[]) {
// List objects in TSM // List objects in TSM
if (list) { if (list) {
if (! tsm_listfile(dsmHandle,space,filename,desc,sendtype,verbose,pitdate)) { // @todo Query Archives by date range.
if (! tsm_listfile(dsmHandle,space,filename,desc,sendtype,verbose,(sendtype == stBackupMountWait ? pitdate : NULL))) {
dsmTerminate(dsmHandle); dsmTerminate(dsmHandle);
exit(3); exit(3);
} }