Compare commits
No commits in common. "master" and "tsmpipe-7.1.3_0_1.6.5-0" have entirely different histories.
master
...
tsmpipe-7.
@ -1,4 +0,0 @@
|
|||||||
.git/
|
|
||||||
lib/
|
|
||||||
scripts/
|
|
||||||
test/
|
|
@ -1,19 +1,17 @@
|
|||||||
stages:
|
stages:
|
||||||
- build
|
- build
|
||||||
- test
|
- test
|
||||||
- docker
|
|
||||||
|
|
||||||
# For some reason compiling on CentOS 6.x results in buffer corruption
|
# Compile on CentOS 6.x, for some reason compiling on CentOS 7.x results in buffer corruption
|
||||||
build:6-7.1:
|
build:6-7.1:
|
||||||
stage: build
|
stage: build
|
||||||
image: ${CI_REGISTRY}/leenooks/ci-tsm:6-7.1
|
image: leenooks/ci-tsm:6-7.1
|
||||||
script:
|
script:
|
||||||
- make -f Makefile.linux64
|
- make -f Makefile.linux64
|
||||||
only:
|
only:
|
||||||
- c6
|
- master
|
||||||
tags:
|
tags:
|
||||||
- C
|
- C
|
||||||
- x86_64
|
|
||||||
artifacts:
|
artifacts:
|
||||||
name: "$CI_BUILD_NAME"
|
name: "$CI_BUILD_NAME"
|
||||||
paths:
|
paths:
|
||||||
@ -21,75 +19,39 @@ build:6-7.1:
|
|||||||
|
|
||||||
test:6-7.1:
|
test:6-7.1:
|
||||||
stage: test
|
stage: test
|
||||||
image: ${CI_REGISTRY}/leenooks/ci-tsm:6-7.1
|
image: leenooks/ci-tsm:6-7.1
|
||||||
dependencies:
|
dependencies:
|
||||||
- build:6-7.1
|
- build:6-7.1
|
||||||
script:
|
script:
|
||||||
- cd test && ./test.sh
|
- cd test && ./test.sh
|
||||||
only:
|
only:
|
||||||
- c6
|
- master
|
||||||
tags:
|
tags:
|
||||||
- C
|
- C
|
||||||
- x86_64
|
|
||||||
|
|
||||||
# Compile on CentOS 6.x, for some reason compiling on CentOS 7.x results in buffer corruption
|
# Compile on CentOS 6.x, for some reason compiling on CentOS 7.x results in buffer corruption
|
||||||
build:7-8.1:
|
build:7-7.1:
|
||||||
stage: build
|
stage: build
|
||||||
image: ${CI_REGISTRY}/leenooks/ci-tsm:7-8.1
|
image: leenooks/ci-tsm:7-7.1
|
||||||
script:
|
script:
|
||||||
- make -f Makefile.linux64
|
- make -f Makefile.linux64
|
||||||
only:
|
only:
|
||||||
- master
|
- master
|
||||||
tags:
|
tags:
|
||||||
- C
|
- C
|
||||||
- x86_64
|
|
||||||
artifacts:
|
artifacts:
|
||||||
name: "$CI_BUILD_NAME"
|
name: "$CI_BUILD_NAME"
|
||||||
paths:
|
paths:
|
||||||
- tsmpipe
|
- tsmpipe
|
||||||
|
|
||||||
test:7-8.1:
|
test:7-7.1:
|
||||||
stage: test
|
stage: test
|
||||||
image: ${CI_REGISTRY}/leenooks/ci-tsm:7-8.1
|
image: leenooks/ci-tsm:7-7.1
|
||||||
dependencies:
|
dependencies:
|
||||||
- build:7-8.1
|
- build:7-7.1
|
||||||
script:
|
script:
|
||||||
- cd test && ./test.sh
|
- cd test && ./test.sh
|
||||||
only:
|
only:
|
||||||
- master
|
- master
|
||||||
tags:
|
tags:
|
||||||
- C
|
- C
|
||||||
- x86_64
|
|
||||||
artifacts:
|
|
||||||
name: "$CI_BUILD_NAME"
|
|
||||||
paths:
|
|
||||||
- tsmpipe
|
|
||||||
|
|
||||||
docker:7-8.1:
|
|
||||||
stage: docker
|
|
||||||
image: docker:latest
|
|
||||||
services:
|
|
||||||
- docker:dind
|
|
||||||
|
|
||||||
before_script:
|
|
||||||
- docker info
|
|
||||||
- docker version
|
|
||||||
- echo "$CI_JOB_TOKEN" | docker login -u "$CI_REGISTRY_USER" "$CI_REGISTRY" --password-stdin
|
|
||||||
variables:
|
|
||||||
CACHETAG: build
|
|
||||||
VERSION: 8.1.7
|
|
||||||
DOCKER_HOST: tcp://docker:2375
|
|
||||||
dependencies:
|
|
||||||
- test:7-8.1
|
|
||||||
script:
|
|
||||||
- if [ -f init ]; then chmod 500 init; fi
|
|
||||||
- docker pull ${CI_REGISTRY_IMAGE}:${CACHETAG} || true
|
|
||||||
- docker build --cache-from ${CI_REGISTRY_IMAGE}:${CACHETAG} -t ${CI_REGISTRY_IMAGE}:${VERSION} -t ${CI_REGISTRY_IMAGE}:${CACHETAG} .
|
|
||||||
- docker run ${CI_REGISTRY_IMAGE}:${VERSION} -h
|
|
||||||
- docker push ${CI_REGISTRY_IMAGE}:${VERSION}
|
|
||||||
- docker push ${CI_REGISTRY_IMAGE}:${CACHETAG}
|
|
||||||
tags:
|
|
||||||
- docker
|
|
||||||
- x86_64
|
|
||||||
only:
|
|
||||||
- master
|
|
||||||
|
26
Dockerfile
26
Dockerfile
@ -1,26 +0,0 @@
|
|||||||
# NAME deon/tsmpipe
|
|
||||||
# VERSION 8.1.7
|
|
||||||
|
|
||||||
FROM centos:7
|
|
||||||
|
|
||||||
# If using FTP source (change tar to not use z)
|
|
||||||
#RUN SOURCE_URL=ftp://public.dhe.ibm.com/storage/tivoli-storage-management/maintenance/client/v8r1/Linux/LinuxX86/BA/v812/8.1.2.0-TIV-TSMBAC-LinuxX86.tar \
|
|
||||||
|
|
||||||
# If using PPA source
|
|
||||||
RUN SOURCE_URL=http://yum.leenooks.vpn/docker/tsm/8.x/SP_CLIENT_8.1.7_LIN86_ML.tar.gz \
|
|
||||||
&& PREFIX=TSMCLI_LNX/tsmcli/linux86 \
|
|
||||||
&& CHARS=$(echo ${PREFIX} | awk -F"/" '{print NF}') \
|
|
||||||
&& curl -SL ${SOURCE_URL} | tar -zC /tmp/ --strip-components ${CHARS} -xf - ${PREFIX}/gskcrypt64-*.linux.x86_64.rpm ${PREFIX}/gskssl64-*.linux.x86_64.rpm ${PREFIX}/TIVsm-API64.x86_64.rpm \
|
|
||||||
&& yum install -y /tmp/*rpm && rm -rf /tmp/*rpm /var/cache/yum
|
|
||||||
|
|
||||||
RUN ln -s /tsm/dsm.sys /opt/tivoli/tsm/client/api/bin64/ \
|
|
||||||
&& ln -s /tsm/dsm.opt /opt/tivoli/tsm/client/api/bin64/ \
|
|
||||||
&& ln -s /tsm/dsmcert.kdb /opt/tivoli/tsm/client/api/bin64/ \
|
|
||||||
&& ln -s /tsm/dsmcert.sth /opt/tivoli/tsm/client/api/bin64/
|
|
||||||
|
|
||||||
COPY tsmpipe /usr/bin
|
|
||||||
|
|
||||||
VOLUME [ "/tsm" ]
|
|
||||||
|
|
||||||
# Starting
|
|
||||||
ENTRYPOINT [ "/usr/bin/tsmpipe" ]
|
|
40
README.md
40
README.md
@ -1,40 +0,0 @@
|
|||||||
# About
|
|
||||||
TSMPIPE is a Tivoli Storage Manager (TSM) or now known as Spectrum Protect client, that enables you to take data from STDIN and store that in TSM as a BACKUP or ARCHIVE object.
|
|
||||||
By using this client, you dont need to do a dump to disk process, followed by using the Spectrum Protect Backup Archive Client. (So no more consuming disk space with old dumps!)
|
|
||||||
|
|
||||||
Restoring data, is the reverse step, restoring directly back to the application from Spectrum Protect.
|
|
||||||
|
|
||||||
# Using
|
|
||||||
In its simplest form, you can
|
|
||||||
```cat myfile.ext | tsmpipe -c [MORE OPTIONS]```
|
|
||||||
|
|
||||||
Or, where an application supports "dumping" to STDOUT, you can pipe that dump into TSMPIPE.
|
|
||||||
```myappdump | tsmpipe -c [OPTIONS]```
|
|
||||||
|
|
||||||
Getting data back is the reverse
|
|
||||||
```tsmpipe -x [MORE OPTIONS] > myfile```
|
|
||||||
|
|
||||||
Or, back to your application
|
|
||||||
```tsmpipe -x [MORE OPTIONS] | myapp```
|
|
||||||
|
|
||||||
This client can also calculate a digest while backuping up data (like MD5, SHA1, etc) - so that you can verify that the dump out of the application matches what goes into
|
|
||||||
Spectrum Protect. For example:
|
|
||||||
|
|
||||||
```
|
|
||||||
myappdump > file
|
|
||||||
md5sum file
|
|
||||||
cat file | tsmpipe -cBs /example/ -f file -m md5
|
|
||||||
tsmpipe -xBs /example/ -f file > file2
|
|
||||||
md5sum file2
|
|
||||||
```
|
|
||||||
|
|
||||||
The MD5 calculation should match in all cases - including the MD5 printed by tsmpipe. See the build test script for more details.
|
|
||||||
# Building
|
|
||||||
Building TSMPIPE is hopefully relatively easy - it's currently only tested on Linux (specifically CentOS), but it should be buildable on other Spectrum Protect
|
|
||||||
supported platforms, however you may need to create an appropriate Makefile.
|
|
||||||
|
|
||||||
Here is a blog on building on Linux: https://thefrinkiac7.wordpress.com/data-protection/building-tsmpipe
|
|
||||||
|
|
||||||
# Help
|
|
||||||
For help, use tsmpipe -h
|
|
||||||
To test that you can connect to TSM, use tsmpipe -i
|
|
@ -18,17 +18,16 @@ char *units(double size) {
|
|||||||
int div = 0;
|
int div = 0;
|
||||||
double rem = 0;
|
double rem = 0;
|
||||||
int base = 1024;
|
int base = 1024;
|
||||||
int s_size = 128;
|
|
||||||
|
|
||||||
char *s;
|
char *s;
|
||||||
|
|
||||||
s = "\0";
|
s = "\0";
|
||||||
s = malloc(s_size);
|
s = malloc(128);
|
||||||
if (s==NULL) {
|
if (s==NULL) {
|
||||||
perror("Arg, out of memory?");
|
perror("Arg, out of memory?");
|
||||||
exit(255);
|
exit(255);
|
||||||
}
|
}
|
||||||
memset(s,0x00,s_size);
|
memset(s,0x00,(sizeof s));
|
||||||
|
|
||||||
while (size >= base && div < (int)(sizeof SIZES / sizeof *SIZES)-1) {
|
while (size >= base && div < (int)(sizeof SIZES / sizeof *SIZES)-1) {
|
||||||
if (verbose > 2)
|
if (verbose > 2)
|
||||||
|
@ -72,16 +72,14 @@ dsmDate dsmStrToDate(char *s) {
|
|||||||
char *dsmDateToStr(dsmDate date) {
|
char *dsmDateToStr(dsmDate date) {
|
||||||
char *s;
|
char *s;
|
||||||
|
|
||||||
int s_size = 32;
|
s = malloc(19);
|
||||||
|
|
||||||
s = malloc(s_size);
|
|
||||||
|
|
||||||
if (s==NULL) {
|
if (s==NULL) {
|
||||||
perror("Arg, out of memory?");
|
perror("Arg, out of memory?");
|
||||||
exit(255);
|
exit(255);
|
||||||
}
|
}
|
||||||
|
|
||||||
memset(s,0x00,s_size);
|
memset(s,0x00,(sizeof s));
|
||||||
|
|
||||||
sprintf(s,"%04i-%02i-%02i %02i:%02i:%02i",
|
sprintf(s,"%04i-%02i-%02i %02i:%02i:%02i",
|
||||||
date.year,
|
date.year,
|
||||||
@ -147,7 +145,7 @@ char *dsmObjnameToStr(dsmObjName objName) {
|
|||||||
exit(255);
|
exit(255);
|
||||||
}
|
}
|
||||||
|
|
||||||
memset(s,0x00,sizeof(dsmObjName));
|
memset(s,0x00,(sizeof s));
|
||||||
|
|
||||||
sprintf(s,"%s%s%s",objName.fs,objName.hl,objName.ll);
|
sprintf(s,"%s%s%s",objName.fs,objName.hl,objName.ll);
|
||||||
|
|
||||||
|
@ -133,11 +133,10 @@ double tsm_sendfile(dsUint32_t dsmHandle, char *fsname, char *filename, long lon
|
|||||||
|
|
||||||
#ifdef USE_DIGEST
|
#ifdef USE_DIGEST
|
||||||
char digest_str[EVP_MAX_MD_SIZE*2];
|
char digest_str[EVP_MAX_MD_SIZE*2];
|
||||||
EVP_MD_CTX *mdctx;
|
EVP_MD_CTX mdctx;
|
||||||
const EVP_MD *md=NULL;
|
const EVP_MD *md=NULL;
|
||||||
unsigned char md_value[EVP_MAX_MD_SIZE];
|
unsigned char md_value[EVP_MAX_MD_SIZE];
|
||||||
unsigned int md_len, i;
|
unsigned int md_len, i;
|
||||||
mdctx = NULL;
|
|
||||||
|
|
||||||
if (digest) {
|
if (digest) {
|
||||||
OpenSSL_add_all_digests();
|
OpenSSL_add_all_digests();
|
||||||
@ -230,8 +229,8 @@ double tsm_sendfile(dsUint32_t dsmHandle, char *fsname, char *filename, long lon
|
|||||||
|
|
||||||
#ifdef USE_DIGEST
|
#ifdef USE_DIGEST
|
||||||
if (digest) {
|
if (digest) {
|
||||||
mdctx = EVP_MD_CTX_new();
|
EVP_MD_CTX_init(&mdctx);
|
||||||
EVP_DigestInit_ex(mdctx, md, NULL);
|
EVP_DigestInit_ex(&mdctx, md, NULL);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@ -251,7 +250,7 @@ double tsm_sendfile(dsUint32_t dsmHandle, char *fsname, char *filename, long lon
|
|||||||
|
|
||||||
#ifdef USE_DIGEST
|
#ifdef USE_DIGEST
|
||||||
if (digest)
|
if (digest)
|
||||||
EVP_DigestUpdate(mdctx, buffer, nbytes);
|
EVP_DigestUpdate(&mdctx, buffer, nbytes);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
dataBlk.bufferLen = nbytes;
|
dataBlk.bufferLen = nbytes;
|
||||||
@ -290,8 +289,8 @@ double tsm_sendfile(dsUint32_t dsmHandle, char *fsname, char *filename, long lon
|
|||||||
|
|
||||||
#ifdef USE_DIGEST
|
#ifdef USE_DIGEST
|
||||||
if (digest) {
|
if (digest) {
|
||||||
EVP_DigestFinal_ex(mdctx, md_value, &md_len);
|
EVP_DigestFinal_ex(&mdctx, md_value, &md_len);
|
||||||
EVP_MD_CTX_free(mdctx);
|
EVP_MD_CTX_cleanup(&mdctx);
|
||||||
|
|
||||||
for(i=0; i<md_len; i++)
|
for(i=0; i<md_len; i++)
|
||||||
sprintf(digest_str+(i*2), "%02x", md_value[i]);
|
sprintf(digest_str+(i*2), "%02x", md_value[i]);
|
||||||
@ -440,15 +439,14 @@ int tsm_deletefile(dsUint32_t dsmHandle, dsmQueryType qType, qryArchiveData qaDa
|
|||||||
extern int verbose;
|
extern int verbose;
|
||||||
dsInt16_t rc=0;
|
dsInt16_t rc=0;
|
||||||
dsUint16_t reason=0;
|
dsUint16_t reason=0;
|
||||||
|
dsmDelInfo *dInfoP;
|
||||||
dsmDelType dType;
|
dsmDelType dType;
|
||||||
dsmDelInfo delInfo;
|
|
||||||
struct matchone_cb_data cbdata;
|
struct matchone_cb_data cbdata;
|
||||||
dsmBool_t friendly=bFalse;
|
dsmBool_t friendly=bFalse;
|
||||||
|
|
||||||
cbdata.numfound = 0;
|
cbdata.numfound = 0;
|
||||||
|
|
||||||
/** Our purge function uses qtReserved8 - this will break in a future release of the API **/
|
rc = tsm_queryfile(dsmHandle,qType,tsm_matchone_cb,&cbdata,qaData,qbData,friendly);
|
||||||
rc = tsm_queryfile(dsmHandle,((qType == qtBackup || qType == qtReserved8) ? qtBackup : qtArchive),tsm_matchone_cb,&cbdata,qaData,qbData,friendly);
|
|
||||||
if (rc != DSM_RC_OK) {
|
if (rc != DSM_RC_OK) {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
@ -464,35 +462,24 @@ int tsm_deletefile(dsUint32_t dsmHandle, dsmQueryType qType, qryArchiveData qaDa
|
|||||||
|
|
||||||
dType = dtArchive;
|
dType = dtArchive;
|
||||||
|
|
||||||
delInfo.archInfo.stVersion = delArchVersion;
|
delArch daInfo;
|
||||||
delInfo.archInfo.objId = cbdata.objId;
|
daInfo.stVersion = delArchVersion;
|
||||||
|
daInfo.objId = cbdata.objId;
|
||||||
|
|
||||||
|
dInfoP = (dsmDelInfo *) &daInfo;
|
||||||
|
|
||||||
} else if (qType == qtBackup) {
|
} else if (qType == qtBackup) {
|
||||||
if (verbose)
|
if (verbose)
|
||||||
fprintf(stderr,"%s: Deleting backup file %s with id [%u-%u]\n",__func__,dsmObjnameToStr(*qbData.objName),cbdata.objId.hi,cbdata.objId.lo);
|
fprintf(stderr,"%s: Deleting backup file %s\n",__func__,dsmObjnameToStr(*qbData.objName));
|
||||||
|
|
||||||
dType = dtBackup;
|
dType = dtBackup;
|
||||||
|
|
||||||
dsmObjName objName;
|
delBack dbInfo;
|
||||||
memset(&objName,0x00,sizeof(objName));
|
dbInfo.stVersion = delBackVersion;
|
||||||
strcpy(objName.fs,qbData.objName->fs);
|
dbInfo.objNameP = qbData.objName;
|
||||||
strcpy(objName.hl,qbData.objName->hl);
|
dbInfo.copyGroup = cbdata.copyGroup;
|
||||||
strcpy(objName.ll,qbData.objName->ll);
|
|
||||||
objName.objType = DSM_OBJ_FILE;
|
|
||||||
|
|
||||||
delInfo.backInfo.stVersion = delBackVersion;
|
dInfoP = (dsmDelInfo *) &dbInfo;
|
||||||
delInfo.backInfo.objNameP = &objName;
|
|
||||||
delInfo.backInfo.copyGroup = cbdata.copyGroup;
|
|
||||||
|
|
||||||
/** Our purge function uses qtReserved8 - this will break in a future release of the API **/
|
|
||||||
} else if (qType == qtReserved8) {
|
|
||||||
if (verbose)
|
|
||||||
fprintf(stderr,"%s: Purging backup file %s with id [%u-%u]\n",__func__,dsmObjnameToStr(*qbData.objName),cbdata.objId.hi,cbdata.objId.lo);
|
|
||||||
|
|
||||||
dType = dtBackupID;
|
|
||||||
|
|
||||||
delInfo.backIDInfo.stVersion = delBackIDVersion;
|
|
||||||
delInfo.backIDInfo.objId = cbdata.objId;
|
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
fprintf(stderr,"%s: UNKNOWN Type %d\n",__func__,qType);
|
fprintf(stderr,"%s: UNKNOWN Type %d\n",__func__,qType);
|
||||||
@ -505,7 +492,7 @@ int tsm_deletefile(dsUint32_t dsmHandle, dsmQueryType qType, qryArchiveData qaDa
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
rc = dsmDeleteObj(dsmHandle,dType,delInfo);
|
rc = dsmDeleteObj(dsmHandle,dType,*dInfoP);
|
||||||
if (rc != DSM_RC_OK) {
|
if (rc != DSM_RC_OK) {
|
||||||
printf("%s: dsmDeleteObj() failed %s\n",__func__,tsm_printerr(dsmHandle,rc));
|
printf("%s: dsmDeleteObj() failed %s\n",__func__,tsm_printerr(dsmHandle,rc));
|
||||||
return 0;
|
return 0;
|
||||||
|
@ -23,7 +23,7 @@ char *tsm_printerr(dsUint32_t dsmHandle, dsInt16_t rc) {
|
|||||||
char rcStr[DSM_MAX_RC_MSG_LENGTH];
|
char rcStr[DSM_MAX_RC_MSG_LENGTH];
|
||||||
char *s;
|
char *s;
|
||||||
|
|
||||||
s = malloc(DSM_MAX_RC_MSG_LENGTH+5);
|
s = malloc(sizeof(rcStr));
|
||||||
|
|
||||||
if (rc == DSM_RC_WILL_ABORT) {
|
if (rc == DSM_RC_WILL_ABORT) {
|
||||||
dsUint16_t reason;
|
dsUint16_t reason;
|
||||||
@ -79,7 +79,6 @@ dsUint32_t tsm_initsess(char *options, char *password) {
|
|||||||
dsInt16_t rc=0;
|
dsInt16_t rc=0;
|
||||||
dsUint32_t dsmHandle=0;
|
dsUint32_t dsmHandle=0;
|
||||||
dsmApiVersionEx applApi;
|
dsmApiVersionEx applApi;
|
||||||
dsmAppVersion pipeApi;
|
|
||||||
dsmInitExIn_t initIn;
|
dsmInitExIn_t initIn;
|
||||||
dsmInitExOut_t initOut;
|
dsmInitExOut_t initOut;
|
||||||
optStruct dsmOpt;
|
optStruct dsmOpt;
|
||||||
@ -96,13 +95,6 @@ dsUint32_t tsm_initsess(char *options, char *password) {
|
|||||||
applApi.level = DSM_API_LEVEL;
|
applApi.level = DSM_API_LEVEL;
|
||||||
applApi.subLevel = DSM_API_SUBLEVEL;
|
applApi.subLevel = DSM_API_SUBLEVEL;
|
||||||
|
|
||||||
memset(&pipeApi,0x00,sizeof(dsmAppVersion));
|
|
||||||
pipeApi.stVersion = appVersionVer;
|
|
||||||
pipeApi.applicationVersion = TSMPIPE_VERSION;
|
|
||||||
pipeApi.applicationRelease = TSMPIPE_RELEASE;
|
|
||||||
pipeApi.applicationLevel = TSMPIPE_LEVEL;
|
|
||||||
pipeApi.applicationSubLevel = TSMPIPE_SUBLEVEL;
|
|
||||||
|
|
||||||
memset(&initIn,0x00,sizeof(dsmInitExIn_t));
|
memset(&initIn,0x00,sizeof(dsmInitExIn_t));
|
||||||
initIn.stVersion = dsmInitExInVersion;
|
initIn.stVersion = dsmInitExInVersion;
|
||||||
initIn.apiVersionExP = &applApi;
|
initIn.apiVersionExP = &applApi;
|
||||||
@ -114,7 +106,6 @@ dsUint32_t tsm_initsess(char *options, char *password) {
|
|||||||
initIn.options = options;
|
initIn.options = options;
|
||||||
initIn.userNameP = NULL;
|
initIn.userNameP = NULL;
|
||||||
initIn.userPasswordP = NULL;
|
initIn.userPasswordP = NULL;
|
||||||
initIn.appVersionP = &pipeApi;
|
|
||||||
//initIn.dirDelimiter = dirDelimiter;
|
//initIn.dirDelimiter = dirDelimiter;
|
||||||
//initIn.useUnicode = useUnicode;
|
//initIn.useUnicode = useUnicode;
|
||||||
//initIn.bEncryptKeyEnabled = encrypt;
|
//initIn.bEncryptKeyEnabled = encrypt;
|
||||||
@ -180,11 +171,8 @@ int tsm_sessioninfo(dsUint32_t dsmHandle) {
|
|||||||
dsmQueryApiVersionEx(&apiLibVer);
|
dsmQueryApiVersionEx(&apiLibVer);
|
||||||
|
|
||||||
printf("Application Version:\n");
|
printf("Application Version:\n");
|
||||||
printf(" TSMPIPE Version: %d.%d.%d.%d\n",
|
printf(" TSMPIPE Version: %s\n",
|
||||||
TSMPIPE_VERSION,
|
_TSMPIPE_VERSION);
|
||||||
TSMPIPE_RELEASE,
|
|
||||||
TSMPIPE_LEVEL,
|
|
||||||
TSMPIPE_SUBLEVEL);
|
|
||||||
printf(" TSMPIPE API Version: %d.%d.%d.%d\n",
|
printf(" TSMPIPE API Version: %d.%d.%d.%d\n",
|
||||||
DSM_API_VERSION,
|
DSM_API_VERSION,
|
||||||
DSM_API_RELEASE,
|
DSM_API_RELEASE,
|
||||||
|
@ -1 +0,0 @@
|
|||||||
COMPRESSAlways Y
|
|
@ -3,7 +3,7 @@ SErvername test
|
|||||||
COMMmethod TCPip
|
COMMmethod TCPip
|
||||||
MANAGEDServices schedule
|
MANAGEDServices schedule
|
||||||
TCPPort 1500
|
TCPPort 1500
|
||||||
TCPServeraddress tsm.leenooks.net
|
TCPServeraddress tsm.leenooks.vpn
|
||||||
PASSWORDAccess generate
|
PASSWORDAccess generate
|
||||||
SCHEDMode polling
|
SCHEDMode polling
|
||||||
|
|
||||||
@ -16,5 +16,3 @@ SErvername test
|
|||||||
TCPBuffsize 32
|
TCPBuffsize 32
|
||||||
TCPWindowsize 64
|
TCPWindowsize 64
|
||||||
SSL No
|
SSL No
|
||||||
|
|
||||||
PASSWORDDIR /tsm
|
|
||||||
|
77
test/test.sh
77
test/test.sh
@ -1,94 +1,43 @@
|
|||||||
#!/bin/sh
|
#!/bin/sh
|
||||||
cd $(dirname $0)
|
|
||||||
|
|
||||||
set -e
|
set -e
|
||||||
FILE=random.1m
|
FILE=random.1m
|
||||||
VERBOSE=${VERBOSE:-""}
|
|
||||||
|
|
||||||
# Create TEST File
|
# Create TEST File
|
||||||
MD5=$(dd if=/dev/urandom bs=10240 count=1024 2>/dev/null |tee ${FILE} |md5sum |awk '{print $1}')
|
MD5=$(dd if=/dev/urandom bs=1024 count=1024 2>/dev/null |tee ${FILE} |md5sum |awk '{print $1}')
|
||||||
SIZE=$(ls -l ${FILE}|awk '{print $5}')
|
SIZE=$(ls -l ${FILE}|awk '{print $5}')
|
||||||
TSMOPT="-VIRTUALNODENAME=TEST -PASSWORD=password -COMPRESSALWAYS=YES"
|
|
||||||
|
|
||||||
TSMPIPE=../tsmpipe
|
TSMPIPE=../tsmpipe
|
||||||
|
|
||||||
echo "MD5 of [${FILE}] is [${MD5}] (${SIZE})"
|
echo "MD5 of [${FILE}] is [${MD5}] (${SIZE})"
|
||||||
|
|
||||||
ln -fs /opt/tivoli/tsm/client/api/bin64/EN_US
|
ln -s /opt/tivoli/tsm/client/api/bin64/EN_US
|
||||||
export DSMI_DIR=./
|
export DSMI_DIR=./
|
||||||
export DSMI_CONFIG=dsm.opt
|
export DSMI_CONFIG=dsm.opt
|
||||||
|
|
||||||
# Send file to TSM
|
# Send file to TSM
|
||||||
echo "+++ TEST BACKUP ++++!"
|
echo "+ TEST SEND FILE!"
|
||||||
echo "+ BACKUP: SEND FILE!"
|
cat ${FILE} | ${TSMPIPE} -Bcm MD5 -s /test -f ${FILE} -vvv -l ${SIZE} -O"-VIRTUALNODENAME=TEST -PASSWORD=TEST"
|
||||||
cat ${FILE} | ${TSMPIPE} -Bcm MD5 -s /test -f ${FILE} ${VERBOSE} -l ${SIZE} -O"${TSMOPT}"
|
|
||||||
|
|
||||||
# Send a second time
|
# Send a second time
|
||||||
echo "+ BACKUP: SEND FILE AGAIN!"
|
echo "+ TEST SEND FILE AGAIN!"
|
||||||
cat ${FILE} | ${TSMPIPE} -Bcm MD5 -s /test -f ${FILE} ${VERBOSE} -l ${SIZE} -O"${TSMOPT}"
|
cat ${FILE} | ${TSMPIPE} -Bcm MD5 -s /test -f ${FILE} -vvv -l ${SIZE} -O"-VIRTUALNODENAME=TEST -PASSWORD=TEST"
|
||||||
|
|
||||||
# List it
|
# List it
|
||||||
echo "+ BACKUP: LIST FILE!"
|
echo "+ TEST LIST FILE!"
|
||||||
${TSMPIPE} -Bts /test -f ${FILE} -O"${TSMOPT}"
|
${TSMPIPE} -Bts /test -f ${FILE} -vvv -O"-VIRTUALNODENAME=TEST -PASSWORD=TEST"
|
||||||
|
|
||||||
# Get it back
|
# Get it back
|
||||||
echo "+ BACKUP: RETRIEVE FILE!"
|
echo "+ TEST RETRIEVE FILE!"
|
||||||
${TSMPIPE} -Bxs /test -f ${FILE} ${VERBOSE} -O"${TSMOPT}" > ${FILE}.back
|
${TSMPIPE} -Bxs /test -f ${FILE} -vvv -O"-VIRTUALNODENAME=TEST -PASSWORD=TEST" > ${FILE}.back
|
||||||
RETRIEVE=$(md5sum ${FILE}.back | awk '{print $1}')
|
RETRIEVE=$(md5sum ${FILE}.back | awk '{print $1}')
|
||||||
if [ "${MD5}" != "${RETRIEVE}" ]; then
|
if [ "${MD5}" != "${RETRIEVE}" ]; then
|
||||||
exit 1
|
exit 1
|
||||||
else
|
else
|
||||||
echo "+ BACKUP: RETRIEVE VALID (${RETRIEVE})!"
|
echo "+ RETRIEVE VALID (${RETRIEVE})!"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Purge the last one
|
|
||||||
echo "+ BACKUP: PURGE!"
|
|
||||||
${TSMPIPE} -Bgs /test -f ${FILE} ${VERBOSE} -O"${TSMOPT}"
|
|
||||||
|
|
||||||
# List it
|
|
||||||
echo "+ BACKUP: LIST FILE IS PURGED!"
|
|
||||||
${TSMPIPE} -Bts /test -f ${FILE} -O"${TSMOPT}"
|
|
||||||
|
|
||||||
# Delete it
|
# Delete it
|
||||||
echo "+ BACKUP: DELETE!"
|
echo "+ TEST DELETE!"
|
||||||
${TSMPIPE} -Bds /test -f ${FILE} ${VERBOSE} -O"${TSMOPT}"
|
${TSMPIPE} -Bds /test -f ${FILE} -vvv -O"-VIRTUALNODENAME=TEST -PASSWORD=TEST"
|
||||||
|
|
||||||
# List it
|
|
||||||
echo "+ BACKUP: LIST FILE IS DELETED!"
|
|
||||||
${TSMPIPE} -Bts /test -f ${FILE} -O"${TSMOPT}"
|
|
||||||
echo "+++ END BACKUP ++++!"
|
|
||||||
|
|
||||||
echo "+++ TEST ARCHIVE ++++!"
|
|
||||||
echo "+ ARCHIVE: SEND FILE!"
|
|
||||||
cat ${FILE} | ${TSMPIPE} -Acm MD5 -s /test -f ${FILE} ${VERBOSE} -l ${SIZE} -D"Test Archive File" -O"${TSMOPT}"
|
|
||||||
|
|
||||||
# Send a second time
|
|
||||||
echo "+ ARCHIVE: SEND FILE AGAIN! (delay)"
|
|
||||||
sleep 2
|
|
||||||
cat ${FILE} | ${TSMPIPE} -Acm MD5 -s /test -f ${FILE} ${VERBOSE} -l ${SIZE} -D"Test Archive File" -O"${TSMOPT}"
|
|
||||||
DATE=$(date +%m%d%Y:%H%M%S)
|
|
||||||
|
|
||||||
# List it
|
|
||||||
echo "+ ARCHIVE: LIST FILE!"
|
|
||||||
${TSMPIPE} -Ats /test -f ${FILE} -O"${TSMOPT}"
|
|
||||||
|
|
||||||
# Get it back
|
|
||||||
echo "+ ARCIHVE: RETRIEVE FILE! (${DATE})"
|
|
||||||
${TSMPIPE} -Axs /test -f ${FILE} -n ${DATE} ${VERBOSE} -O"${TSMOPT}" > ${FILE}.back
|
|
||||||
RETRIEVE=$(md5sum ${FILE}.back | awk '{print $1}')
|
|
||||||
if [ "${MD5}" != "${RETRIEVE}" ]; then
|
|
||||||
exit 1
|
|
||||||
else
|
|
||||||
echo "+ ARCHIVE: RETRIEVE VALID (${RETRIEVE})!"
|
|
||||||
fi
|
|
||||||
|
|
||||||
# Purge the last one
|
|
||||||
echo "+ ARCHIVE: DELETE!"
|
|
||||||
${TSMPIPE} -Ads /test -f ${FILE} -n ${DATE} ${VERBOSE} -O"${TSMOPT}"
|
|
||||||
|
|
||||||
# List it
|
|
||||||
echo "+ ARCHIVE: LIST FILE AFTER DELETE!"
|
|
||||||
${TSMPIPE} -Ats /test -f ${FILE} -O"${TSMOPT}"
|
|
||||||
echo "+++ END ARCHIVE ++++!"
|
|
||||||
|
|
||||||
rm -f EN_US ${FILE} ${FILE}.back
|
rm -f EN_US ${FILE} ${FILE}.back
|
||||||
|
24
tsmpipe.c
24
tsmpipe.c
@ -67,9 +67,9 @@ int copy_env(const char *from, const char *to) {
|
|||||||
|
|
||||||
void usage(void) {
|
void usage(void) {
|
||||||
fprintf(stderr,
|
fprintf(stderr,
|
||||||
"tsmpipe %d.%d.%d.%d, usage:\n"
|
"tsmpipe %s, usage:\n"
|
||||||
"\n"
|
"\n"
|
||||||
"tsmpipe [-i|-p]|[[-A|-B|-U] [-c|-x|-d|-g|-t] -s fsname -f filepath [-l len] ...]\n"
|
"tsmpipe [-i|-p]|[[-A|-B|-U] [-c|-x|-d|-t] -s fsname -f filepath [-l len] ...]\n"
|
||||||
" -i Show session information\n"
|
" -i Show session information\n"
|
||||||
" -p Set Password\n"
|
" -p Set Password\n"
|
||||||
" -A, -B and -U are mutually exclusive:\n"
|
" -A, -B and -U are mutually exclusive:\n"
|
||||||
@ -80,7 +80,6 @@ void usage(void) {
|
|||||||
" -c Create: Read from stdin and store in TSM\n"
|
" -c Create: Read from stdin and store in TSM\n"
|
||||||
" -x eXtract: Recall from TSM and write to stdout\n"
|
" -x eXtract: Recall from TSM and write to stdout\n"
|
||||||
" -d Delete: Delete object from TSM\n"
|
" -d Delete: Delete object from TSM\n"
|
||||||
" -g purGe: Active Delete object from TSM\n"
|
|
||||||
" -t lisT: Print filelist to stdout\n"
|
" -t lisT: Print filelist to stdout\n"
|
||||||
" -s and -f are required arguments for (-A/ -B operations):\n"
|
" -s and -f are required arguments for (-A/ -B operations):\n"
|
||||||
" -s fsname Name of filespace in TSM\n"
|
" -s fsname Name of filespace in TSM\n"
|
||||||
@ -102,7 +101,7 @@ void usage(void) {
|
|||||||
#endif
|
#endif
|
||||||
" -v Verbose. More -v's gives more verbosity\n"
|
" -v Verbose. More -v's gives more verbosity\n"
|
||||||
" -V Verbose information on TSM transfer\n"
|
" -V Verbose information on TSM transfer\n"
|
||||||
,TSMPIPE_VERSION,TSMPIPE_RELEASE,TSMPIPE_LEVEL,TSMPIPE_SUBLEVEL);
|
,_TSMPIPE_VERSION);
|
||||||
|
|
||||||
exit(0);
|
exit(0);
|
||||||
}
|
}
|
||||||
@ -131,7 +130,7 @@ int main(int argc, char *argv[]) {
|
|||||||
char *digest=NULL;
|
char *digest=NULL;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
while ((c = getopt(argc, argv, "hiABcxdtUvVe:E:f:Fgl:L:m:n:N:s:D:O:pP:")) != -1) {
|
while ((c = getopt(argc, argv, "hiABcxdtUvVe:E:f:Fl:L:m:n:N:s:D:O:pP:")) != -1) {
|
||||||
switch(c) {
|
switch(c) {
|
||||||
case 'h': usage(); break;
|
case 'h': usage(); break;
|
||||||
case 'A': qType = qtArchive; break;
|
case 'A': qType = qtArchive; break;
|
||||||
@ -142,7 +141,6 @@ int main(int argc, char *argv[]) {
|
|||||||
case 'c': if (action != 0) usage_action(); action = ACTION_CREATE; break;
|
case 'c': if (action != 0) usage_action(); action = ACTION_CREATE; break;
|
||||||
case 'x': if (action != 0) usage_action(); action = ACTION_EXTRACT; break;
|
case 'x': if (action != 0) usage_action(); action = ACTION_EXTRACT; break;
|
||||||
case 'd': if (action != 0) usage_action(); action = ACTION_DELETE; break;
|
case 'd': if (action != 0) usage_action(); action = ACTION_DELETE; break;
|
||||||
case 'g': if (action != 0) usage_action(); action = ACTION_PURGE; break;
|
|
||||||
case 't': if (action != 0) usage_action(); action = ACTION_LIST; break;
|
case 't': if (action != 0) usage_action(); action = ACTION_LIST; break;
|
||||||
case 'U': if (action != 0) usage_action(); action = ACTION_UPDATE; break;
|
case 'U': if (action != 0) usage_action(); action = ACTION_UPDATE; break;
|
||||||
|
|
||||||
@ -225,10 +223,6 @@ int main(int argc, char *argv[]) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (action == ACTION_PURGE && qType != qtBackup) {
|
|
||||||
debugLog(0,__func__,"ERROR: -g can only be used with -B",1);
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Let the TSM api get the signals */
|
/* Let the TSM api get the signals */
|
||||||
signal(SIGPIPE, SIG_IGN);
|
signal(SIGPIPE, SIG_IGN);
|
||||||
signal(SIGINT, SIG_IGN);
|
signal(SIGINT, SIG_IGN);
|
||||||
@ -278,7 +272,6 @@ int main(int argc, char *argv[]) {
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
case ACTION_DELETE:
|
case ACTION_DELETE:
|
||||||
case ACTION_PURGE:
|
|
||||||
case ACTION_LIST:
|
case ACTION_LIST:
|
||||||
case ACTION_EXTRACT:
|
case ACTION_EXTRACT:
|
||||||
memset(&qaData,0x00,sizeof(qryArchiveData));
|
memset(&qaData,0x00,sizeof(qryArchiveData));
|
||||||
@ -293,7 +286,6 @@ int main(int argc, char *argv[]) {
|
|||||||
qbData.owner = "";
|
qbData.owner = "";
|
||||||
|
|
||||||
switch (action) {
|
switch (action) {
|
||||||
case ACTION_PURGE:
|
|
||||||
case ACTION_DELETE:
|
case ACTION_DELETE:
|
||||||
qbData.objState = DSM_ACTIVE;
|
qbData.objState = DSM_ACTIVE;
|
||||||
break;
|
break;
|
||||||
@ -307,7 +299,7 @@ int main(int argc, char *argv[]) {
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (action == ACTION_DELETE || action == ACTION_PURGE || ! pitdate) {
|
if (action == ACTION_DELETE || ! pitdate) {
|
||||||
qbData.pitDate.year = DATE_MINUS_INFINITE;
|
qbData.pitDate.year = DATE_MINUS_INFINITE;
|
||||||
} else {
|
} else {
|
||||||
qbData.pitDate = dsmStrToDate(pitdate);
|
qbData.pitDate = dsmStrToDate(pitdate);
|
||||||
@ -350,12 +342,6 @@ int main(int argc, char *argv[]) {
|
|||||||
rc = tsm_deletefile(dsmHandle,qType,qaData,qbData);
|
rc = tsm_deletefile(dsmHandle,qType,qaData,qbData);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case ACTION_PURGE:
|
|
||||||
debugLog(2,__func__,"PURGE Operation",0);
|
|
||||||
/** We use qtReserved8 to let tsm_deletefile() know that we want to purge - this will break a future API **/
|
|
||||||
rc = tsm_deletefile(dsmHandle,qtReserved8,qaData,qbData);
|
|
||||||
break;
|
|
||||||
|
|
||||||
case ACTION_EXTRACT:
|
case ACTION_EXTRACT:
|
||||||
debugLog(2,__func__,"EXTRACT Operation",0);
|
debugLog(2,__func__,"EXTRACT Operation",0);
|
||||||
rc = tsm_restorefile(dsmHandle,qType,qaData,qbData);
|
rc = tsm_restorefile(dsmHandle,qType,qaData,qbData);
|
||||||
|
@ -1,7 +1,4 @@
|
|||||||
#define TSMPIPE_VERSION 1
|
#define _TSMPIPE_VERSION "1.6.5"
|
||||||
#define TSMPIPE_RELEASE 6
|
|
||||||
#define TSMPIPE_LEVEL 6
|
|
||||||
#define TSMPIPE_SUBLEVEL 0
|
|
||||||
#define INPUTLEN 1025
|
#define INPUTLEN 1025
|
||||||
|
|
||||||
#define ACTION_INFO 1
|
#define ACTION_INFO 1
|
||||||
@ -12,7 +9,6 @@
|
|||||||
#define ACTION_UPDATE 6
|
#define ACTION_UPDATE 6
|
||||||
#define ACTION_CREATE_UPDATE 7
|
#define ACTION_CREATE_UPDATE 7
|
||||||
#define ACTION_PASSWORD 8
|
#define ACTION_PASSWORD 8
|
||||||
#define ACTION_PURGE 9
|
|
||||||
#define DSM_COMM_TCPIP6 6 // There is no DSM_COMM_ const for TCPIPv6
|
#define DSM_COMM_TCPIP6 6 // There is no DSM_COMM_ const for TCPIPv6
|
||||||
|
|
||||||
// If you want to use MD5/SHA1 calculations as the data goes in here, ensure this is defined.
|
// If you want to use MD5/SHA1 calculations as the data goes in here, ensure this is defined.
|
||||||
|
Reference in New Issue
Block a user