-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathdmp-periodic-backup.r
57 lines (55 loc) · 2.12 KB
/
dmp-periodic-backup.r
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
periodicArchive {
# dmp-periodic-backup.r
checkCollInput (*Src);
checkCollInput (*Dest);
checkRescInput (*Res, *DestZone);
# periodically archive a collection every week
collArchive (*Res, *Src, *Dest, *Acct);
writeLine("stdout","Periodic rule queued for archiving a collection");
}
collArchive (*Res, *Src, *Dest, *Acct) {
delay("<PLUSET>1m</PLUSET><EF>7d</EF>") {
# Loop over files in a collection, *Src
# Copy all files into an archive collection. *Dest
*Len = strlen(*Src);
#=============get current time, Timestamp is YYY-MM-DD.hh:mm:ss ================
msiGetSystemTime(*TimeA, "unix");
#============ create a collection for log files if it does not exist ===============
createLogFile (*Dest, "log", "Check", *Res, *LPath, *Lfile, *L_FD);
#============ find files to archive
*Query = select DATA_NAME, DATA_CHECKSUM,COLL_NAME where COLL_NAME like '*Src%';
foreach(*Row in *Query) {
*File = *Row.DATA_NAME;
*Check = *Row.DATA_CHECKSUM;
*Coll = *Row.COLL_NAME;
*L1 = strlen(*Coll);
*Src1 = *Coll ++ "/" ++ *File;
*C1 = substr(*Coll,*Len,*L1);
if(strlen(*C1)==0) {
*DestColl = *Dest;
*Dest1 = *Dest ++ "/" ++ *File;
} else {
*DestColl = *Dest ++ *C1;
*Dest1 = *Dest ++ *C1 ++ "/" ++ *File;
}
isColl(*DestColl, *Lfile, *Status1);
if (*Status1 == 0) {
# If file is already in the archive, do not copy it again
isData(*DestColl, *File, *Status);
if (*Status == "0") {
msiDataObjCopy(*Src1,*Dest1,"destRescName=*Res++++forceFlag=", *Status);
msiSetACL("default","own", "*Acct", *Dest1);
msiDataObjChksum(*Dest1, "forceChksum=", *Chksum);
if (*Check != *Chksum) {
writeLine("*Lfile", "Bad checksum for file *Dest1");
}
else { writeLine("*Lfile", "Moved file *Src1 to *Dest1");
writeLine("*Lfile", "Moved file *Src1 to *Dest1");
}
}
}
}
}
}
INPUT *Res=$"stage", *DestZone =$"ornlZone", *Acct =$"Mauna-acct", *Src=$"/Mauna/home/atmos/sensor", *Dest =$"/*DestZone/home/*Acct#Mauna/archive"
OUTPUT ruleExecOut