Just curious if there is an easy way to back up my docker-compose.yaml and .env files. I have the following directory structure for my containers:

-docker
  -<name of container>
    -.env
    -docker-compose.yml

I’d like to copy those two files for each container folder but no other subfolders that may also be in the container folder (config, data, etc). I’ve been trying to get my restic backups to do it but I just can’t figure it out.

Is there a better way? I’d like to have backups in case my entire server dies.

UPDATE: Thank you all for the advice, I’m giving git a try and so far so good!

    • grimer@lemmy.worldOP
      link
      fedilink
      English
      arrow-up
      3
      ·
      3 days ago

      In my particular case I only have a few .env files and they don’t have any credentials in them. This is mostly for the docker-compose files.

      • shadybraden@programming.dev
        link
        fedilink
        English
        arrow-up
        2
        ·
        edit-2
        3 days ago

        You can specify a folder in your files for configs, and a different one for the compose and env:

        - config
           - <container_config>
        - docker
          - container 
              - compose.yml
        

        Edit: then you can map your volume not to ./config:/config but instead to /config/containerName:/config

      • PunkRockSportsFan@fanaticus.social
        link
        fedilink
        English
        arrow-up
        1
        ·
        3 days ago

        It’s like you have secrets that you pull in to build your .env which should only be used by the stuff that needs it and it’s not shared.

        I’m assuming this is a production backup and the idea that someone has a prod .env file gives me the Willies.

        Id want to change all the cards.