Wojtek @suda Siudzinski


Python/Node/Golang/Rust developer, DIY hacker, rookie designer, 3D print junkie. CEO @ Gaia Charge


Backup CoreOS's data volumes

Yaron made a great Docker image for creating backups using Duplicity. It's designed to make backups of host directories, but what I wanted is to backup other container's volumes. You can do this with this CoreOS unit file:

[Unit]
Description=Backup
After=docker.service
Requires=docker.service

[Service]
User=core
TimeoutStartSec=5
ExecStart=/bin/bash -c  ' \
  /usr/bin/docker run \
    --volumes-from ghost-override \
    --name=backup-ghost \
    --rm \
    -e  AWS_ACCESS_KEY_ID=<ACCESS_KEY_ID> -e AWS_SECRET_ACCESS_KEY=<ACCESS_KEY> \
    --privileged  \
    --entrypoint "/bin/bash" \
    yaronr/backup-volume-container \
    -c "mount -o bind /ghost-override /var/backup && /run.sh s3+http://<BUCKET>.s3.amazonaws.com/ghost 60"'
    
ExecStop=/usr/bin/docker stop backup-ghost

[Install]
WantedBy=multi-user.target

Just remember to set your info to:

  • Description= your name for this backup service
  • --volumes-from data volume container which is supposed to be backed up
  • --name= friendly name of this container in Docker
  • <ACCESS_KEY_ID>, <ACCESS_KEY> and <BUCKET> your Amazon S3 credentials
  • mount -o bind /ghost-override /var/backup replace /ghost-override with directory where data volume is mounted

Then you can create such service for every data volume you want to back up.

comments powered by Disqus