djmaze / resticker

Run automatic restic backups via a Docker container.
https://hub.docker.com/r/mazzolino/restic/
Apache License 2.0
512 stars 71 forks source link

pre command question about backup up mongo db? #167

Closed killmasta93 closed 9 months ago

killmasta93 commented 1 year ago

Hi I was wondering if someone else has had this issue before currently i can use the pre command to backup mysql and postgre but cant seem to get it working on mongo this is what i have so far

docker exec -i 4minitz-mongo-1 /usr/bin/mongodump --gzip --archive=db.archive | restic backup --tag meetingsdb --stdin --stdin-filename db.archive

but it gives an our saying invalid

but if i run it manually it works fine

Thank you

nettnikl commented 9 months ago

I think you are confusing | and &&

djmaze commented 9 months ago

@nettnikl No, he is not. He wants to pipe the mongo dump into restic for backing it up, which is possible.

The problem is probably the escaping of the command. As a quick solution, I propose putting the command into a bash script and mounting the script into the restic container so you can run it instead.

So, something like this:

  backup:
    # ...
    environment:
      PRE_COMMANDS: |-
        /usr/local/bin/backup_mongo.sh
    volumes:
      - ./backup_mongo.sh:/usr/local/bin/backup_mongo.sh
killmasta93 commented 9 months ago

Thank you