1 16 package org.outerj.daisy.backupTool; 17 18 import java.io.File ; 19 20 import org.outerj.daisy.backupTool.dbDump.DbDumper; 21 22 public class DbBackupEntry extends AbstractBackupEntry { 23 private DbDumper dbDumper; 24 private File tmpFile; 25 26 public DbBackupEntry(File backupFile, DbDumper dbDumper, BackupInstance buInstance) { 27 super(backupFile, buInstance); 28 String fileName = backupFile.getName(); 29 fileName = fileName.substring(0, fileName.lastIndexOf(".")+1) + "sql"; 30 tmpFile = new File (backupFile.getParentFile(), fileName ); 31 this.dbDumper = dbDumper; 32 } 33 34 public void backupInit() throws Exception { 35 this.backupFile.createNewFile(); 36 tmpFile.createNewFile(); 37 } 38 39 public void backup() throws Exception { 40 dbDumper.dump(tmpFile); 41 } 42 43 protected File getTempPath() { 44 return tmpFile; 45 } 46 47 public void restore() throws Exception { 48 tmpFile.createNewFile(); 49 BackupHelper.unzipToFile(backupFile, tmpFile); 50 dbDumper.restore(tmpFile); 51 BackupHelper.deleteFile(tmpFile); 52 } 53 54 protected boolean isNothing() { 55 return false; 56 } 57 } 58 | Popular Tags |