Skip to end of banner
Go to start of banner

Backup SIL scripts

Skip to end of metadata
Go to start of metadata

You are viewing an old version of this page. View the current version.

Compare with Current View Page History

« Previous Version 2 Next »

We've encountered an issue exporting this macro. Please try exporting this page again later.
A utility that will archive and compress the all the files in the main silprograms directory into a tar file.
/**
* Creates a backup tar file of the silprograms directory.
* The tar file is then attached to a newly created Jira ticket to allow for download.
* @author Tim Reiking
* @date   2019/04/22
*/

string projectKey = "TRASH";        // The Jira project to create a new ticket
string type = "Task";               // Ticket type to create
string prefix = argv[0];            // Prefix the saved file name
string issueKey = argv[1];          // Generated Jira issue that contains backup

function backup(string env) {
    string fileName = prefix+replace(env, ".", "")+"DirBackup.tar.gz";
    string path = silEnv(env);
    string filePath = path+"/../"+fileName;
    //string command = "cd "+path+" && tar -czf "+filePath+" "+path;
    string command = "tar -czf "+filePath+" "+path;
     
    runnerLog(command);
    runnerLog("-------------");
    runnerLog(system(command));
     
    if(fileExists(filePath)) {
        if(isNull(issueKey)) { issueKey = createIssue(projectKey, "", type, "Created "+env+" backup"); }
        attachFile(filePath, issueKey);
        deleteFile(filePath);
    }
}
prefix = isNull(prefix) ? "" : prefix;
string cleanPath = silEnv("sil.home")+"/~";
if(directoryExists(cleanPath)) { system("rm -R "+cleanPath); }

backup("sil.home");
backup("kepler.home");

return issueKey;
  • No labels