mirror of https://github.com/micromata/borgbackup-butler.git

Kai Reinhard
19.04.2021 f5b3310103ea177182c0eb1d29065b44dd228de0
Support of $BorgButlerHome/environment.sh for setting java options.
5 files modified
94 ■■■■■ changed files
README.adoc 21 ●●●● patch | view | raw | blame | history
borgbutler-core/src/main/kotlin/de/micromata/borgbutler/config/ConfigurationHandler.kt 50 ●●●●● patch | view | raw | blame | history
borgbutler-docker/app/Dockerfile 2 ●●●●● patch | view | raw | blame | history
borgbutler-docker/app/entrypoint.sh 14 ●●●●● patch | view | raw | blame | history
borgbutler-docker/buildDocker.sh 7 ●●●● patch | view | raw | blame | history
README.adoc
@@ -67,7 +67,7 @@
Enjoy BorgButler by opening your browser: http://localhost:9042
You may refer the log file through the web browser or in `$HOME/BorgButler/borgbutler.log`.
You may refer the log file through the web browser or in `${BorgButlerHome}/borgbutler.log`.
For new versions of BorgButler or for changing the running options of your BorgButler container, simply delete the BorgButler docker container by `docker rm borgbutler` and call `docker run` again.
@@ -78,6 +78,8 @@
2. Unzip `borgbutler-server/build/distributions/borgbutler-server-<version>.zip`
3. Run `bin/borgbutler-server` or `bin/borgbutler-server.bat`.
As BorgButler default home directory, `${HOME}/.borgbutler` is used.
=== Starting from sources
You'll need OpenJDK 9+ as well as gradle.
@@ -95,7 +97,7 @@
[source,yaml]
----
borgCommand: "/Users/kai/.borgbutler/bin/borg-macosx64-1.1.9"
borgCommand: "${BorgButlerHome}/bin/borg-macosx64-1.1.9"
maxArchiveContentCacheCapacityMb: 200
repoConfigs:
- displayName: "ACME - Backup server 1"
@@ -121,10 +123,10 @@
Here: link:doc/ExampleBorgConfig{outfilesuffix}[Installation]
==== Backups of configuration files
=== Backups of configuration files
You may configure and initialize your repositories by the BorgButler app. The config file is generated by BorgButler. Before
saving a new configuration BorgButler stores a copy of the current configuration in the backup dir: `~/.borgbutler/backup/`.
saving a new configuration BorgButler stores a copy of the current configuration in the backup dir: `${BorgButlerHome}/backup/`.
== More immpressions
@@ -145,8 +147,15 @@
== Trouble shooting
=== Docker
==== Increase memory (OutOfMemory)
1. `docker rm borgbutler`
2. `docker run -e JAVA_OPTS="-Xmx2G" -v ...`
Edit `${BorgButlerHome}/environment.sh` and restart your docker container (since version 0.7).
[source,bash]
----
#!/bin/bash
export JAVA_OPTS=-DXmx4g
----
If your docker container crashes on heavy usage of large borg archives, check the memory settings of your docker installation.
=== How to download/restore?
borgbutler-core/src/main/kotlin/de/micromata/borgbutler/config/ConfigurationHandler.kt
@@ -76,6 +76,30 @@
        FileUtils.copyFile(file, backupFile)
    }
    init {
        workingDir = if (butlerHomeDir != null) {
            File(butlerHomeDir)
        } else {
            File(System.getProperty("user.home"), BUTLER_HOME_DIR)
        }
        log.info("Using directory '" + workingDir.getAbsolutePath() + "' as BorgButler's home directory.")
        if (!workingDir.exists()) {
            log.info("Creating borg-butlers working directory: " + workingDir.getAbsolutePath())
            workingDir.mkdirs()
        }
        configFile = File(workingDir, CONFIG_FILENAME)
        configBackupDir = File(workingDir, CONFIG_BACKUP_DIR)
        if (!configBackupDir.exists()) {
            log.info("Creating borg-butlers backup directory: " + configBackupDir.absolutePath)
            configBackupDir.mkdirs()
        }
        val environmentFile = File(workingDir, ENVIRONMENT_FILE)
        if (!environmentFile.exists()) {
            environmentFile.writeText(ENVIRONMENT_FILE_INITIAL_CONTENT)
        }
        read()
    }
    companion object {
        private var instance: ConfigurationHandler? = null
        private const val BUTLER_HOME_DIR = ".borgbutler"
@@ -122,25 +146,13 @@
            val yaml = FileUtils.readFileToString(configFile, Definitions.STD_CHARSET)
            return YamlUtils.fromYaml(configClazz, yaml)
        }
    }
    init {
        workingDir = if (butlerHomeDir != null) {
            File(butlerHomeDir)
        } else {
            File(System.getProperty("user.home"), BUTLER_HOME_DIR)
        }
        log.info("Using directory '" + workingDir.getAbsolutePath() + "' as BorgButler's home directory.")
        if (!workingDir.exists()) {
            log.info("Creating borg-butlers working directory: " + workingDir.getAbsolutePath())
            workingDir.mkdirs()
        }
        configFile = File(workingDir, CONFIG_FILENAME)
        configBackupDir = File(workingDir, CONFIG_BACKUP_DIR)
        if (!configBackupDir.exists()) {
            log.info("Creating borg-butlers backup directory: " + configBackupDir.absolutePath)
            configBackupDir.mkdirs()
        }
        read()
        private const val ENVIRONMENT_FILE = "environment.sh"
        private const val ENVIRONMENT_FILE_INITIAL_CONTENT = "#!/bin/bash\n\n" +
                "# Set the java options here:\n" +
                "#export JAVA_OPTS=-DXmx4g\n" +
                "export JAVA_OPTS=\n\n" +
                "# Set your options here (will be used for starting\n" +
                "export JAVA_ARGS=\n"
    }
}
borgbutler-docker/app/Dockerfile
@@ -23,8 +23,6 @@
COPY --chown=borgbutler:borgbutler entrypoint.sh /app
RUN chmod 755 /app/entrypoint.sh
#COPY shutdown.sh /app
#COPY startup.sh /app
# Variable expansion doesn't work for ENTRYPOINT definition as array, but array is required, because graceful shutdown of
# container isn't given if java is started via 'sh -c' as it will be done by ENTRYPOINT java .....
borgbutler-docker/app/entrypoint.sh
@@ -44,6 +44,20 @@
echo "Starting ${APP_NAME}..."
ENVIRONMENT_FILE=/BorgButler/environment.sh
if [ -f "$ENVIRONMENT_FILE" ]; then
  echo "Sourcing $ENVIRONMENT_FILE..."
  . $ENVIRONMENT_FILE
fi
if [ -n "$JAVA_OPTS" ]; then
  echo "JAVA_OPTS=${JAVA_OPTS}"
fi
if [ -n "$JAVA_ARGS" ]; then
  echo "JAVA_ARGS=${JAVA_ARGS}"
fi
#Trap SIGTERM
trap cleanup INT SIGTERM
borgbutler-docker/buildDocker.sh
@@ -16,8 +16,5 @@
echo "docker push kreinhard/borgbutler:latest"
echo
echo
echo "Run without ssh: 'docker run -v $HOME/BorgButler:/BorgButler -p 127.0.0.1:9042:9042 --name borgbutler kreinhard/borgbutler'"
echo "Run with ssh: 'docker run -v $HOME/BorgButler:/BorgButler -v $HOME/.ssh:/home/borgbutler/.ssh:ro -p 127.0.0.1:9042:9042 --name borgbutler kreinhard/borgbutler'"
echo
echo 'Increase Java memory: docker run -e JAVA_OPTS="-Xmx2g" -v ...'
echo "Run 'docker run -v $HOME/BorgButler:/BorgButler -p 127.0.0.1:9042:9042 --name borgbutler kreinhard/borgbutler'"
echo "For remote ssh repos, use option  '-v $HOME/.ssh:/home/borgbutler/.ssh:ro'"