Skip to content

Commit

Permalink
2.0.1
Browse files Browse the repository at this point in the history
1. 1.20.5/1.20.6 support
2. notSetReadOnly changed to setWorldsReadOnly (default value = true)
3. Improved config description
  • Loading branch information
DVDishka committed May 2, 2024
1 parent 10c3f11 commit 8d8362c
Show file tree
Hide file tree
Showing 6 changed files with 26 additions and 32 deletions.
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -73,8 +73,8 @@


* `Backups folder` - **(Path)** - Full path to folder, where backups will be stored
* `Add directory to backup` - **(List of paths)** - Full directory paths to backup (Worlds will be backed up automatically, so you do not need to specify world folders there) (For example you can specify "plugins", "config")
* `Exclude Directory From Backup` - **(List of paths)** - Full directory paths to exclude from backup. If you want to backup everything from the **folder1** except some **folder1/file1** you can specify **folder1** in `addDirectoryToBackup` and **folder1/file1** in `excludeDirectoryFromBackup`. (The `backupsFolder` directory will be excluded automatically to prevent the loop)
* `Add directory to backup` - **(List of paths)** - Full directory paths to folders/files that you want to be backed up. World folders will be backed up automatically, so you do not need to specify world folders there (For example you can specify "plugins", "config")
* `Exclude Directory From Backup` - **(List of paths)** - Full directory paths to folders/files that you want to be excluded from backup. If you want to backup everything from the **folder1** except some **folder1/file1** you can specify **folder1** in `addDirectoryToBackup` and **folder1/file1** in `excludeDirectoryFromBackup`. (The `backupsFolder` directory will be excluded automatically to prevent the loop)



Expand All @@ -97,7 +97,7 @@


* `Better logging` - **(true/false)** - Enable logging of additional information **(used for debugging, you probably don't need it)**
* `Not set read only` - **(true/false)** - The backuper marks all world folders as **Read Only** to prevent folder changing that may cause the backup crash. To disable this feature set this option to **true**
* `Set worlds read only` - **(true/false)** - **(True recommended)** The backuper will mark all world folders as **Read Only** to prevent folder changing that may cause the backup crash. **True** value may cause **access denied** errors during the backup **(you should just ignore that)**

---

Expand Down
8 changes: 4 additions & 4 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

<groupId>ru.dvdishka</groupId>
<artifactId>Backuper</artifactId>
<version>2.0.0</version>
<version>2.0.1</version>
<packaging>jar</packaging>

<name>Backuper</name>
Expand All @@ -16,7 +16,7 @@
<java.version>1.8</java.version>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
<url>mc.dvdcraft.ru</url>
<url>dvdserv.ru</url>

<build>
<plugins>
Expand Down Expand Up @@ -81,7 +81,7 @@
<dependency>
<groupId>commons-io</groupId>
<artifactId>commons-io</artifactId>
<version>2.11.0</version>
<version>2.16.1</version>
</dependency>
<dependency>
<groupId>org.bstats</groupId>
Expand All @@ -92,7 +92,7 @@
<dependency>
<groupId>dev.jorel</groupId>
<artifactId>commandapi-bukkit-shade</artifactId>
<version>9.3.0</version>
<version>9.4.0</version>
</dependency>
<dependency>
<groupId>io.papermc.paper</groupId>
Expand Down
14 changes: 4 additions & 10 deletions src/main/java/ru/dvdishka/backuper/Backuper.java
Original file line number Diff line number Diff line change
Expand Up @@ -25,20 +25,14 @@ public void onEnable() {
File backupsDir = new File("plugins/Backuper/Backups");
File configFile = new File("plugins/Backuper/config.yml");

if (!pluginDir.exists()) {
if (!pluginDir.exists() && !pluginDir.mkdir()) {

if (!pluginDir.mkdir()) {

Logger.getLogger().warn("Can not create plugins/Backuper dir!");
}
Logger.getLogger().warn("Can not create plugins/Backuper dir!");
}

if (!backupsDir.exists()) {

if (!backupsDir.mkdir()) {
if (!backupsDir.exists() && !backupsDir.mkdir()) {

Logger.getLogger().warn("Can not create plugins/Backuper/Backups dir!");
}
Logger.getLogger().warn("Can not create plugins/Backuper/Backups dir!");
}

Initialization.initConfig(configFile, null);
Expand Down
14 changes: 7 additions & 7 deletions src/main/java/ru/dvdishka/backuper/backend/config/Config.java
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ public class Config {

private File configFile = null;

private final String configVersion = "6.0";
private final String configVersion = "7.0";
private long lastBackup = 0;
private long lastChange = 0;

Expand All @@ -35,7 +35,7 @@ public class Config {
private boolean zipArchive = true;
private long alertTimeBeforeRestart = 60;
private boolean betterLogging = false;
private boolean notSetReadOnly = false;
private boolean setWorldsReadOnly = false;
private boolean alertOnlyServerRestart = true;

private static Config instance = null;
Expand Down Expand Up @@ -97,7 +97,7 @@ public void load(File configFile, CommandSender sender) {
this.addDirectoryToBackup = config.getStringList("addDirectoryToBackup");
this.excludeDirectoryFromBackup = config.getStringList("excludeDirectoryFromBackup");
this.alertTimeBeforeRestart = config.getLong("alertTimeBeforeRestart", 60);
this.notSetReadOnly = config.getBoolean("notSetReadOnly", false);
this.setWorldsReadOnly = config.getBoolean("setWorldsReadOnly", false);
this.alertOnlyServerRestart = config.getBoolean("alertOnlyServerRestart", true);

if (this.backupTime < -1) {
Expand Down Expand Up @@ -135,7 +135,7 @@ public void load(File configFile, CommandSender sender) {
List<String> configFields = List.of("backupTime", "backupPeriod", "afterBackup", "maxBackupsNumber",
"maxBackupsWeight", "zipArchive", "betterLogging", "autoBackup", "lastBackup", "lastChange",
"skipDuplicateBackup", "backupsFolder", "alertTimeBeforeRestart", "addDirectoryToBackup",
"excludeDirectoryFromBackup", "notSetReadOnly", "alertOnlyServerRestart");
"excludeDirectoryFromBackup", "setWorldsReadOnly", "alertOnlyServerRestart");

for (String configField : configFields) {
if (isConfigFileOk && !config.contains(configField)) {
Expand Down Expand Up @@ -171,7 +171,7 @@ public void load(File configFile, CommandSender sender) {
newConfig.set("alertTimeBeforeRestart", this.alertTimeBeforeRestart);
newConfig.set("addDirectoryToBackup", this.addDirectoryToBackup);
newConfig.set("excludeDirectoryFromBackup", this.excludeDirectoryFromBackup);
newConfig.set("notSetReadOnly", this.notSetReadOnly);
newConfig.set("setWorldsReadOnly", this.setWorldsReadOnly);
newConfig.set("alertOnlyServerRestart", this.alertOnlyServerRestart);

try {
Expand Down Expand Up @@ -266,8 +266,8 @@ public FileConfiguration getFileConfiguration() {
return YamlConfiguration.loadConfiguration(configFile);
}

public boolean isNotSetReadOnly() {
return notSetReadOnly;
public boolean isSetWorldsReadOnly() {
return setWorldsReadOnly;
}

public boolean isAlertOnlyServerRestart() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ public void runDeleteOldBackupsSync() {

public static void setWorldsReadOnlySync(CommandSender sender, boolean force) {

if (Config.getInstance().isNotSetReadOnly() && !force) {
if (!Config.getInstance().isSetWorldsReadOnly() && !force) {
return;
}

Expand All @@ -123,7 +123,7 @@ public static void setWorldsReadOnlySync(CommandSender sender, boolean force) {

public static void setWorldsReadOnlySync(CommandSender sender) {

if (Config.getInstance().isNotSetReadOnly()) {
if (!Config.getInstance().isSetWorldsReadOnly()) {
return;
}

Expand All @@ -142,7 +142,7 @@ public static void setWorldsReadOnlySync(CommandSender sender) {

public static void setWorldsWritableSync(CommandSender sender, boolean force) {

if (Config.getInstance().isNotSetReadOnly() && !force) {
if (!Config.getInstance().isSetWorldsReadOnly() && !force) {
return;
}

Expand Down
10 changes: 5 additions & 5 deletions src/main/resources/config.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# DO NOT CHANGE
configVersion: 6.0
configVersion: 7.0
lastBackup: 0
lastChange: 0

Expand All @@ -9,13 +9,13 @@ autoBackup: true

# (Path) Full directory where backups will be stored
backupsFolder: plugins/Backuper/Backups
# (Path list) (An example of how to set a list is below) Full directory paths to backup (Worlds will be backed up automatically, so you do not need to specify world folders there) (For example you can specify "plugins", "config")
# (Path list) (An example of how to set a list is below) Full directory paths to folders/files that you want to be backed up. Worlds will be backed up automatically, so you do not need to specify world folders there (For example you can specify "plugins", "config")
# addDirectoryToBackup:
# - path1
# - path2
# - ...
addDirectoryToBackup: []
# (Path list) (An example of how to set a list is below) Full directory paths to exclude from backup. If you want to backup everything from the folder1 except some folder1/file1 you can specify folder1 in addDirectoryToBackup and folder1/file1 in excludeDirectoryFromBackup. (The backupsFolder directory will be excluded automatically to prevent the loop)
# (Path list) (An example of how to set a list is below) Full directory paths to folders/files that you want to be excluded from backup. If you want to backup everything from the folder1 except some folder1/file1 you can specify folder1 in addDirectoryToBackup and folder1/file1 in excludeDirectoryFromBackup. (The backupsFolder directory will be excluded automatically to prevent the loop)
# excludeDirectoryFromBackup:
# - path1
# - path2
Expand Down Expand Up @@ -45,5 +45,5 @@ alertOnlyServerRestart: true

# (true/false) Better logging (Some statistic and other information for debugging, you probably don't need it)
betterLogging: false
# Backuper marks all world folders as Read Only to prevent folder changing that may cause backup crash. To disable this feature set notSetReadOnly = true
notSetReadOnly: false
# (true/false) (True recommended) The backuper will mark all world folders as Read Only to prevent folder changing that may cause the backup crash. True value may cause access denied errors during the backup (you should just ignore that)
setWorldsReadOnly: false

0 comments on commit 8d8362c

Please sign in to comment.