Updated backup
This commit is contained in:
parent
2ff0ec353e
commit
00629ed332
@ -25,9 +25,12 @@ import org.apache.commons.compress.utils.IOUtils;
|
||||
|
||||
public class SibaManager
|
||||
{
|
||||
public static int pathLength;
|
||||
|
||||
public static File backup(final File toto, final String target) throws ArchiveException, IOException
|
||||
{
|
||||
pathLength = toto.getParentFile().getAbsolutePath().length();
|
||||
|
||||
/* String outputFileNameWithoutExtension = toto.getName()+"-"+ LocalDateTime.now(); */
|
||||
LocalDateTime date = LocalDateTime.now();
|
||||
DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd'_'H'H_'m");
|
||||
@ -53,6 +56,7 @@ public class SibaManager
|
||||
} */
|
||||
gzCompress.write(fileTar);
|
||||
gzCompress.close();
|
||||
output.delete();
|
||||
md5(output1, target + "/" + outputFileNameWithoutExtension + ".md5");
|
||||
return output1;
|
||||
}
|
||||
@ -61,13 +65,18 @@ public class SibaManager
|
||||
{
|
||||
for (File file : directory.listFiles())
|
||||
{
|
||||
|
||||
if (file.isDirectory())
|
||||
{
|
||||
directoryToSave(file, outputStream);
|
||||
}
|
||||
else
|
||||
{
|
||||
outputStream.putArchiveEntry(new TarArchiveEntry(file));
|
||||
TarArchiveEntry tae = new TarArchiveEntry(file);
|
||||
String pathPartiel = file.getPath().substring(pathLength);
|
||||
tae.setName(pathPartiel);
|
||||
/* outputStream.putArchiveEntry(new TarArchiveEntry(file)); */
|
||||
outputStream.putArchiveEntry(tae);
|
||||
IOUtils.copy(new FileInputStream(file), outputStream);
|
||||
outputStream.closeArchiveEntry();
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user