Restore to Docker Service

CommunityEnterprise

To use this restore method, the where= or parameter of a Bacula restore command is used.

The Docker container archive will be sent to the Docker service and restored as a new image and then created as container if the container_create restore parameter is set (this is a default). If the restore parameter container_create is not set then any container will be restored to image level only and user has to create or run the container manually. If restore parameter container_run is set (default is no) then restored container will be started immediate after successful restore.

The Docker image archive will be loaded into the Docker service as the original docker image overwriting the one already exist. This is a default behavior and cannot be changed. You can skip docker image restore of already existent image with Replace option of restore command.

Docker volume restore will extract all files into the same Docker volume. If volume is not defined in Docker then a default local volume will be created. Volume data files restore will always overwrite restored data. This is a current limitation of the plugin and will be removed in the future.

You can change default container name or container image label during restore with container_defaultnames or container_imageid restore parameters (see container_defaultnames: <Yes|No> or container_imageid: <Yes|No>).

Example

To restore a container or image to a Docker service, the administrator should execute the restore command and specify the where parameter as in this example:

* restore where=/

and then set any other required restore plugin parameters for the restore.

In the following restore session example, the container_run plugin restore option is set to “Yes”:

* restore where=/
...
Run Restore job
JobName:         RestoreFiles
Bootstrap:       /opt/bacula/working/docker-test-dir.restore.1.bsr
Where:           /
Replace:         Always
Fileset:         Full Set
Backup Client:   docker-test-fd
Restore Client:  docker-test-fd
Storage:         File1
When:            2018-09-28 14:09:30
Catalog:         MyCatalog
Priority:        10
Plugin Options:  *None*
OK to run? (yes/mod/no): mod
Parameters to modify:
    1: Level
    2: Storage
    3: Job
    4: Fileset
    5: Restore Client
    6: When
    7: Priority
    8: Bootstrap
    9: Where
    10: File Relocation
    11: Replace
    12: JobId
    13: Plugin Options
Select parameter to modify (1-13): 13
Automatically selected : docker: container=mcache1 abort_on_error
Plugin Restore Options
container_create:    *None*               (*Yes*)
container_run:       *None*               (*No*)
container_imageid:   *None*               (*No*)
container_defaultnames: *None*               (*No*)
docker_host:         *None*               (*local*)
Use above plugin configuration? (yes/mod/no): mod
You have the following choices:
    1: container_create (Create container on restore)
    2: container_run (Run container on restore)
    3: container_imageid (Use Image Id for container creation/start)
    4: container_defaultnames (Use default docker Names on container creation)
    5: docker_host (Use defined docker host to restore)
Select parameter to modify (1-4): 2
Please enter a value for container_run: yes
Plugin Restore Options
container_create:    *None*               (*Yes*)
container_run:       yes                  (*No*)
container_imageid:   *None*               (*No*)
container_defaultnames: *None*               (*No*)
docker_host:         *None*               (*local*)
Use above plugin configuration? (yes/mod/no): yes

The restore job log will indicate which container is restored and which new container id was created:

JobId 139: Start Restore Job RestoreFiles.2018-09-28_14.13.31_03
JobId 139: Using Device "FileChgr1-Dev1" to read.
JobId 139: Ready to read from volume "vol001" on File device "FileChgr1-Dev1" (/opt/bacula/archive).
JobId 139: Forward spacing Volume "vol001" to addr=225
JobId 139: docker: Docker Container restore: mcache1/b97d4dd88063
JobId 139: End of Volume "vol001" at addr=62177197 on device "FileChgr1-Dev1" (/opt/bacula/archive).
JobId 139: dkcommctx: Successfully run container as: ef48c6b5b867

The new container created during the restore will get a new container id. You can check it running with a following command:

# docker ps -a
CONTAINER ID        IMAGE                              CREATED             STATUS
ef48c6b5b867        mcache1/b97d4dd88063/139:restore   4 minutes ago       Up 4 minutes

See also

Next articles:

Go back to: Restore.