Compare commits
No commits in common. "724d30343326f9c74019003859cec167bed6cc04" and "8221fb8ff7a2230b4ba54242b9d8eb4bab9b9f49" have entirely different histories.
724d303433
...
8221fb8ff7
@ -1,18 +1,9 @@
|
||||
import net.horizoncode.sysbackup.cli.CLIProcessor;
|
||||
|
||||
import java.io.File;
|
||||
import java.net.URISyntaxException;
|
||||
|
||||
public class Bootstrapper {
|
||||
|
||||
public static void main(String[] args) throws URISyntaxException {
|
||||
|
||||
File executionPath =
|
||||
new File(
|
||||
new File(Bootstrapper.class.getProtectionDomain().getCodeSource().getLocation().toURI())
|
||||
.getParent());
|
||||
|
||||
public static void main(String[] args) {
|
||||
CLIProcessor cliProcessor = new CLIProcessor();
|
||||
cliProcessor.startCLI(args, executionPath);
|
||||
cliProcessor.startCLI(args);
|
||||
}
|
||||
}
|
||||
|
@ -30,7 +30,7 @@ public class CLIProcessor {
|
||||
}
|
||||
}
|
||||
|
||||
public void startCLI(String[] args, File executionPath) {
|
||||
public void startCLI(String[] args) {
|
||||
try {
|
||||
if ((args == null) || (args.length == 0)) {
|
||||
usage();
|
||||
@ -46,7 +46,7 @@ public class CLIProcessor {
|
||||
return;
|
||||
}
|
||||
String fileName = args[1];
|
||||
File tasksFolder = new File(executionPath, "tasks");
|
||||
File tasksFolder = new File("tasks");
|
||||
if (!tasksFolder.exists())
|
||||
if (!tasksFolder.mkdir()) System.err.println("Failed to create tasks folder!");
|
||||
File taskFile = new File(tasksFolder, fileName + ".toml");
|
||||
@ -56,8 +56,7 @@ public class CLIProcessor {
|
||||
}
|
||||
|
||||
Config taskConfig = new Config(taskFile);
|
||||
TaskBuilder taskBuilder =
|
||||
TaskBuilder.builder().executionPath(executionPath).taskConfig(taskConfig).build();
|
||||
TaskBuilder taskBuilder = TaskBuilder.builder().taskConfig(taskConfig).build();
|
||||
taskBuilder.start();
|
||||
break;
|
||||
}
|
||||
@ -68,7 +67,7 @@ public class CLIProcessor {
|
||||
return;
|
||||
}
|
||||
String fileName = args[1];
|
||||
File tasksFolder = new File(executionPath, "tasks");
|
||||
File tasksFolder = new File("tasks");
|
||||
if (!tasksFolder.exists())
|
||||
if (!tasksFolder.mkdir()) System.err.println("Failed to create tasks folder!");
|
||||
System.out.println("Saving task config " + fileName + ".toml...");
|
||||
@ -85,7 +84,7 @@ public class CLIProcessor {
|
||||
return;
|
||||
}
|
||||
String fileName = args[1];
|
||||
File tasksFolder = new File(executionPath, "tasks");
|
||||
File tasksFolder = new File("tasks");
|
||||
if (!tasksFolder.exists())
|
||||
if (!tasksFolder.mkdir()) System.err.println("Failed to create tasks folder!");
|
||||
File taskFile = new File(tasksFolder, fileName + ".toml");
|
||||
|
@ -9,6 +9,7 @@ import org.apache.commons.io.FilenameUtils;
|
||||
import org.tomlj.TomlArray;
|
||||
|
||||
import java.io.File;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.Date;
|
||||
import java.util.concurrent.LinkedBlockingQueue;
|
||||
@ -22,11 +23,9 @@ public class TaskBuilder {
|
||||
|
||||
@Builder.Default private final LinkedBlockingQueue<Task> taskList = new LinkedBlockingQueue<>();
|
||||
|
||||
private final File executionPath;
|
||||
|
||||
public void start() {
|
||||
|
||||
File backupDir = new File(executionPath, "backups");
|
||||
File backupDir = new File("backups");
|
||||
if (!backupDir.exists())
|
||||
if (!backupDir.mkdir()) {
|
||||
System.err.println("Failed to create backups directory!");
|
||||
|
@ -8,9 +8,12 @@ import me.tongfei.progressbar.ProgressBarStyle;
|
||||
import net.horizoncode.sysbackup.tasks.Task;
|
||||
import net.lingala.zip4j.ZipFile;
|
||||
import net.lingala.zip4j.progress.ProgressMonitor;
|
||||
import org.apache.commons.io.FileUtils;
|
||||
import org.apache.commons.io.IOUtils;
|
||||
import org.apache.commons.lang3.RandomStringUtils;
|
||||
|
||||
import java.io.*;
|
||||
import java.nio.charset.Charset;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
@ -93,8 +96,7 @@ public class DatabaseTask extends Task {
|
||||
new ProgressBarBuilder()
|
||||
.setStyle(ProgressBarStyle.ASCII)
|
||||
.setInitialMax(progressMonitor.getTotalWork())
|
||||
.setTaskName("Adding DB File...")
|
||||
.setUnit("MiB", 1048576);
|
||||
.setTaskName("Adding DB File...");
|
||||
|
||||
try (ProgressBar pb = pbb.build()) {
|
||||
while (!progressMonitor.getState().equals(ProgressMonitor.State.READY)) {
|
||||
@ -104,11 +106,11 @@ public class DatabaseTask extends Task {
|
||||
pb.stepTo(progressMonitor.getTotalWork());
|
||||
} catch (Exception exception) {
|
||||
exception.printStackTrace();
|
||||
outputSQLFile.deleteOnExit();
|
||||
FileUtils.deleteQuietly(outputSQLFile);
|
||||
onDone();
|
||||
}
|
||||
progressMonitor.endProgressMonitor();
|
||||
outputSQLFile.deleteOnExit();
|
||||
FileUtils.deleteQuietly(outputSQLFile);
|
||||
onDone();
|
||||
} catch (Exception ex) {
|
||||
ex.printStackTrace();
|
||||
|
@ -3,12 +3,16 @@ package net.horizoncode.sysbackup.tasks.impl;
|
||||
import me.tongfei.progressbar.ProgressBar;
|
||||
import me.tongfei.progressbar.ProgressBarBuilder;
|
||||
import me.tongfei.progressbar.ProgressBarStyle;
|
||||
import me.tongfei.progressbar.TerminalUtils;
|
||||
import net.horizoncode.sysbackup.tasks.Task;
|
||||
import net.horizoncode.sysbackup.threading.ThreadPool;
|
||||
import net.lingala.zip4j.ZipFile;
|
||||
import net.lingala.zip4j.progress.ProgressMonitor;
|
||||
import org.jline.terminal.Terminal;
|
||||
import org.jline.terminal.TerminalBuilder;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.nio.file.Paths;
|
||||
|
||||
public class FileSystemTask extends Task {
|
||||
@ -46,8 +50,7 @@ public class FileSystemTask extends Task {
|
||||
new ProgressBarBuilder()
|
||||
.setStyle(ProgressBarStyle.ASCII)
|
||||
.setInitialMax(progressMonitor.getTotalWork())
|
||||
.setTaskName("Adding Files...")
|
||||
.setUnit("MiB", 1048576);
|
||||
.setTaskName("Adding Files...");
|
||||
|
||||
try (ProgressBar pb = pbb.build()) {
|
||||
while (!progressMonitor.getState().equals(ProgressMonitor.State.READY)) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user