1 6 7 package com.sun.enterprise.config.backup.ui; 8 import java.io.*; 9 import com.sun.enterprise.util.Console; 10 import com.sun.enterprise.config.backup.status.StatusConstants; 11 import com.sun.enterprise.config.backup.BackupRequest; 12 import com.sun.enterprise.config.backup.appserver.BackupManager; 13 17 public class BackupUI 18 { 19 public BackupUI() 20 { 21 } 22 23 public static void main(String [] args) 24 { 25 String s; 26 String userInfo = "qberry"; 27 String execType = StatusConstants.STORAGE_TYPE_ZIP; 28 String fromDir = "C:/temp/domains/domain1/applications,C:/temp/domains/domain1/config,C:/temp/domains/domain1/generated"; 30 String toDir = "c:/temp/backuprestore"; 33 String command = "backup"; 34 boolean ask = false; 35 36 new File(toDir).mkdirs(); 37 38 if(ask) 39 { 40 s = Console.readLine("User Info [" + userInfo + "]"); 41 42 if(s.length() > 0) 43 userInfo = s; 44 45 if(userInfo.length() < 1) 46 userInfo = null; 47 48 s = Console.readLine("Backup Storage Type D|Z [" + execType + "]").toLowerCase(); 49 50 if(s != null && s.length() > 0) 51 { 52 if(s.charAt(0) == 'z') 53 execType = StatusConstants.STORAGE_TYPE_ZIP; 54 else 55 execType = StatusConstants.STORAGE_TYPE_DIRECTORY; 56 } 57 58 s = Console.readLine("Directory to backup: [" + fromDir + "]"); 59 60 if(s.length() > 0) 61 fromDir = s; 62 63 s = Console.readLine("Directory to store backup files: [" + toDir + "]"); 64 65 if(s.length() > 0) 66 toDir = s; 67 68 69 s = Console.readLine("Command: [" + command + "]"); 70 71 if(s.length() > 0) 72 command = s; 73 } 74 BackupRequest request = new BackupRequest(); 75 76 request.setDirToStoreBackupFiles(toDir); 77 request.setDirsToBackup(new String [] { fromDir }); 78 request.setBackupStorageType(execType); 79 request.setCommand(command); 80 request.setUserInfo(userInfo); 81 request.verify(); 82 BackupManager mgr = new BackupManager(); 83 84 mgr.execute(request); 85 } 86 } | Popular Tags |