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

Format for exclude-file AND files-from #164

Open
Enissay opened this issue May 19, 2023 · 3 comments
Open

Format for exclude-file AND files-from #164

Enissay opened this issue May 19, 2023 · 3 comments

Comments

@Enissay
Copy link

Enissay commented May 19, 2023

Hi all,

I was trying to take advantage of the PRE_COMMANDS var to provide a list of files to skip but the syntax doesnt seem to bbe working... I have tried many ways and still failed...

Of course using something like exclude_file_ok.txt (see below) works but is very unredable... Please advise what am I missing ?

...
    environment:

      RESTIC_BACKUP_ARGS: --verbose --exclude-file /mnt/restic_config/exclude_file.txt --tag resticker-auto

      PRE_COMMANDS: |-
        mkdir -p /mnt/restic_config
        
        echo -e ".git/\n.config/\nbin/\nobj/" > /mnt/restic_config/exclude_file_ok.txt
                      
        cat <<- EOF > /mnt/restic_config/exclude_file.txt
          .config/
          .git/
          bin/
          obj/
        EOF

Next, I would like also to provide a list of files/folders from a file to be loaded using restic's --files-from, but I don't see such option for resticker, or have I missed it ?

The idea here is to create a different list to backup for each host of the swarm if [[ "{{.Node.Hostname}}" == "host1" ]]; then echo "## list to include 1" > /mnt/restic_config/include_file.txt; elif ... fi

In any case, such file will be crated the same way as for the exclusion list, so It would also benefit the solution for the above issue...

Thank you

@Enissay Enissay changed the title exclude-file AND files-from Format for exclude-file AND files-from May 19, 2023
@Enissay
Copy link
Author

Enissay commented May 23, 2023

As workaround I managed to do it like this:

  • For Q1:
    It is not as optimized as the above but it achieves what's needed: easily readable + ability to add comments
      PRE_COMMANDS: |-
        mkdir -p /mnt/restic_config

        # Exclude file        
        echo "# Generals"         >> /mnt/restic_config/exclude_file.txt
        echo ".config/"           >> /mnt/restic_config/exclude_file.txt
        echo ".git/"              >> /mnt/restic_config/exclude_file.txt
        echo "..."                >> /mnt/restic_config/exclude_file.txt
  • For Q2:
    For RESTIC_BACKUP_SOURCES, the project does not seem to support reading files to BU from a text file. It seems to simply parse the given values as string split up by spaces. So no way to add comments or try to make it nicely readable
      RESTIC_BACKUP_SOURCES: >-
        # Category 1
        /mnt/path11
        /mnt/path12
        # Category 2
        /mnt/path21
        /mnt/path22
        # Category 3
        /mnt/path31
        #...

I am not sure if anyone have better ideas for the above ?

@djmaze
Copy link
Owner

djmaze commented Jul 6, 2023

Sorry for the late answer. For Q1, you could just create your exclude file locally and then mount it into the container, like this:

services:
  backup:
    environment:
      RESTIC_BACKUP_ARGS: --verbose --exclude-file /mnt/restic_config/exclude_file.txt --tag resticker-auto
    configs:
      source: exclude_file.txt
      target: /mnt/restic_config/exclude_file.txt
  # ...

configs:
   exclude_file.txt:
     file: exclude_file.txt

@djmaze
Copy link
Owner

djmaze commented Jul 6, 2023

For a host-specific config, you could one service for each host (so set a different constraint on node.hostname for each service).

Or you could just use a bind mount (using volumes:) for mounting a config file from each host. But then you would need to create those files on each host beforehand.

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

No branches or pull requests

2 participants