A ready to use docker container, based on jdbbackup-core, that schedules and executes the backup of a data sources.
This application requires Java11+.
The artifact deployed in Maven central is a runnable jar.
Launch it with java -jar jdbbackup-docker-1.0.0.jar config.json
where config.json is the configuration file (see below) or set the environment variable TASKS_PATH to the path of the configuration file and launch it with java -jar jdbbackup-docker-1.0.0.jar
. You may also leave TASKS_PATH unset, its default value is tasks.json.
If you want to include this application in a Java program, the main class is com.fathzer.jdbbackup.cron.Main.
In order to use the MySQL source, mysqldump command must be installed on the machine that runs this application.
You can run the container with the following command
docker run -d --rm --volume /home/jma/git/jdbbackup-docker/tasks.json:/home/jdbbackup/tasks.json fathzer/db-backup
By default, the path of the configuration file is home/jdbbackup/tasks.json.
You can also easily pass a local file to the image using the --volume docker option:
--volume /home/account/path/backupTasks.json:/home/jdbbackup/tasks.json
You can also define the TASKS_PATH environment variable to use another file path.
You should provide a json configuration file with the following format
{
"proxy":"[user[:pwd]@]@host::port",
"tasks": [{
"name":"Mybackup",
"schedule":"@daily"
"source":"mysql://root:pwd@host:port/database",
"destinations":["s3://bucket/path"]}]
}
JSon attributes:
- proxy: The proxy used to connect to remote servers. This attribute is not mandatory. pwd and user are optional in this attribute.
- tasks: The list of backup tasks. This attribute is mandatory and should not be empty.
- name: The task's name.
- schedule: The task's schedule. This attribute accepts cron-like patterns and the following values:
- @hourly: Every hour on the hour.
- @daily or @midnight: Every day at midnight.
- @weekly: Every Sunday at midnight
- @monthly: Every month the first day of the month at midnight.
- @yearly or @annually: Every year the first day of the year at midnight.
- source: The data source to backup.
- destinations: The destinations where to save the data. It can't be empty.
The container is able to store the backup in various destinations type (sftp server, s3, etc...) the format of addresses passed in destinations attribute depends on the destination type.
The only data source type included in this container is mySQL. You can add your own (Postgres for example) by developing a SourceManager plugin.
Please have a look at jdbbackup-core project to find documentation on existing source and destination managers, and to learn how to develop your own.
To add your own plugins, define the pluginsDirectory environment variable and use --volume docker option to mount a host directory at the path defined in pluginsDirectory.
Example: -e "pluginsDirectory=/plugins" --volume /home/account/path/plugins:/plugins
This image only contains MySQL/MariaDB database source manager and file destination manager. If another source/destination is referenced in the configuration file, without being added through the pluginsDirectory, the container will automatically search it in an Internet plugin repository.
If you want to delete all previously downloaded plugins and reload useful ones at container startup, set the clearDownloadedPlugins system property to true.
By default, the image uses the plugin repository whose root URI is https://jdbbackup.github.io/web/repository/.
The full URL is completed with the image version, for instance https://jdbbackup.github.io/web/repository/1.0.0.json.
If you want to use your own repository, put its root URI in pluginRepository system property.
Your repository should return a json file like the following at the address root/version.
"repository": {
"destinationManagers": [
"sftp":"https://myOwnRepo.com/artifacts/jdbbackup-sftp-1.0.0.jar",
"s3":"https://myOwnRepo.com/artifacts/jdbbackup-s3-1.0.0.jar",
"gcs":"https://myOwnRepo.com/artifacts/jdbbackup-gcs-1.0.0.jar",
"dropbox":"https://myOwnRepo.com/artifacts/jdbbackup-dropbox-1.0.0.jar"
],
"sourceManagers": [
"fake":"https://www.astesana.net/jdbbackup/artifacts/jdbbackup-fakesource-1.0.0.jar"
]
}
Warning absolute URL are mandatory.
Logging is based on the slf4j framework. Logs are bound with LogBack.
The default configuration logs to the console, rejecting entries below info level.
If you want to change logback configuration, please have a look at the logback manual.
- How to build the Docker image?:
mvn package -Pdocker