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