Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

archive/tar: sockets not supported #58

Closed
2 tasks
rk0n opened this issue Feb 8, 2022 · 4 comments
Closed
2 tasks

archive/tar: sockets not supported #58

rk0n opened this issue Feb 8, 2022 · 4 comments
Labels

Comments

@rk0n
Copy link

rk0n commented Feb 8, 2022

  • I'm submitting a ...

    • [X ] bug report
    • feature request
    • support request
  • What is the current behavior?
    When trying to backup a gitlab docker volume I get an error and no tar file:

level=error msg="Fatal error running backup: takeBackup: error compressing backup folder: archive/tar: sockets not supported"
  • If the current behavior is a bug, please provide the configuration and steps to reproduce and if possible a minimal demo of the problem.
version: '3.6'
services:
  nginx:
    image: nginxproxy/nginx-proxy
    restart: always
    ports:
      - "80:80"
      - "443:443"
    labels:
      - docker-volume-backup.stop-during-backup=true
    volumes:
      - /var/run/docker.sock:/tmp/docker.sock:ro
      - ./data/nginx/certs:/etc/nginx/certs:ro
      - ./data/nginx/vhosts:/etc/nginx/vhost.d
      - ./data/nginx/html:/usr/share/nginx/html
    networks:
      - proxy

  proxy-companion:
    restart: always
    image: sebastienheyd/self-signed-proxy-companion
    labels:
      - docker-volume-backup.stop-during-backup=true
    volumes:
        - /var/run/docker.sock:/var/run/docker.sock:ro
        - ./data/nginx/certs:/etc/nginx/certs:rw
    depends_on:
      - nginx

  gitlab:
    image: 'gitlab/gitlab-ce:14.7.0-ce.0'
    restart: always
    hostname: 'git.localhost'
    shm_size: '256m'
    volumes:
      - ./data/gitlab/config:/etc/gitlab
      - ./data/gitlab/logs:/var/log/gitlab
      - ./data/gitlab/data:/var/opt/gitlab
    environment:
      VIRTUAL_HOST: git.localhost
      VIRTUAL_PORT: 80
      SELF_SIGNED_HOST: git.localhost
      GITLAB_OMNIBUS_CONFIG: |
         external_url 'https://git.localhost'
         nginx['listen_port'] = 80
         nginx['listen_https'] = false
    labels:
      - docker-volume-backup.stop-during-backup=true
    ports:
      - "10022:22"
    networks:
      - proxy

  backup:
    image: offen/docker-volume-backup:v2.10.0
    environment:
      # A backup is taken each day at 3AM
      BACKUP_CRON_EXPRESSION: "0 3 * * *"
      BACKUP_FILENAME: backup-%Y-%m-%dT%H-%M-%S.tar.gz
      BACKUP_RETENTION_DAYS: 7
      GPG_PASSPHRASE: secretkey
    volumes:
      - /var/run/docker.sock:/var/run/docker.sock:ro
      - /etc/timezone:/etc/timezone:ro
      - /etc/localtime:/etc/localtime:ro
      - ./backups:/archive
      - ./:/backup/docker-compose:ro
      - ./data/gitlab/data:/backup/gitlab/data:ro
      - ./data/gitlab/logs:/backup/gitlab/logs:ro
      - ./data/gitlab/config:/backup/gitlab/config:ro

Do:
docker-compose up -d
docker exec backup backup
level=error msg="Fatal error running backup: takeBackup: error compressing backup folder: archive/tar: sockets not supported"

  • What is the expected behavior?
    Ignore sockets and create tar file. Maybe a info for the user in the log.

  • What is the motivation / use case for changing the behavior?
    Increases the compatibility

  • Please tell us about your environment:

    • Image version: 2.10.0
    • Docker version: 20.10.12
    • docker-compose version: 2.2.3
@m90
Copy link
Member

m90 commented Feb 8, 2022

Thanks for raising this. This is an issue upstream at https://github.com/m90/targz, but luckily I am in control of that repo so we should be able to fix it.

I'm not entirely sure how to fix it yet though. It seems that good old command line tar seems to ignore sockets (thus creating an archive), but still exits non-zero in such cases https://serverfault.com/questions/525805/getting-errors-while-making-backup-of-whole-centos-with-tar unless you explicitly exclude the offending paths. I'd like to think about this a little longer so the fix for this doesn't turn into something with unforeseen consequences.

In the meantine, I think you should be able to work around this by actively excluding the offending sockets from the backup as described in #42 and here: https://stackoverflow.com/questions/29181032/add-a-volume-to-docker-but-exclude-a-sub-folder

@m90 m90 added the upstream label Feb 8, 2022
@m90
Copy link
Member

m90 commented Feb 8, 2022

For reference, here's a similar issue and fix elsewhere GoogleContainerTools/kaniko#288

@m90
Copy link
Member

m90 commented Feb 8, 2022

I looked around more and it seems everyone who creates tar archives in native Go will just skip sockets, so I guess it's ok to do the same here.

A fix for this is now included in v2.10.1. Let me know if it works for you.

@m90 m90 closed this as completed Feb 11, 2022
@rk0n
Copy link
Author

rk0n commented Apr 1, 2022

Everything works like expected now. Thank you for fixing the issue that quick!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants